babylon.module.d.ts 4.9 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933
  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/webRequest" {
  4967. /**
  4968. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  4969. */
  4970. export class WebRequest {
  4971. private _xhr;
  4972. /**
  4973. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  4974. * i.e. when loading files, where the server/service expects an Authorization header
  4975. */
  4976. static CustomRequestHeaders: {
  4977. [key: string]: string;
  4978. };
  4979. /**
  4980. * Add callback functions in this array to update all the requests before they get sent to the network
  4981. */
  4982. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  4983. private _injectCustomRequestHeaders;
  4984. /**
  4985. * Gets or sets a function to be called when loading progress changes
  4986. */
  4987. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  4988. /**
  4989. * Returns client's state
  4990. */
  4991. readonly readyState: number;
  4992. /**
  4993. * Returns client's status
  4994. */
  4995. readonly status: number;
  4996. /**
  4997. * Returns client's status as a text
  4998. */
  4999. readonly statusText: string;
  5000. /**
  5001. * Returns client's response
  5002. */
  5003. readonly response: any;
  5004. /**
  5005. * Returns client's response url
  5006. */
  5007. readonly responseURL: string;
  5008. /**
  5009. * Returns client's response as text
  5010. */
  5011. readonly responseText: string;
  5012. /**
  5013. * Gets or sets the expected response type
  5014. */
  5015. responseType: XMLHttpRequestResponseType;
  5016. /** @hidden */
  5017. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5018. /** @hidden */
  5019. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5020. /**
  5021. * Cancels any network activity
  5022. */
  5023. abort(): void;
  5024. /**
  5025. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5026. * @param body defines an optional request body
  5027. */
  5028. send(body?: Document | BodyInit | null): void;
  5029. /**
  5030. * Sets the request method, request URL
  5031. * @param method defines the method to use (GET, POST, etc..)
  5032. * @param url defines the url to connect with
  5033. */
  5034. open(method: string, url: string): void;
  5035. }
  5036. }
  5037. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5038. /**
  5039. * Class used to evalaute queries containing `and` and `or` operators
  5040. */
  5041. export class AndOrNotEvaluator {
  5042. /**
  5043. * Evaluate a query
  5044. * @param query defines the query to evaluate
  5045. * @param evaluateCallback defines the callback used to filter result
  5046. * @returns true if the query matches
  5047. */
  5048. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5049. private static _HandleParenthesisContent;
  5050. private static _SimplifyNegation;
  5051. }
  5052. }
  5053. declare module "babylonjs/Misc/tags" {
  5054. /**
  5055. * Class used to store custom tags
  5056. */
  5057. export class Tags {
  5058. /**
  5059. * Adds support for tags on the given object
  5060. * @param obj defines the object to use
  5061. */
  5062. static EnableFor(obj: any): void;
  5063. /**
  5064. * Removes tags support
  5065. * @param obj defines the object to use
  5066. */
  5067. static DisableFor(obj: any): void;
  5068. /**
  5069. * Gets a boolean indicating if the given object has tags
  5070. * @param obj defines the object to use
  5071. * @returns a boolean
  5072. */
  5073. static HasTags(obj: any): boolean;
  5074. /**
  5075. * Gets the tags available on a given object
  5076. * @param obj defines the object to use
  5077. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5078. * @returns the tags
  5079. */
  5080. static GetTags(obj: any, asString?: boolean): any;
  5081. /**
  5082. * Adds tags to an object
  5083. * @param obj defines the object to use
  5084. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5085. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5086. */
  5087. static AddTagsTo(obj: any, tagsString: string): void;
  5088. /**
  5089. * @hidden
  5090. */
  5091. static _AddTagTo(obj: any, tag: string): void;
  5092. /**
  5093. * Removes specific tags from a specific object
  5094. * @param obj defines the object to use
  5095. * @param tagsString defines the tags to remove
  5096. */
  5097. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5098. /**
  5099. * @hidden
  5100. */
  5101. static _RemoveTagFrom(obj: any, tag: string): void;
  5102. /**
  5103. * Defines if tags hosted on an object match a given query
  5104. * @param obj defines the object to use
  5105. * @param tagsQuery defines the tag query
  5106. * @returns a boolean
  5107. */
  5108. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5109. }
  5110. }
  5111. declare module "babylonjs/Materials/materialDefines" {
  5112. /**
  5113. * Manages the defines for the Material
  5114. */
  5115. export class MaterialDefines {
  5116. private _keys;
  5117. private _isDirty;
  5118. /** @hidden */
  5119. _renderId: number;
  5120. /** @hidden */
  5121. _areLightsDirty: boolean;
  5122. /** @hidden */
  5123. _areAttributesDirty: boolean;
  5124. /** @hidden */
  5125. _areTexturesDirty: boolean;
  5126. /** @hidden */
  5127. _areFresnelDirty: boolean;
  5128. /** @hidden */
  5129. _areMiscDirty: boolean;
  5130. /** @hidden */
  5131. _areImageProcessingDirty: boolean;
  5132. /** @hidden */
  5133. _normals: boolean;
  5134. /** @hidden */
  5135. _uvs: boolean;
  5136. /** @hidden */
  5137. _needNormals: boolean;
  5138. /** @hidden */
  5139. _needUVs: boolean;
  5140. /**
  5141. * Specifies if the material needs to be re-calculated
  5142. */
  5143. readonly isDirty: boolean;
  5144. /**
  5145. * Marks the material to indicate that it has been re-calculated
  5146. */
  5147. markAsProcessed(): void;
  5148. /**
  5149. * Marks the material to indicate that it needs to be re-calculated
  5150. */
  5151. markAsUnprocessed(): void;
  5152. /**
  5153. * Marks the material to indicate all of its defines need to be re-calculated
  5154. */
  5155. markAllAsDirty(): void;
  5156. /**
  5157. * Marks the material to indicate that image processing needs to be re-calculated
  5158. */
  5159. markAsImageProcessingDirty(): void;
  5160. /**
  5161. * Marks the material to indicate the lights need to be re-calculated
  5162. */
  5163. markAsLightDirty(): void;
  5164. /**
  5165. * Marks the attribute state as changed
  5166. */
  5167. markAsAttributesDirty(): void;
  5168. /**
  5169. * Marks the texture state as changed
  5170. */
  5171. markAsTexturesDirty(): void;
  5172. /**
  5173. * Marks the fresnel state as changed
  5174. */
  5175. markAsFresnelDirty(): void;
  5176. /**
  5177. * Marks the misc state as changed
  5178. */
  5179. markAsMiscDirty(): void;
  5180. /**
  5181. * Rebuilds the material defines
  5182. */
  5183. rebuild(): void;
  5184. /**
  5185. * Specifies if two material defines are equal
  5186. * @param other - A material define instance to compare to
  5187. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5188. */
  5189. isEqual(other: MaterialDefines): boolean;
  5190. /**
  5191. * Clones this instance's defines to another instance
  5192. * @param other - material defines to clone values to
  5193. */
  5194. cloneTo(other: MaterialDefines): void;
  5195. /**
  5196. * Resets the material define values
  5197. */
  5198. reset(): void;
  5199. /**
  5200. * Converts the material define values to a string
  5201. * @returns - String of material define information
  5202. */
  5203. toString(): string;
  5204. }
  5205. }
  5206. declare module "babylonjs/Misc/performanceMonitor" {
  5207. /**
  5208. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5209. */
  5210. export class PerformanceMonitor {
  5211. private _enabled;
  5212. private _rollingFrameTime;
  5213. private _lastFrameTimeMs;
  5214. /**
  5215. * constructor
  5216. * @param frameSampleSize The number of samples required to saturate the sliding window
  5217. */
  5218. constructor(frameSampleSize?: number);
  5219. /**
  5220. * Samples current frame
  5221. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5222. */
  5223. sampleFrame(timeMs?: number): void;
  5224. /**
  5225. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5226. */
  5227. readonly averageFrameTime: number;
  5228. /**
  5229. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5230. */
  5231. readonly averageFrameTimeVariance: number;
  5232. /**
  5233. * Returns the frame time of the most recent frame
  5234. */
  5235. readonly instantaneousFrameTime: number;
  5236. /**
  5237. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5238. */
  5239. readonly averageFPS: number;
  5240. /**
  5241. * Returns the average framerate in frames per second using the most recent frame time
  5242. */
  5243. readonly instantaneousFPS: number;
  5244. /**
  5245. * Returns true if enough samples have been taken to completely fill the sliding window
  5246. */
  5247. readonly isSaturated: boolean;
  5248. /**
  5249. * Enables contributions to the sliding window sample set
  5250. */
  5251. enable(): void;
  5252. /**
  5253. * Disables contributions to the sliding window sample set
  5254. * Samples will not be interpolated over the disabled period
  5255. */
  5256. disable(): void;
  5257. /**
  5258. * Returns true if sampling is enabled
  5259. */
  5260. readonly isEnabled: boolean;
  5261. /**
  5262. * Resets performance monitor
  5263. */
  5264. reset(): void;
  5265. }
  5266. /**
  5267. * RollingAverage
  5268. *
  5269. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5270. */
  5271. export class RollingAverage {
  5272. /**
  5273. * Current average
  5274. */
  5275. average: number;
  5276. /**
  5277. * Current variance
  5278. */
  5279. variance: number;
  5280. protected _samples: Array<number>;
  5281. protected _sampleCount: number;
  5282. protected _pos: number;
  5283. protected _m2: number;
  5284. /**
  5285. * constructor
  5286. * @param length The number of samples required to saturate the sliding window
  5287. */
  5288. constructor(length: number);
  5289. /**
  5290. * Adds a sample to the sample set
  5291. * @param v The sample value
  5292. */
  5293. add(v: number): void;
  5294. /**
  5295. * Returns previously added values or null if outside of history or outside the sliding window domain
  5296. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5297. * @return Value previously recorded with add() or null if outside of range
  5298. */
  5299. history(i: number): number;
  5300. /**
  5301. * Returns true if enough samples have been taken to completely fill the sliding window
  5302. * @return true if sample-set saturated
  5303. */
  5304. isSaturated(): boolean;
  5305. /**
  5306. * Resets the rolling average (equivalent to 0 samples taken so far)
  5307. */
  5308. reset(): void;
  5309. /**
  5310. * Wraps a value around the sample range boundaries
  5311. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5312. * @return Wrapped position in sample range
  5313. */
  5314. protected _wrapPosition(i: number): number;
  5315. }
  5316. }
  5317. declare module "babylonjs/Misc/stringDictionary" {
  5318. import { Nullable } from "babylonjs/types";
  5319. /**
  5320. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5321. * The underlying implementation relies on an associative array to ensure the best performances.
  5322. * The value can be anything including 'null' but except 'undefined'
  5323. */
  5324. export class StringDictionary<T> {
  5325. /**
  5326. * This will clear this dictionary and copy the content from the 'source' one.
  5327. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5328. * @param source the dictionary to take the content from and copy to this dictionary
  5329. */
  5330. copyFrom(source: StringDictionary<T>): void;
  5331. /**
  5332. * Get a value based from its key
  5333. * @param key the given key to get the matching value from
  5334. * @return the value if found, otherwise undefined is returned
  5335. */
  5336. get(key: string): T | undefined;
  5337. /**
  5338. * Get a value from its key or add it if it doesn't exist.
  5339. * This method will ensure you that a given key/data will be present in the dictionary.
  5340. * @param key the given key to get the matching value from
  5341. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5342. * The factory will only be invoked if there's no data for the given key.
  5343. * @return the value corresponding to the key.
  5344. */
  5345. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5346. /**
  5347. * Get a value from its key if present in the dictionary otherwise add it
  5348. * @param key the key to get the value from
  5349. * @param val if there's no such key/value pair in the dictionary add it with this value
  5350. * @return the value corresponding to the key
  5351. */
  5352. getOrAdd(key: string, val: T): T;
  5353. /**
  5354. * Check if there's a given key in the dictionary
  5355. * @param key the key to check for
  5356. * @return true if the key is present, false otherwise
  5357. */
  5358. contains(key: string): boolean;
  5359. /**
  5360. * Add a new key and its corresponding value
  5361. * @param key the key to add
  5362. * @param value the value corresponding to the key
  5363. * @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
  5364. */
  5365. add(key: string, value: T): boolean;
  5366. /**
  5367. * Update a specific value associated to a key
  5368. * @param key defines the key to use
  5369. * @param value defines the value to store
  5370. * @returns true if the value was updated (or false if the key was not found)
  5371. */
  5372. set(key: string, value: T): boolean;
  5373. /**
  5374. * Get the element of the given key and remove it from the dictionary
  5375. * @param key defines the key to search
  5376. * @returns the value associated with the key or null if not found
  5377. */
  5378. getAndRemove(key: string): Nullable<T>;
  5379. /**
  5380. * Remove a key/value from the dictionary.
  5381. * @param key the key to remove
  5382. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5383. */
  5384. remove(key: string): boolean;
  5385. /**
  5386. * Clear the whole content of the dictionary
  5387. */
  5388. clear(): void;
  5389. /**
  5390. * Gets the current count
  5391. */
  5392. readonly count: number;
  5393. /**
  5394. * Execute a callback on each key/val of the dictionary.
  5395. * Note that you can remove any element in this dictionary in the callback implementation
  5396. * @param callback the callback to execute on a given key/value pair
  5397. */
  5398. forEach(callback: (key: string, val: T) => void): void;
  5399. /**
  5400. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5401. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5402. * Note that you can remove any element in this dictionary in the callback implementation
  5403. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5404. * @returns the first item
  5405. */
  5406. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5407. private _count;
  5408. private _data;
  5409. }
  5410. }
  5411. declare module "babylonjs/Misc/promise" {
  5412. /**
  5413. * Helper class that provides a small promise polyfill
  5414. */
  5415. export class PromisePolyfill {
  5416. /**
  5417. * Static function used to check if the polyfill is required
  5418. * If this is the case then the function will inject the polyfill to window.Promise
  5419. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5420. */
  5421. static Apply(force?: boolean): void;
  5422. }
  5423. }
  5424. declare module "babylonjs/Meshes/buffer" {
  5425. import { Nullable, DataArray } from "babylonjs/types";
  5426. /**
  5427. * Class used to store data that will be store in GPU memory
  5428. */
  5429. export class Buffer {
  5430. private _engine;
  5431. private _buffer;
  5432. /** @hidden */
  5433. _data: Nullable<DataArray>;
  5434. private _updatable;
  5435. private _instanced;
  5436. /**
  5437. * Gets the byte stride.
  5438. */
  5439. readonly byteStride: number;
  5440. /**
  5441. * Constructor
  5442. * @param engine the engine
  5443. * @param data the data to use for this buffer
  5444. * @param updatable whether the data is updatable
  5445. * @param stride the stride (optional)
  5446. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5447. * @param instanced whether the buffer is instanced (optional)
  5448. * @param useBytes set to true if the stride in in bytes (optional)
  5449. */
  5450. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5451. /**
  5452. * Create a new VertexBuffer based on the current buffer
  5453. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5454. * @param offset defines offset in the buffer (0 by default)
  5455. * @param size defines the size in floats of attributes (position is 3 for instance)
  5456. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5457. * @param instanced defines if the vertex buffer contains indexed data
  5458. * @param useBytes defines if the offset and stride are in bytes
  5459. * @returns the new vertex buffer
  5460. */
  5461. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5462. /**
  5463. * Gets a boolean indicating if the Buffer is updatable?
  5464. * @returns true if the buffer is updatable
  5465. */
  5466. isUpdatable(): boolean;
  5467. /**
  5468. * Gets current buffer's data
  5469. * @returns a DataArray or null
  5470. */
  5471. getData(): Nullable<DataArray>;
  5472. /**
  5473. * Gets underlying native buffer
  5474. * @returns underlying native buffer
  5475. */
  5476. getBuffer(): Nullable<WebGLBuffer>;
  5477. /**
  5478. * Gets the stride in float32 units (i.e. byte stride / 4).
  5479. * May not be an integer if the byte stride is not divisible by 4.
  5480. * DEPRECATED. Use byteStride instead.
  5481. * @returns the stride in float32 units
  5482. */
  5483. getStrideSize(): number;
  5484. /**
  5485. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5486. * @param data defines the data to store
  5487. */
  5488. create(data?: Nullable<DataArray>): void;
  5489. /** @hidden */
  5490. _rebuild(): void;
  5491. /**
  5492. * Update current buffer data
  5493. * @param data defines the data to store
  5494. */
  5495. update(data: DataArray): void;
  5496. /**
  5497. * Updates the data directly.
  5498. * @param data the new data
  5499. * @param offset the new offset
  5500. * @param vertexCount the vertex count (optional)
  5501. * @param useBytes set to true if the offset is in bytes
  5502. */
  5503. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5504. /**
  5505. * Release all resources
  5506. */
  5507. dispose(): void;
  5508. }
  5509. /**
  5510. * Specialized buffer used to store vertex data
  5511. */
  5512. export class VertexBuffer {
  5513. /** @hidden */
  5514. _buffer: Buffer;
  5515. private _kind;
  5516. private _size;
  5517. private _ownsBuffer;
  5518. private _instanced;
  5519. private _instanceDivisor;
  5520. /**
  5521. * The byte type.
  5522. */
  5523. static readonly BYTE: number;
  5524. /**
  5525. * The unsigned byte type.
  5526. */
  5527. static readonly UNSIGNED_BYTE: number;
  5528. /**
  5529. * The short type.
  5530. */
  5531. static readonly SHORT: number;
  5532. /**
  5533. * The unsigned short type.
  5534. */
  5535. static readonly UNSIGNED_SHORT: number;
  5536. /**
  5537. * The integer type.
  5538. */
  5539. static readonly INT: number;
  5540. /**
  5541. * The unsigned integer type.
  5542. */
  5543. static readonly UNSIGNED_INT: number;
  5544. /**
  5545. * The float type.
  5546. */
  5547. static readonly FLOAT: number;
  5548. /**
  5549. * Gets or sets the instance divisor when in instanced mode
  5550. */
  5551. instanceDivisor: number;
  5552. /**
  5553. * Gets the byte stride.
  5554. */
  5555. readonly byteStride: number;
  5556. /**
  5557. * Gets the byte offset.
  5558. */
  5559. readonly byteOffset: number;
  5560. /**
  5561. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5562. */
  5563. readonly normalized: boolean;
  5564. /**
  5565. * Gets the data type of each component in the array.
  5566. */
  5567. readonly type: number;
  5568. /**
  5569. * Constructor
  5570. * @param engine the engine
  5571. * @param data the data to use for this vertex buffer
  5572. * @param kind the vertex buffer kind
  5573. * @param updatable whether the data is updatable
  5574. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5575. * @param stride the stride (optional)
  5576. * @param instanced whether the buffer is instanced (optional)
  5577. * @param offset the offset of the data (optional)
  5578. * @param size the number of components (optional)
  5579. * @param type the type of the component (optional)
  5580. * @param normalized whether the data contains normalized data (optional)
  5581. * @param useBytes set to true if stride and offset are in bytes (optional)
  5582. */
  5583. 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);
  5584. /** @hidden */
  5585. _rebuild(): void;
  5586. /**
  5587. * Returns the kind of the VertexBuffer (string)
  5588. * @returns a string
  5589. */
  5590. getKind(): string;
  5591. /**
  5592. * Gets a boolean indicating if the VertexBuffer is updatable?
  5593. * @returns true if the buffer is updatable
  5594. */
  5595. isUpdatable(): boolean;
  5596. /**
  5597. * Gets current buffer's data
  5598. * @returns a DataArray or null
  5599. */
  5600. getData(): Nullable<DataArray>;
  5601. /**
  5602. * Gets underlying native buffer
  5603. * @returns underlying native buffer
  5604. */
  5605. getBuffer(): Nullable<WebGLBuffer>;
  5606. /**
  5607. * Gets the stride in float32 units (i.e. byte stride / 4).
  5608. * May not be an integer if the byte stride is not divisible by 4.
  5609. * DEPRECATED. Use byteStride instead.
  5610. * @returns the stride in float32 units
  5611. */
  5612. getStrideSize(): number;
  5613. /**
  5614. * Returns the offset as a multiple of the type byte length.
  5615. * DEPRECATED. Use byteOffset instead.
  5616. * @returns the offset in bytes
  5617. */
  5618. getOffset(): number;
  5619. /**
  5620. * Returns the number of components per vertex attribute (integer)
  5621. * @returns the size in float
  5622. */
  5623. getSize(): number;
  5624. /**
  5625. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5626. * @returns true if this buffer is instanced
  5627. */
  5628. getIsInstanced(): boolean;
  5629. /**
  5630. * Returns the instancing divisor, zero for non-instanced (integer).
  5631. * @returns a number
  5632. */
  5633. getInstanceDivisor(): number;
  5634. /**
  5635. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5636. * @param data defines the data to store
  5637. */
  5638. create(data?: DataArray): void;
  5639. /**
  5640. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5641. * This function will create a new buffer if the current one is not updatable
  5642. * @param data defines the data to store
  5643. */
  5644. update(data: DataArray): void;
  5645. /**
  5646. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5647. * Returns the directly updated WebGLBuffer.
  5648. * @param data the new data
  5649. * @param offset the new offset
  5650. * @param useBytes set to true if the offset is in bytes
  5651. */
  5652. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5653. /**
  5654. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5655. */
  5656. dispose(): void;
  5657. /**
  5658. * Enumerates each value of this vertex buffer as numbers.
  5659. * @param count the number of values to enumerate
  5660. * @param callback the callback function called for each value
  5661. */
  5662. forEach(count: number, callback: (value: number, index: number) => void): void;
  5663. /**
  5664. * Positions
  5665. */
  5666. static readonly PositionKind: string;
  5667. /**
  5668. * Normals
  5669. */
  5670. static readonly NormalKind: string;
  5671. /**
  5672. * Tangents
  5673. */
  5674. static readonly TangentKind: string;
  5675. /**
  5676. * Texture coordinates
  5677. */
  5678. static readonly UVKind: string;
  5679. /**
  5680. * Texture coordinates 2
  5681. */
  5682. static readonly UV2Kind: string;
  5683. /**
  5684. * Texture coordinates 3
  5685. */
  5686. static readonly UV3Kind: string;
  5687. /**
  5688. * Texture coordinates 4
  5689. */
  5690. static readonly UV4Kind: string;
  5691. /**
  5692. * Texture coordinates 5
  5693. */
  5694. static readonly UV5Kind: string;
  5695. /**
  5696. * Texture coordinates 6
  5697. */
  5698. static readonly UV6Kind: string;
  5699. /**
  5700. * Colors
  5701. */
  5702. static readonly ColorKind: string;
  5703. /**
  5704. * Matrix indices (for bones)
  5705. */
  5706. static readonly MatricesIndicesKind: string;
  5707. /**
  5708. * Matrix weights (for bones)
  5709. */
  5710. static readonly MatricesWeightsKind: string;
  5711. /**
  5712. * Additional matrix indices (for bones)
  5713. */
  5714. static readonly MatricesIndicesExtraKind: string;
  5715. /**
  5716. * Additional matrix weights (for bones)
  5717. */
  5718. static readonly MatricesWeightsExtraKind: string;
  5719. /**
  5720. * Deduces the stride given a kind.
  5721. * @param kind The kind string to deduce
  5722. * @returns The deduced stride
  5723. */
  5724. static DeduceStride(kind: string): number;
  5725. /**
  5726. * Gets the byte length of the given type.
  5727. * @param type the type
  5728. * @returns the number of bytes
  5729. */
  5730. static GetTypeByteLength(type: number): number;
  5731. /**
  5732. * Enumerates each value of the given parameters as numbers.
  5733. * @param data the data to enumerate
  5734. * @param byteOffset the byte offset of the data
  5735. * @param byteStride the byte stride of the data
  5736. * @param componentCount the number of components per element
  5737. * @param componentType the type of the component
  5738. * @param count the total number of components
  5739. * @param normalized whether the data is normalized
  5740. * @param callback the callback function called for each value
  5741. */
  5742. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5743. private static _GetFloatValue;
  5744. }
  5745. }
  5746. declare module "babylonjs/Maths/sphericalPolynomial" {
  5747. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5748. /**
  5749. * Class representing spherical polynomial coefficients to the 3rd degree
  5750. */
  5751. export class SphericalPolynomial {
  5752. /**
  5753. * The x coefficients of the spherical polynomial
  5754. */
  5755. x: Vector3;
  5756. /**
  5757. * The y coefficients of the spherical polynomial
  5758. */
  5759. y: Vector3;
  5760. /**
  5761. * The z coefficients of the spherical polynomial
  5762. */
  5763. z: Vector3;
  5764. /**
  5765. * The xx coefficients of the spherical polynomial
  5766. */
  5767. xx: Vector3;
  5768. /**
  5769. * The yy coefficients of the spherical polynomial
  5770. */
  5771. yy: Vector3;
  5772. /**
  5773. * The zz coefficients of the spherical polynomial
  5774. */
  5775. zz: Vector3;
  5776. /**
  5777. * The xy coefficients of the spherical polynomial
  5778. */
  5779. xy: Vector3;
  5780. /**
  5781. * The yz coefficients of the spherical polynomial
  5782. */
  5783. yz: Vector3;
  5784. /**
  5785. * The zx coefficients of the spherical polynomial
  5786. */
  5787. zx: Vector3;
  5788. /**
  5789. * Adds an ambient color to the spherical polynomial
  5790. * @param color the color to add
  5791. */
  5792. addAmbient(color: Color3): void;
  5793. /**
  5794. * Scales the spherical polynomial by the given amount
  5795. * @param scale the amount to scale
  5796. */
  5797. scale(scale: number): void;
  5798. /**
  5799. * Gets the spherical polynomial from harmonics
  5800. * @param harmonics the spherical harmonics
  5801. * @returns the spherical polynomial
  5802. */
  5803. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5804. /**
  5805. * Constructs a spherical polynomial from an array.
  5806. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5807. * @returns the spherical polynomial
  5808. */
  5809. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5810. }
  5811. /**
  5812. * Class representing spherical harmonics coefficients to the 3rd degree
  5813. */
  5814. export class SphericalHarmonics {
  5815. /**
  5816. * The l0,0 coefficients of the spherical harmonics
  5817. */
  5818. l00: Vector3;
  5819. /**
  5820. * The l1,-1 coefficients of the spherical harmonics
  5821. */
  5822. l1_1: Vector3;
  5823. /**
  5824. * The l1,0 coefficients of the spherical harmonics
  5825. */
  5826. l10: Vector3;
  5827. /**
  5828. * The l1,1 coefficients of the spherical harmonics
  5829. */
  5830. l11: Vector3;
  5831. /**
  5832. * The l2,-2 coefficients of the spherical harmonics
  5833. */
  5834. l2_2: Vector3;
  5835. /**
  5836. * The l2,-1 coefficients of the spherical harmonics
  5837. */
  5838. l2_1: Vector3;
  5839. /**
  5840. * The l2,0 coefficients of the spherical harmonics
  5841. */
  5842. l20: Vector3;
  5843. /**
  5844. * The l2,1 coefficients of the spherical harmonics
  5845. */
  5846. l21: Vector3;
  5847. /**
  5848. * The l2,2 coefficients of the spherical harmonics
  5849. */
  5850. lL22: Vector3;
  5851. /**
  5852. * Adds a light to the spherical harmonics
  5853. * @param direction the direction of the light
  5854. * @param color the color of the light
  5855. * @param deltaSolidAngle the delta solid angle of the light
  5856. */
  5857. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5858. /**
  5859. * Scales the spherical harmonics by the given amount
  5860. * @param scale the amount to scale
  5861. */
  5862. scale(scale: number): void;
  5863. /**
  5864. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5865. *
  5866. * ```
  5867. * E_lm = A_l * L_lm
  5868. * ```
  5869. *
  5870. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5871. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5872. * the scaling factors are given in equation 9.
  5873. */
  5874. convertIncidentRadianceToIrradiance(): void;
  5875. /**
  5876. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5877. *
  5878. * ```
  5879. * L = (1/pi) * E * rho
  5880. * ```
  5881. *
  5882. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5883. */
  5884. convertIrradianceToLambertianRadiance(): void;
  5885. /**
  5886. * Gets the spherical harmonics from polynomial
  5887. * @param polynomial the spherical polynomial
  5888. * @returns the spherical harmonics
  5889. */
  5890. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5891. /**
  5892. * Constructs a spherical harmonics from an array.
  5893. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5894. * @returns the spherical harmonics
  5895. */
  5896. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5897. }
  5898. }
  5899. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  5900. import { Nullable } from "babylonjs/types";
  5901. /**
  5902. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5903. */
  5904. export interface CubeMapInfo {
  5905. /**
  5906. * The pixel array for the front face.
  5907. * This is stored in format, left to right, up to down format.
  5908. */
  5909. front: Nullable<ArrayBufferView>;
  5910. /**
  5911. * The pixel array for the back face.
  5912. * This is stored in format, left to right, up to down format.
  5913. */
  5914. back: Nullable<ArrayBufferView>;
  5915. /**
  5916. * The pixel array for the left face.
  5917. * This is stored in format, left to right, up to down format.
  5918. */
  5919. left: Nullable<ArrayBufferView>;
  5920. /**
  5921. * The pixel array for the right face.
  5922. * This is stored in format, left to right, up to down format.
  5923. */
  5924. right: Nullable<ArrayBufferView>;
  5925. /**
  5926. * The pixel array for the up face.
  5927. * This is stored in format, left to right, up to down format.
  5928. */
  5929. up: Nullable<ArrayBufferView>;
  5930. /**
  5931. * The pixel array for the down face.
  5932. * This is stored in format, left to right, up to down format.
  5933. */
  5934. down: Nullable<ArrayBufferView>;
  5935. /**
  5936. * The size of the cubemap stored.
  5937. *
  5938. * Each faces will be size * size pixels.
  5939. */
  5940. size: number;
  5941. /**
  5942. * The format of the texture.
  5943. *
  5944. * RGBA, RGB.
  5945. */
  5946. format: number;
  5947. /**
  5948. * The type of the texture data.
  5949. *
  5950. * UNSIGNED_INT, FLOAT.
  5951. */
  5952. type: number;
  5953. /**
  5954. * Specifies whether the texture is in gamma space.
  5955. */
  5956. gammaSpace: boolean;
  5957. }
  5958. /**
  5959. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5960. */
  5961. export class PanoramaToCubeMapTools {
  5962. private static FACE_FRONT;
  5963. private static FACE_BACK;
  5964. private static FACE_RIGHT;
  5965. private static FACE_LEFT;
  5966. private static FACE_DOWN;
  5967. private static FACE_UP;
  5968. /**
  5969. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5970. *
  5971. * @param float32Array The source data.
  5972. * @param inputWidth The width of the input panorama.
  5973. * @param inputHeight The height of the input panorama.
  5974. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5975. * @return The cubemap data
  5976. */
  5977. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5978. private static CreateCubemapTexture;
  5979. private static CalcProjectionSpherical;
  5980. }
  5981. }
  5982. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  5983. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  5984. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  5985. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  5986. /**
  5987. * Helper class dealing with the extraction of spherical polynomial dataArray
  5988. * from a cube map.
  5989. */
  5990. export class CubeMapToSphericalPolynomialTools {
  5991. private static FileFaces;
  5992. /**
  5993. * Converts a texture to the according Spherical Polynomial data.
  5994. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5995. *
  5996. * @param texture The texture to extract the information from.
  5997. * @return The Spherical Polynomial data.
  5998. */
  5999. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6000. /**
  6001. * Converts a cubemap to the according Spherical Polynomial data.
  6002. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6003. *
  6004. * @param cubeInfo The Cube map to extract the information from.
  6005. * @return The Spherical Polynomial data.
  6006. */
  6007. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6008. }
  6009. }
  6010. declare module "babylonjs/Engines/engineStore" {
  6011. import { Nullable } from "babylonjs/types";
  6012. import { Engine } from "babylonjs/Engines/engine";
  6013. import { Scene } from "babylonjs/scene";
  6014. /**
  6015. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6016. * during the life time of the application.
  6017. */
  6018. export class EngineStore {
  6019. /** Gets the list of created engines */
  6020. static Instances: import("babylonjs/Engines/engine").Engine[];
  6021. /**
  6022. * Gets the latest created engine
  6023. */
  6024. static readonly LastCreatedEngine: Nullable<Engine>;
  6025. /**
  6026. * Gets the latest created scene
  6027. */
  6028. static readonly LastCreatedScene: Nullable<Scene>;
  6029. }
  6030. }
  6031. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  6032. /**
  6033. * Define options used to create a render target texture
  6034. */
  6035. export class RenderTargetCreationOptions {
  6036. /**
  6037. * Specifies is mipmaps must be generated
  6038. */
  6039. generateMipMaps?: boolean;
  6040. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6041. generateDepthBuffer?: boolean;
  6042. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6043. generateStencilBuffer?: boolean;
  6044. /** Defines texture type (int by default) */
  6045. type?: number;
  6046. /** Defines sampling mode (trilinear by default) */
  6047. samplingMode?: number;
  6048. /** Defines format (RGBA by default) */
  6049. format?: number;
  6050. }
  6051. }
  6052. declare module "babylonjs/States/alphaCullingState" {
  6053. /**
  6054. * @hidden
  6055. **/
  6056. export class _AlphaState {
  6057. private _isAlphaBlendDirty;
  6058. private _isBlendFunctionParametersDirty;
  6059. private _isBlendEquationParametersDirty;
  6060. private _isBlendConstantsDirty;
  6061. private _alphaBlend;
  6062. private _blendFunctionParameters;
  6063. private _blendEquationParameters;
  6064. private _blendConstants;
  6065. /**
  6066. * Initializes the state.
  6067. */
  6068. constructor();
  6069. readonly isDirty: boolean;
  6070. alphaBlend: boolean;
  6071. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6072. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6073. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6074. reset(): void;
  6075. apply(gl: WebGLRenderingContext): void;
  6076. }
  6077. }
  6078. declare module "babylonjs/States/depthCullingState" {
  6079. import { Nullable } from "babylonjs/types";
  6080. /**
  6081. * @hidden
  6082. **/
  6083. export class _DepthCullingState {
  6084. private _isDepthTestDirty;
  6085. private _isDepthMaskDirty;
  6086. private _isDepthFuncDirty;
  6087. private _isCullFaceDirty;
  6088. private _isCullDirty;
  6089. private _isZOffsetDirty;
  6090. private _isFrontFaceDirty;
  6091. private _depthTest;
  6092. private _depthMask;
  6093. private _depthFunc;
  6094. private _cull;
  6095. private _cullFace;
  6096. private _zOffset;
  6097. private _frontFace;
  6098. /**
  6099. * Initializes the state.
  6100. */
  6101. constructor();
  6102. readonly isDirty: boolean;
  6103. zOffset: number;
  6104. cullFace: Nullable<number>;
  6105. cull: Nullable<boolean>;
  6106. depthFunc: Nullable<number>;
  6107. depthMask: boolean;
  6108. depthTest: boolean;
  6109. frontFace: Nullable<number>;
  6110. reset(): void;
  6111. apply(gl: WebGLRenderingContext): void;
  6112. }
  6113. }
  6114. declare module "babylonjs/States/stencilState" {
  6115. /**
  6116. * @hidden
  6117. **/
  6118. export class _StencilState {
  6119. /** 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 */
  6120. static readonly ALWAYS: number;
  6121. /** Passed to stencilOperation to specify that stencil value must be kept */
  6122. static readonly KEEP: number;
  6123. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6124. static readonly REPLACE: number;
  6125. private _isStencilTestDirty;
  6126. private _isStencilMaskDirty;
  6127. private _isStencilFuncDirty;
  6128. private _isStencilOpDirty;
  6129. private _stencilTest;
  6130. private _stencilMask;
  6131. private _stencilFunc;
  6132. private _stencilFuncRef;
  6133. private _stencilFuncMask;
  6134. private _stencilOpStencilFail;
  6135. private _stencilOpDepthFail;
  6136. private _stencilOpStencilDepthPass;
  6137. readonly isDirty: boolean;
  6138. stencilFunc: number;
  6139. stencilFuncRef: number;
  6140. stencilFuncMask: number;
  6141. stencilOpStencilFail: number;
  6142. stencilOpDepthFail: number;
  6143. stencilOpStencilDepthPass: number;
  6144. stencilMask: number;
  6145. stencilTest: boolean;
  6146. constructor();
  6147. reset(): void;
  6148. apply(gl: WebGLRenderingContext): void;
  6149. }
  6150. }
  6151. declare module "babylonjs/States/index" {
  6152. export * from "babylonjs/States/alphaCullingState";
  6153. export * from "babylonjs/States/depthCullingState";
  6154. export * from "babylonjs/States/stencilState";
  6155. }
  6156. declare module "babylonjs/Instrumentation/timeToken" {
  6157. import { Nullable } from "babylonjs/types";
  6158. /**
  6159. * @hidden
  6160. **/
  6161. export class _TimeToken {
  6162. _startTimeQuery: Nullable<WebGLQuery>;
  6163. _endTimeQuery: Nullable<WebGLQuery>;
  6164. _timeElapsedQuery: Nullable<WebGLQuery>;
  6165. _timeElapsedQueryEnded: boolean;
  6166. }
  6167. }
  6168. declare module "babylonjs/Materials/Textures/internalTextureTracker" {
  6169. import { Nullable } from "babylonjs/types";
  6170. /**
  6171. * Internal interface used to track InternalTexture already bound to the GL context
  6172. */
  6173. export interface IInternalTextureTracker {
  6174. /**
  6175. * Gets or set the previous tracker in the list
  6176. */
  6177. previous: Nullable<IInternalTextureTracker>;
  6178. /**
  6179. * Gets or set the next tracker in the list
  6180. */
  6181. next: Nullable<IInternalTextureTracker>;
  6182. }
  6183. /**
  6184. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  6185. */
  6186. export class DummyInternalTextureTracker {
  6187. /**
  6188. * Gets or set the previous tracker in the list
  6189. */
  6190. previous: Nullable<IInternalTextureTracker>;
  6191. /**
  6192. * Gets or set the next tracker in the list
  6193. */
  6194. next: Nullable<IInternalTextureTracker>;
  6195. }
  6196. }
  6197. declare module "babylonjs/Materials/Textures/internalTexture" {
  6198. import { Observable } from "babylonjs/Misc/observable";
  6199. import { Nullable, int } from "babylonjs/types";
  6200. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6201. import { IInternalTextureTracker } from "babylonjs/Materials/Textures/internalTextureTracker";
  6202. import { Engine } from "babylonjs/Engines/engine";
  6203. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6204. /**
  6205. * Class used to store data associated with WebGL texture data for the engine
  6206. * This class should not be used directly
  6207. */
  6208. export class InternalTexture implements IInternalTextureTracker {
  6209. /** hidden */
  6210. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6211. /**
  6212. * The source of the texture data is unknown
  6213. */
  6214. static DATASOURCE_UNKNOWN: number;
  6215. /**
  6216. * Texture data comes from an URL
  6217. */
  6218. static DATASOURCE_URL: number;
  6219. /**
  6220. * Texture data is only used for temporary storage
  6221. */
  6222. static DATASOURCE_TEMP: number;
  6223. /**
  6224. * Texture data comes from raw data (ArrayBuffer)
  6225. */
  6226. static DATASOURCE_RAW: number;
  6227. /**
  6228. * Texture content is dynamic (video or dynamic texture)
  6229. */
  6230. static DATASOURCE_DYNAMIC: number;
  6231. /**
  6232. * Texture content is generated by rendering to it
  6233. */
  6234. static DATASOURCE_RENDERTARGET: number;
  6235. /**
  6236. * Texture content is part of a multi render target process
  6237. */
  6238. static DATASOURCE_MULTIRENDERTARGET: number;
  6239. /**
  6240. * Texture data comes from a cube data file
  6241. */
  6242. static DATASOURCE_CUBE: number;
  6243. /**
  6244. * Texture data comes from a raw cube data
  6245. */
  6246. static DATASOURCE_CUBERAW: number;
  6247. /**
  6248. * Texture data come from a prefiltered cube data file
  6249. */
  6250. static DATASOURCE_CUBEPREFILTERED: number;
  6251. /**
  6252. * Texture content is raw 3D data
  6253. */
  6254. static DATASOURCE_RAW3D: number;
  6255. /**
  6256. * Texture content is a depth texture
  6257. */
  6258. static DATASOURCE_DEPTHTEXTURE: number;
  6259. /**
  6260. * Texture data comes from a raw cube data encoded with RGBD
  6261. */
  6262. static DATASOURCE_CUBERAW_RGBD: number;
  6263. /**
  6264. * Defines if the texture is ready
  6265. */
  6266. isReady: boolean;
  6267. /**
  6268. * Defines if the texture is a cube texture
  6269. */
  6270. isCube: boolean;
  6271. /**
  6272. * Defines if the texture contains 3D data
  6273. */
  6274. is3D: boolean;
  6275. /**
  6276. * Gets the URL used to load this texture
  6277. */
  6278. url: string;
  6279. /**
  6280. * Gets the sampling mode of the texture
  6281. */
  6282. samplingMode: number;
  6283. /**
  6284. * Gets a boolean indicating if the texture needs mipmaps generation
  6285. */
  6286. generateMipMaps: boolean;
  6287. /**
  6288. * Gets the number of samples used by the texture (WebGL2+ only)
  6289. */
  6290. samples: number;
  6291. /**
  6292. * Gets the type of the texture (int, float...)
  6293. */
  6294. type: number;
  6295. /**
  6296. * Gets the format of the texture (RGB, RGBA...)
  6297. */
  6298. format: number;
  6299. /**
  6300. * Observable called when the texture is loaded
  6301. */
  6302. onLoadedObservable: Observable<InternalTexture>;
  6303. /**
  6304. * Gets the width of the texture
  6305. */
  6306. width: number;
  6307. /**
  6308. * Gets the height of the texture
  6309. */
  6310. height: number;
  6311. /**
  6312. * Gets the depth of the texture
  6313. */
  6314. depth: number;
  6315. /**
  6316. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6317. */
  6318. baseWidth: number;
  6319. /**
  6320. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6321. */
  6322. baseHeight: number;
  6323. /**
  6324. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6325. */
  6326. baseDepth: number;
  6327. /**
  6328. * Gets a boolean indicating if the texture is inverted on Y axis
  6329. */
  6330. invertY: boolean;
  6331. /**
  6332. * Gets or set the previous tracker in the list
  6333. */
  6334. previous: Nullable<IInternalTextureTracker>;
  6335. /**
  6336. * Gets or set the next tracker in the list
  6337. */
  6338. next: Nullable<IInternalTextureTracker>;
  6339. /** @hidden */
  6340. _invertVScale: boolean;
  6341. /** @hidden */
  6342. _initialSlot: number;
  6343. /** @hidden */
  6344. _designatedSlot: number;
  6345. /** @hidden */
  6346. _dataSource: number;
  6347. /** @hidden */
  6348. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6349. /** @hidden */
  6350. _bufferView: Nullable<ArrayBufferView>;
  6351. /** @hidden */
  6352. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6353. /** @hidden */
  6354. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6355. /** @hidden */
  6356. _size: number;
  6357. /** @hidden */
  6358. _extension: string;
  6359. /** @hidden */
  6360. _files: Nullable<string[]>;
  6361. /** @hidden */
  6362. _workingCanvas: HTMLCanvasElement;
  6363. /** @hidden */
  6364. _workingContext: CanvasRenderingContext2D;
  6365. /** @hidden */
  6366. _framebuffer: Nullable<WebGLFramebuffer>;
  6367. /** @hidden */
  6368. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6369. /** @hidden */
  6370. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6371. /** @hidden */
  6372. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6373. /** @hidden */
  6374. _attachments: Nullable<number[]>;
  6375. /** @hidden */
  6376. _cachedCoordinatesMode: Nullable<number>;
  6377. /** @hidden */
  6378. _cachedWrapU: Nullable<number>;
  6379. /** @hidden */
  6380. _cachedWrapV: Nullable<number>;
  6381. /** @hidden */
  6382. _cachedWrapR: Nullable<number>;
  6383. /** @hidden */
  6384. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6385. /** @hidden */
  6386. _isDisabled: boolean;
  6387. /** @hidden */
  6388. _compression: Nullable<string>;
  6389. /** @hidden */
  6390. _generateStencilBuffer: boolean;
  6391. /** @hidden */
  6392. _generateDepthBuffer: boolean;
  6393. /** @hidden */
  6394. _comparisonFunction: number;
  6395. /** @hidden */
  6396. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6397. /** @hidden */
  6398. _lodGenerationScale: number;
  6399. /** @hidden */
  6400. _lodGenerationOffset: number;
  6401. /** @hidden */
  6402. _lodTextureHigh: BaseTexture;
  6403. /** @hidden */
  6404. _lodTextureMid: BaseTexture;
  6405. /** @hidden */
  6406. _lodTextureLow: BaseTexture;
  6407. /** @hidden */
  6408. _isRGBD: boolean;
  6409. /** @hidden */
  6410. _webGLTexture: Nullable<WebGLTexture>;
  6411. /** @hidden */
  6412. _references: number;
  6413. private _engine;
  6414. /**
  6415. * Gets the Engine the texture belongs to.
  6416. * @returns The babylon engine
  6417. */
  6418. getEngine(): Engine;
  6419. /**
  6420. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6421. */
  6422. readonly dataSource: number;
  6423. /**
  6424. * Creates a new InternalTexture
  6425. * @param engine defines the engine to use
  6426. * @param dataSource defines the type of data that will be used
  6427. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6428. */
  6429. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6430. /**
  6431. * Increments the number of references (ie. the number of Texture that point to it)
  6432. */
  6433. incrementReferences(): void;
  6434. /**
  6435. * Change the size of the texture (not the size of the content)
  6436. * @param width defines the new width
  6437. * @param height defines the new height
  6438. * @param depth defines the new depth (1 by default)
  6439. */
  6440. updateSize(width: int, height: int, depth?: int): void;
  6441. /** @hidden */
  6442. _rebuild(): void;
  6443. /** @hidden */
  6444. _swapAndDie(target: InternalTexture): void;
  6445. /**
  6446. * Dispose the current allocated resources
  6447. */
  6448. dispose(): void;
  6449. }
  6450. }
  6451. declare module "babylonjs/Animations/easing" {
  6452. /**
  6453. * This represents the main contract an easing function should follow.
  6454. * Easing functions are used throughout the animation system.
  6455. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6456. */
  6457. export interface IEasingFunction {
  6458. /**
  6459. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6460. * of the easing function.
  6461. * The link below provides some of the most common examples of easing functions.
  6462. * @see https://easings.net/
  6463. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6464. * @returns the corresponding value on the curve defined by the easing function
  6465. */
  6466. ease(gradient: number): number;
  6467. }
  6468. /**
  6469. * Base class used for every default easing function.
  6470. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6471. */
  6472. export class EasingFunction implements IEasingFunction {
  6473. /**
  6474. * Interpolation follows the mathematical formula associated with the easing function.
  6475. */
  6476. static readonly EASINGMODE_EASEIN: number;
  6477. /**
  6478. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6479. */
  6480. static readonly EASINGMODE_EASEOUT: number;
  6481. /**
  6482. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6483. */
  6484. static readonly EASINGMODE_EASEINOUT: number;
  6485. private _easingMode;
  6486. /**
  6487. * Sets the easing mode of the current function.
  6488. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6489. */
  6490. setEasingMode(easingMode: number): void;
  6491. /**
  6492. * Gets the current easing mode.
  6493. * @returns the easing mode
  6494. */
  6495. getEasingMode(): number;
  6496. /**
  6497. * @hidden
  6498. */
  6499. easeInCore(gradient: number): number;
  6500. /**
  6501. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6502. * of the easing function.
  6503. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6504. * @returns the corresponding value on the curve defined by the easing function
  6505. */
  6506. ease(gradient: number): number;
  6507. }
  6508. /**
  6509. * Easing function with a circle shape (see link below).
  6510. * @see https://easings.net/#easeInCirc
  6511. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6512. */
  6513. export class CircleEase extends EasingFunction implements IEasingFunction {
  6514. /** @hidden */
  6515. easeInCore(gradient: number): number;
  6516. }
  6517. /**
  6518. * Easing function with a ease back shape (see link below).
  6519. * @see https://easings.net/#easeInBack
  6520. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6521. */
  6522. export class BackEase extends EasingFunction implements IEasingFunction {
  6523. /** Defines the amplitude of the function */
  6524. amplitude: number;
  6525. /**
  6526. * Instantiates a back ease easing
  6527. * @see https://easings.net/#easeInBack
  6528. * @param amplitude Defines the amplitude of the function
  6529. */
  6530. constructor(
  6531. /** Defines the amplitude of the function */
  6532. amplitude?: number);
  6533. /** @hidden */
  6534. easeInCore(gradient: number): number;
  6535. }
  6536. /**
  6537. * Easing function with a bouncing shape (see link below).
  6538. * @see https://easings.net/#easeInBounce
  6539. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6540. */
  6541. export class BounceEase extends EasingFunction implements IEasingFunction {
  6542. /** Defines the number of bounces */
  6543. bounces: number;
  6544. /** Defines the amplitude of the bounce */
  6545. bounciness: number;
  6546. /**
  6547. * Instantiates a bounce easing
  6548. * @see https://easings.net/#easeInBounce
  6549. * @param bounces Defines the number of bounces
  6550. * @param bounciness Defines the amplitude of the bounce
  6551. */
  6552. constructor(
  6553. /** Defines the number of bounces */
  6554. bounces?: number,
  6555. /** Defines the amplitude of the bounce */
  6556. bounciness?: number);
  6557. /** @hidden */
  6558. easeInCore(gradient: number): number;
  6559. }
  6560. /**
  6561. * Easing function with a power of 3 shape (see link below).
  6562. * @see https://easings.net/#easeInCubic
  6563. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6564. */
  6565. export class CubicEase extends EasingFunction implements IEasingFunction {
  6566. /** @hidden */
  6567. easeInCore(gradient: number): number;
  6568. }
  6569. /**
  6570. * Easing function with an elastic shape (see link below).
  6571. * @see https://easings.net/#easeInElastic
  6572. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6573. */
  6574. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6575. /** Defines the number of oscillations*/
  6576. oscillations: number;
  6577. /** Defines the amplitude of the oscillations*/
  6578. springiness: number;
  6579. /**
  6580. * Instantiates an elastic easing function
  6581. * @see https://easings.net/#easeInElastic
  6582. * @param oscillations Defines the number of oscillations
  6583. * @param springiness Defines the amplitude of the oscillations
  6584. */
  6585. constructor(
  6586. /** Defines the number of oscillations*/
  6587. oscillations?: number,
  6588. /** Defines the amplitude of the oscillations*/
  6589. springiness?: number);
  6590. /** @hidden */
  6591. easeInCore(gradient: number): number;
  6592. }
  6593. /**
  6594. * Easing function with an exponential shape (see link below).
  6595. * @see https://easings.net/#easeInExpo
  6596. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6597. */
  6598. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6599. /** Defines the exponent of the function */
  6600. exponent: number;
  6601. /**
  6602. * Instantiates an exponential easing function
  6603. * @see https://easings.net/#easeInExpo
  6604. * @param exponent Defines the exponent of the function
  6605. */
  6606. constructor(
  6607. /** Defines the exponent of the function */
  6608. exponent?: number);
  6609. /** @hidden */
  6610. easeInCore(gradient: number): number;
  6611. }
  6612. /**
  6613. * Easing function with a power shape (see link below).
  6614. * @see https://easings.net/#easeInQuad
  6615. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6616. */
  6617. export class PowerEase extends EasingFunction implements IEasingFunction {
  6618. /** Defines the power of the function */
  6619. power: number;
  6620. /**
  6621. * Instantiates an power base easing function
  6622. * @see https://easings.net/#easeInQuad
  6623. * @param power Defines the power of the function
  6624. */
  6625. constructor(
  6626. /** Defines the power of the function */
  6627. power?: number);
  6628. /** @hidden */
  6629. easeInCore(gradient: number): number;
  6630. }
  6631. /**
  6632. * Easing function with a power of 2 shape (see link below).
  6633. * @see https://easings.net/#easeInQuad
  6634. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6635. */
  6636. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6637. /** @hidden */
  6638. easeInCore(gradient: number): number;
  6639. }
  6640. /**
  6641. * Easing function with a power of 4 shape (see link below).
  6642. * @see https://easings.net/#easeInQuart
  6643. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6644. */
  6645. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6646. /** @hidden */
  6647. easeInCore(gradient: number): number;
  6648. }
  6649. /**
  6650. * Easing function with a power of 5 shape (see link below).
  6651. * @see https://easings.net/#easeInQuint
  6652. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6653. */
  6654. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6655. /** @hidden */
  6656. easeInCore(gradient: number): number;
  6657. }
  6658. /**
  6659. * Easing function with a sin shape (see link below).
  6660. * @see https://easings.net/#easeInSine
  6661. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6662. */
  6663. export class SineEase extends EasingFunction implements IEasingFunction {
  6664. /** @hidden */
  6665. easeInCore(gradient: number): number;
  6666. }
  6667. /**
  6668. * Easing function with a bezier shape (see link below).
  6669. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6670. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6671. */
  6672. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6673. /** Defines the x component of the start tangent in the bezier curve */
  6674. x1: number;
  6675. /** Defines the y component of the start tangent in the bezier curve */
  6676. y1: number;
  6677. /** Defines the x component of the end tangent in the bezier curve */
  6678. x2: number;
  6679. /** Defines the y component of the end tangent in the bezier curve */
  6680. y2: number;
  6681. /**
  6682. * Instantiates a bezier function
  6683. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6684. * @param x1 Defines the x component of the start tangent in the bezier curve
  6685. * @param y1 Defines the y component of the start tangent in the bezier curve
  6686. * @param x2 Defines the x component of the end tangent in the bezier curve
  6687. * @param y2 Defines the y component of the end tangent in the bezier curve
  6688. */
  6689. constructor(
  6690. /** Defines the x component of the start tangent in the bezier curve */
  6691. x1?: number,
  6692. /** Defines the y component of the start tangent in the bezier curve */
  6693. y1?: number,
  6694. /** Defines the x component of the end tangent in the bezier curve */
  6695. x2?: number,
  6696. /** Defines the y component of the end tangent in the bezier curve */
  6697. y2?: number);
  6698. /** @hidden */
  6699. easeInCore(gradient: number): number;
  6700. }
  6701. }
  6702. declare module "babylonjs/Animations/animationKey" {
  6703. /**
  6704. * Defines an interface which represents an animation key frame
  6705. */
  6706. export interface IAnimationKey {
  6707. /**
  6708. * Frame of the key frame
  6709. */
  6710. frame: number;
  6711. /**
  6712. * Value at the specifies key frame
  6713. */
  6714. value: any;
  6715. /**
  6716. * The input tangent for the cubic hermite spline
  6717. */
  6718. inTangent?: any;
  6719. /**
  6720. * The output tangent for the cubic hermite spline
  6721. */
  6722. outTangent?: any;
  6723. /**
  6724. * The animation interpolation type
  6725. */
  6726. interpolation?: AnimationKeyInterpolation;
  6727. }
  6728. /**
  6729. * Enum for the animation key frame interpolation type
  6730. */
  6731. export enum AnimationKeyInterpolation {
  6732. /**
  6733. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6734. */
  6735. STEP = 1
  6736. }
  6737. }
  6738. declare module "babylonjs/Animations/animationRange" {
  6739. /**
  6740. * Represents the range of an animation
  6741. */
  6742. export class AnimationRange {
  6743. /**The name of the animation range**/
  6744. name: string;
  6745. /**The starting frame of the animation */
  6746. from: number;
  6747. /**The ending frame of the animation*/
  6748. to: number;
  6749. /**
  6750. * Initializes the range of an animation
  6751. * @param name The name of the animation range
  6752. * @param from The starting frame of the animation
  6753. * @param to The ending frame of the animation
  6754. */
  6755. constructor(
  6756. /**The name of the animation range**/
  6757. name: string,
  6758. /**The starting frame of the animation */
  6759. from: number,
  6760. /**The ending frame of the animation*/
  6761. to: number);
  6762. /**
  6763. * Makes a copy of the animation range
  6764. * @returns A copy of the animation range
  6765. */
  6766. clone(): AnimationRange;
  6767. }
  6768. }
  6769. declare module "babylonjs/Animations/animationEvent" {
  6770. /**
  6771. * Composed of a frame, and an action function
  6772. */
  6773. export class AnimationEvent {
  6774. /** The frame for which the event is triggered **/
  6775. frame: number;
  6776. /** The event to perform when triggered **/
  6777. action: (currentFrame: number) => void;
  6778. /** Specifies if the event should be triggered only once**/
  6779. onlyOnce?: boolean | undefined;
  6780. /**
  6781. * Specifies if the animation event is done
  6782. */
  6783. isDone: boolean;
  6784. /**
  6785. * Initializes the animation event
  6786. * @param frame The frame for which the event is triggered
  6787. * @param action The event to perform when triggered
  6788. * @param onlyOnce Specifies if the event should be triggered only once
  6789. */
  6790. constructor(
  6791. /** The frame for which the event is triggered **/
  6792. frame: number,
  6793. /** The event to perform when triggered **/
  6794. action: (currentFrame: number) => void,
  6795. /** Specifies if the event should be triggered only once**/
  6796. onlyOnce?: boolean | undefined);
  6797. /** @hidden */
  6798. _clone(): AnimationEvent;
  6799. }
  6800. }
  6801. declare module "babylonjs/Behaviors/behavior" {
  6802. import { Nullable } from "babylonjs/types";
  6803. /**
  6804. * Interface used to define a behavior
  6805. */
  6806. export interface Behavior<T> {
  6807. /** gets or sets behavior's name */
  6808. name: string;
  6809. /**
  6810. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6811. */
  6812. init(): void;
  6813. /**
  6814. * Called when the behavior is attached to a target
  6815. * @param target defines the target where the behavior is attached to
  6816. */
  6817. attach(target: T): void;
  6818. /**
  6819. * Called when the behavior is detached from its target
  6820. */
  6821. detach(): void;
  6822. }
  6823. /**
  6824. * Interface implemented by classes supporting behaviors
  6825. */
  6826. export interface IBehaviorAware<T> {
  6827. /**
  6828. * Attach a behavior
  6829. * @param behavior defines the behavior to attach
  6830. * @returns the current host
  6831. */
  6832. addBehavior(behavior: Behavior<T>): T;
  6833. /**
  6834. * Remove a behavior from the current object
  6835. * @param behavior defines the behavior to detach
  6836. * @returns the current host
  6837. */
  6838. removeBehavior(behavior: Behavior<T>): T;
  6839. /**
  6840. * Gets a behavior using its name to search
  6841. * @param name defines the name to search
  6842. * @returns the behavior or null if not found
  6843. */
  6844. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6845. }
  6846. }
  6847. declare module "babylonjs/Collisions/intersectionInfo" {
  6848. import { Nullable } from "babylonjs/types";
  6849. /**
  6850. * @hidden
  6851. */
  6852. export class IntersectionInfo {
  6853. bu: Nullable<number>;
  6854. bv: Nullable<number>;
  6855. distance: number;
  6856. faceId: number;
  6857. subMeshId: number;
  6858. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6859. }
  6860. }
  6861. declare module "babylonjs/Culling/boundingSphere" {
  6862. import { DeepImmutable } from "babylonjs/types";
  6863. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6864. /**
  6865. * Class used to store bounding sphere information
  6866. */
  6867. export class BoundingSphere {
  6868. /**
  6869. * Gets the center of the bounding sphere in local space
  6870. */
  6871. readonly center: Vector3;
  6872. /**
  6873. * Radius of the bounding sphere in local space
  6874. */
  6875. radius: number;
  6876. /**
  6877. * Gets the center of the bounding sphere in world space
  6878. */
  6879. readonly centerWorld: Vector3;
  6880. /**
  6881. * Radius of the bounding sphere in world space
  6882. */
  6883. radiusWorld: number;
  6884. /**
  6885. * Gets the minimum vector in local space
  6886. */
  6887. readonly minimum: Vector3;
  6888. /**
  6889. * Gets the maximum vector in local space
  6890. */
  6891. readonly maximum: Vector3;
  6892. private _worldMatrix;
  6893. private static readonly TmpVector3;
  6894. /**
  6895. * Creates a new bounding sphere
  6896. * @param min defines the minimum vector (in local space)
  6897. * @param max defines the maximum vector (in local space)
  6898. * @param worldMatrix defines the new world matrix
  6899. */
  6900. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6901. /**
  6902. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6903. * @param min defines the new minimum vector (in local space)
  6904. * @param max defines the new maximum vector (in local space)
  6905. * @param worldMatrix defines the new world matrix
  6906. */
  6907. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6908. /**
  6909. * Scale the current bounding sphere by applying a scale factor
  6910. * @param factor defines the scale factor to apply
  6911. * @returns the current bounding box
  6912. */
  6913. scale(factor: number): BoundingSphere;
  6914. /**
  6915. * Gets the world matrix of the bounding box
  6916. * @returns a matrix
  6917. */
  6918. getWorldMatrix(): DeepImmutable<Matrix>;
  6919. /** @hidden */
  6920. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6921. /**
  6922. * Tests if the bounding sphere is intersecting the frustum planes
  6923. * @param frustumPlanes defines the frustum planes to test
  6924. * @returns true if there is an intersection
  6925. */
  6926. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6927. /**
  6928. * Tests if the bounding sphere center is in between the frustum planes.
  6929. * Used for optimistic fast inclusion.
  6930. * @param frustumPlanes defines the frustum planes to test
  6931. * @returns true if the sphere center is in between the frustum planes
  6932. */
  6933. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6934. /**
  6935. * Tests if a point is inside the bounding sphere
  6936. * @param point defines the point to test
  6937. * @returns true if the point is inside the bounding sphere
  6938. */
  6939. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6940. /**
  6941. * Checks if two sphere intersct
  6942. * @param sphere0 sphere 0
  6943. * @param sphere1 sphere 1
  6944. * @returns true if the speres intersect
  6945. */
  6946. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6947. }
  6948. }
  6949. declare module "babylonjs/Culling/boundingBox" {
  6950. import { DeepImmutable } from "babylonjs/types";
  6951. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6952. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6953. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6954. /**
  6955. * Class used to store bounding box information
  6956. */
  6957. export class BoundingBox implements ICullable {
  6958. /**
  6959. * Gets the 8 vectors representing the bounding box in local space
  6960. */
  6961. readonly vectors: Vector3[];
  6962. /**
  6963. * Gets the center of the bounding box in local space
  6964. */
  6965. readonly center: Vector3;
  6966. /**
  6967. * Gets the center of the bounding box in world space
  6968. */
  6969. readonly centerWorld: Vector3;
  6970. /**
  6971. * Gets the extend size in local space
  6972. */
  6973. readonly extendSize: Vector3;
  6974. /**
  6975. * Gets the extend size in world space
  6976. */
  6977. readonly extendSizeWorld: Vector3;
  6978. /**
  6979. * Gets the OBB (object bounding box) directions
  6980. */
  6981. readonly directions: Vector3[];
  6982. /**
  6983. * Gets the 8 vectors representing the bounding box in world space
  6984. */
  6985. readonly vectorsWorld: Vector3[];
  6986. /**
  6987. * Gets the minimum vector in world space
  6988. */
  6989. readonly minimumWorld: Vector3;
  6990. /**
  6991. * Gets the maximum vector in world space
  6992. */
  6993. readonly maximumWorld: Vector3;
  6994. /**
  6995. * Gets the minimum vector in local space
  6996. */
  6997. readonly minimum: Vector3;
  6998. /**
  6999. * Gets the maximum vector in local space
  7000. */
  7001. readonly maximum: Vector3;
  7002. private _worldMatrix;
  7003. private static readonly TmpVector3;
  7004. /**
  7005. * @hidden
  7006. */
  7007. _tag: number;
  7008. /**
  7009. * Creates a new bounding box
  7010. * @param min defines the minimum vector (in local space)
  7011. * @param max defines the maximum vector (in local space)
  7012. * @param worldMatrix defines the new world matrix
  7013. */
  7014. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7015. /**
  7016. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7017. * @param min defines the new minimum vector (in local space)
  7018. * @param max defines the new maximum vector (in local space)
  7019. * @param worldMatrix defines the new world matrix
  7020. */
  7021. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7022. /**
  7023. * Scale the current bounding box by applying a scale factor
  7024. * @param factor defines the scale factor to apply
  7025. * @returns the current bounding box
  7026. */
  7027. scale(factor: number): BoundingBox;
  7028. /**
  7029. * Gets the world matrix of the bounding box
  7030. * @returns a matrix
  7031. */
  7032. getWorldMatrix(): DeepImmutable<Matrix>;
  7033. /** @hidden */
  7034. _update(world: DeepImmutable<Matrix>): void;
  7035. /**
  7036. * Tests if the bounding box is intersecting the frustum planes
  7037. * @param frustumPlanes defines the frustum planes to test
  7038. * @returns true if there is an intersection
  7039. */
  7040. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7041. /**
  7042. * Tests if the bounding box is entirely inside the frustum planes
  7043. * @param frustumPlanes defines the frustum planes to test
  7044. * @returns true if there is an inclusion
  7045. */
  7046. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7047. /**
  7048. * Tests if a point is inside the bounding box
  7049. * @param point defines the point to test
  7050. * @returns true if the point is inside the bounding box
  7051. */
  7052. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7053. /**
  7054. * Tests if the bounding box intersects with a bounding sphere
  7055. * @param sphere defines the sphere to test
  7056. * @returns true if there is an intersection
  7057. */
  7058. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7059. /**
  7060. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7061. * @param min defines the min vector to use
  7062. * @param max defines the max vector to use
  7063. * @returns true if there is an intersection
  7064. */
  7065. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7066. /**
  7067. * Tests if two bounding boxes are intersections
  7068. * @param box0 defines the first box to test
  7069. * @param box1 defines the second box to test
  7070. * @returns true if there is an intersection
  7071. */
  7072. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7073. /**
  7074. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7075. * @param minPoint defines the minimum vector of the bounding box
  7076. * @param maxPoint defines the maximum vector of the bounding box
  7077. * @param sphereCenter defines the sphere center
  7078. * @param sphereRadius defines the sphere radius
  7079. * @returns true if there is an intersection
  7080. */
  7081. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7082. /**
  7083. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7084. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7085. * @param frustumPlanes defines the frustum planes to test
  7086. * @return true if there is an inclusion
  7087. */
  7088. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7089. /**
  7090. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7091. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7092. * @param frustumPlanes defines the frustum planes to test
  7093. * @return true if there is an intersection
  7094. */
  7095. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7096. }
  7097. }
  7098. declare module "babylonjs/Collisions/collider" {
  7099. import { Nullable, IndicesArray } from "babylonjs/types";
  7100. import { Vector3, Plane } from "babylonjs/Maths/math";
  7101. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7102. /** @hidden */
  7103. export class Collider {
  7104. /** Define if a collision was found */
  7105. collisionFound: boolean;
  7106. /**
  7107. * Define last intersection point in local space
  7108. */
  7109. intersectionPoint: Vector3;
  7110. /**
  7111. * Define last collided mesh
  7112. */
  7113. collidedMesh: Nullable<AbstractMesh>;
  7114. private _collisionPoint;
  7115. private _planeIntersectionPoint;
  7116. private _tempVector;
  7117. private _tempVector2;
  7118. private _tempVector3;
  7119. private _tempVector4;
  7120. private _edge;
  7121. private _baseToVertex;
  7122. private _destinationPoint;
  7123. private _slidePlaneNormal;
  7124. private _displacementVector;
  7125. /** @hidden */
  7126. _radius: Vector3;
  7127. /** @hidden */
  7128. _retry: number;
  7129. private _velocity;
  7130. private _basePoint;
  7131. private _epsilon;
  7132. /** @hidden */
  7133. _velocityWorldLength: number;
  7134. /** @hidden */
  7135. _basePointWorld: Vector3;
  7136. private _velocityWorld;
  7137. private _normalizedVelocity;
  7138. /** @hidden */
  7139. _initialVelocity: Vector3;
  7140. /** @hidden */
  7141. _initialPosition: Vector3;
  7142. private _nearestDistance;
  7143. private _collisionMask;
  7144. collisionMask: number;
  7145. /**
  7146. * Gets the plane normal used to compute the sliding response (in local space)
  7147. */
  7148. readonly slidePlaneNormal: Vector3;
  7149. /** @hidden */
  7150. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7151. /** @hidden */
  7152. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7153. /** @hidden */
  7154. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7155. /** @hidden */
  7156. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7157. /** @hidden */
  7158. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7159. /** @hidden */
  7160. _getResponse(pos: Vector3, vel: Vector3): void;
  7161. }
  7162. }
  7163. declare module "babylonjs/Culling/boundingInfo" {
  7164. import { DeepImmutable } from "babylonjs/types";
  7165. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7166. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7167. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7168. import { Collider } from "babylonjs/Collisions/collider";
  7169. /**
  7170. * Interface for cullable objects
  7171. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7172. */
  7173. export interface ICullable {
  7174. /**
  7175. * Checks if the object or part of the object is in the frustum
  7176. * @param frustumPlanes Camera near/planes
  7177. * @returns true if the object is in frustum otherwise false
  7178. */
  7179. isInFrustum(frustumPlanes: Plane[]): boolean;
  7180. /**
  7181. * Checks if a cullable object (mesh...) is in the camera frustum
  7182. * Unlike isInFrustum this cheks the full bounding box
  7183. * @param frustumPlanes Camera near/planes
  7184. * @returns true if the object is in frustum otherwise false
  7185. */
  7186. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7187. }
  7188. /**
  7189. * Info for a bounding data of a mesh
  7190. */
  7191. export class BoundingInfo implements ICullable {
  7192. /**
  7193. * Bounding box for the mesh
  7194. */
  7195. readonly boundingBox: BoundingBox;
  7196. /**
  7197. * Bounding sphere for the mesh
  7198. */
  7199. readonly boundingSphere: BoundingSphere;
  7200. private _isLocked;
  7201. private static readonly TmpVector3;
  7202. /**
  7203. * Constructs bounding info
  7204. * @param minimum min vector of the bounding box/sphere
  7205. * @param maximum max vector of the bounding box/sphere
  7206. * @param worldMatrix defines the new world matrix
  7207. */
  7208. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7209. /**
  7210. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7211. * @param min defines the new minimum vector (in local space)
  7212. * @param max defines the new maximum vector (in local space)
  7213. * @param worldMatrix defines the new world matrix
  7214. */
  7215. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7216. /**
  7217. * min vector of the bounding box/sphere
  7218. */
  7219. readonly minimum: Vector3;
  7220. /**
  7221. * max vector of the bounding box/sphere
  7222. */
  7223. readonly maximum: Vector3;
  7224. /**
  7225. * If the info is locked and won't be updated to avoid perf overhead
  7226. */
  7227. isLocked: boolean;
  7228. /**
  7229. * Updates the bounding sphere and box
  7230. * @param world world matrix to be used to update
  7231. */
  7232. update(world: DeepImmutable<Matrix>): void;
  7233. /**
  7234. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7235. * @param center New center of the bounding info
  7236. * @param extend New extend of the bounding info
  7237. * @returns the current bounding info
  7238. */
  7239. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7240. /**
  7241. * Scale the current bounding info by applying a scale factor
  7242. * @param factor defines the scale factor to apply
  7243. * @returns the current bounding info
  7244. */
  7245. scale(factor: number): BoundingInfo;
  7246. /**
  7247. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7248. * @param frustumPlanes defines the frustum to test
  7249. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7250. * @returns true if the bounding info is in the frustum planes
  7251. */
  7252. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7253. /**
  7254. * Gets the world distance between the min and max points of the bounding box
  7255. */
  7256. readonly diagonalLength: number;
  7257. /**
  7258. * Checks if a cullable object (mesh...) is in the camera frustum
  7259. * Unlike isInFrustum this cheks the full bounding box
  7260. * @param frustumPlanes Camera near/planes
  7261. * @returns true if the object is in frustum otherwise false
  7262. */
  7263. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7264. /** @hidden */
  7265. _checkCollision(collider: Collider): boolean;
  7266. /**
  7267. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7268. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7269. * @param point the point to check intersection with
  7270. * @returns if the point intersects
  7271. */
  7272. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7273. /**
  7274. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7275. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7276. * @param boundingInfo the bounding info to check intersection with
  7277. * @param precise if the intersection should be done using OBB
  7278. * @returns if the bounding info intersects
  7279. */
  7280. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7281. }
  7282. }
  7283. declare module "babylonjs/Misc/smartArray" {
  7284. /**
  7285. * Defines an array and its length.
  7286. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7287. */
  7288. export interface ISmartArrayLike<T> {
  7289. /**
  7290. * The data of the array.
  7291. */
  7292. data: Array<T>;
  7293. /**
  7294. * The active length of the array.
  7295. */
  7296. length: number;
  7297. }
  7298. /**
  7299. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7300. */
  7301. export class SmartArray<T> implements ISmartArrayLike<T> {
  7302. /**
  7303. * The full set of data from the array.
  7304. */
  7305. data: Array<T>;
  7306. /**
  7307. * The active length of the array.
  7308. */
  7309. length: number;
  7310. protected _id: number;
  7311. /**
  7312. * Instantiates a Smart Array.
  7313. * @param capacity defines the default capacity of the array.
  7314. */
  7315. constructor(capacity: number);
  7316. /**
  7317. * Pushes a value at the end of the active data.
  7318. * @param value defines the object to push in the array.
  7319. */
  7320. push(value: T): void;
  7321. /**
  7322. * Iterates over the active data and apply the lambda to them.
  7323. * @param func defines the action to apply on each value.
  7324. */
  7325. forEach(func: (content: T) => void): void;
  7326. /**
  7327. * Sorts the full sets of data.
  7328. * @param compareFn defines the comparison function to apply.
  7329. */
  7330. sort(compareFn: (a: T, b: T) => number): void;
  7331. /**
  7332. * Resets the active data to an empty array.
  7333. */
  7334. reset(): void;
  7335. /**
  7336. * Releases all the data from the array as well as the array.
  7337. */
  7338. dispose(): void;
  7339. /**
  7340. * Concats the active data with a given array.
  7341. * @param array defines the data to concatenate with.
  7342. */
  7343. concat(array: any): void;
  7344. /**
  7345. * Returns the position of a value in the active data.
  7346. * @param value defines the value to find the index for
  7347. * @returns the index if found in the active data otherwise -1
  7348. */
  7349. indexOf(value: T): number;
  7350. /**
  7351. * Returns whether an element is part of the active data.
  7352. * @param value defines the value to look for
  7353. * @returns true if found in the active data otherwise false
  7354. */
  7355. contains(value: T): boolean;
  7356. private static _GlobalId;
  7357. }
  7358. /**
  7359. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7360. * The data in this array can only be present once
  7361. */
  7362. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7363. private _duplicateId;
  7364. /**
  7365. * Pushes a value at the end of the active data.
  7366. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7367. * @param value defines the object to push in the array.
  7368. */
  7369. push(value: T): void;
  7370. /**
  7371. * Pushes a value at the end of the active data.
  7372. * If the data is already present, it won t be added again
  7373. * @param value defines the object to push in the array.
  7374. * @returns true if added false if it was already present
  7375. */
  7376. pushNoDuplicate(value: T): boolean;
  7377. /**
  7378. * Resets the active data to an empty array.
  7379. */
  7380. reset(): void;
  7381. /**
  7382. * Concats the active data with a given array.
  7383. * This ensures no dupplicate will be present in the result.
  7384. * @param array defines the data to concatenate with.
  7385. */
  7386. concatWithNoDuplicate(array: any): void;
  7387. }
  7388. }
  7389. declare module "babylonjs/Materials/multiMaterial" {
  7390. import { Nullable } from "babylonjs/types";
  7391. import { Scene } from "babylonjs/scene";
  7392. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7393. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  7394. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7395. import { Material } from "babylonjs/Materials/material";
  7396. /**
  7397. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7398. * separate meshes. This can be use to improve performances.
  7399. * @see http://doc.babylonjs.com/how_to/multi_materials
  7400. */
  7401. export class MultiMaterial extends Material {
  7402. private _subMaterials;
  7403. /**
  7404. * Gets or Sets the list of Materials used within the multi material.
  7405. * They need to be ordered according to the submeshes order in the associated mesh
  7406. */
  7407. subMaterials: Nullable<Material>[];
  7408. /**
  7409. * Function used to align with Node.getChildren()
  7410. * @returns the list of Materials used within the multi material
  7411. */
  7412. getChildren(): Nullable<Material>[];
  7413. /**
  7414. * Instantiates a new Multi Material
  7415. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7416. * separate meshes. This can be use to improve performances.
  7417. * @see http://doc.babylonjs.com/how_to/multi_materials
  7418. * @param name Define the name in the scene
  7419. * @param scene Define the scene the material belongs to
  7420. */
  7421. constructor(name: string, scene: Scene);
  7422. private _hookArray;
  7423. /**
  7424. * Get one of the submaterial by its index in the submaterials array
  7425. * @param index The index to look the sub material at
  7426. * @returns The Material if the index has been defined
  7427. */
  7428. getSubMaterial(index: number): Nullable<Material>;
  7429. /**
  7430. * Get the list of active textures for the whole sub materials list.
  7431. * @returns All the textures that will be used during the rendering
  7432. */
  7433. getActiveTextures(): BaseTexture[];
  7434. /**
  7435. * Gets the current class name of the material e.g. "MultiMaterial"
  7436. * Mainly use in serialization.
  7437. * @returns the class name
  7438. */
  7439. getClassName(): string;
  7440. /**
  7441. * Checks if the material is ready to render the requested sub mesh
  7442. * @param mesh Define the mesh the submesh belongs to
  7443. * @param subMesh Define the sub mesh to look readyness for
  7444. * @param useInstances Define whether or not the material is used with instances
  7445. * @returns true if ready, otherwise false
  7446. */
  7447. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7448. /**
  7449. * Clones the current material and its related sub materials
  7450. * @param name Define the name of the newly cloned material
  7451. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7452. * @returns the cloned material
  7453. */
  7454. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7455. /**
  7456. * Serializes the materials into a JSON representation.
  7457. * @returns the JSON representation
  7458. */
  7459. serialize(): any;
  7460. /**
  7461. * Dispose the material and release its associated resources
  7462. * @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)
  7463. * @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)
  7464. * @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)
  7465. */
  7466. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7467. /**
  7468. * Creates a MultiMaterial from parsed MultiMaterial data.
  7469. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7470. * @param scene defines the hosting scene
  7471. * @returns a new MultiMaterial
  7472. */
  7473. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7474. }
  7475. }
  7476. declare module "babylonjs/Loading/sceneLoaderFlags" {
  7477. /**
  7478. * Class used to represent data loading progression
  7479. */
  7480. export class SceneLoaderFlags {
  7481. private static _ForceFullSceneLoadingForIncremental;
  7482. private static _ShowLoadingScreen;
  7483. private static _CleanBoneMatrixWeights;
  7484. private static _loggingLevel;
  7485. /**
  7486. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7487. */
  7488. static ForceFullSceneLoadingForIncremental: boolean;
  7489. /**
  7490. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7491. */
  7492. static ShowLoadingScreen: boolean;
  7493. /**
  7494. * Defines the current logging level (while loading the scene)
  7495. * @ignorenaming
  7496. */
  7497. static loggingLevel: number;
  7498. /**
  7499. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7500. */
  7501. static CleanBoneMatrixWeights: boolean;
  7502. }
  7503. }
  7504. declare module "babylonjs/Meshes/transformNode" {
  7505. import { DeepImmutable } from "babylonjs/types";
  7506. import { Observable } from "babylonjs/Misc/observable";
  7507. import { Nullable } from "babylonjs/types";
  7508. import { Camera } from "babylonjs/Cameras/camera";
  7509. import { Scene } from "babylonjs/scene";
  7510. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  7511. import { Node } from "babylonjs/node";
  7512. import { Bone } from "babylonjs/Bones/bone";
  7513. /**
  7514. * 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.
  7515. * @see https://doc.babylonjs.com/how_to/transformnode
  7516. */
  7517. export class TransformNode extends Node {
  7518. /**
  7519. * Object will not rotate to face the camera
  7520. */
  7521. static BILLBOARDMODE_NONE: number;
  7522. /**
  7523. * Object will rotate to face the camera but only on the x axis
  7524. */
  7525. static BILLBOARDMODE_X: number;
  7526. /**
  7527. * Object will rotate to face the camera but only on the y axis
  7528. */
  7529. static BILLBOARDMODE_Y: number;
  7530. /**
  7531. * Object will rotate to face the camera but only on the z axis
  7532. */
  7533. static BILLBOARDMODE_Z: number;
  7534. /**
  7535. * Object will rotate to face the camera
  7536. */
  7537. static BILLBOARDMODE_ALL: number;
  7538. private _forward;
  7539. private _forwardInverted;
  7540. private _up;
  7541. private _right;
  7542. private _rightInverted;
  7543. private _position;
  7544. private _rotation;
  7545. private _rotationQuaternion;
  7546. protected _scaling: Vector3;
  7547. protected _isDirty: boolean;
  7548. private _transformToBoneReferal;
  7549. /**
  7550. * Set the billboard mode. Default is 0.
  7551. *
  7552. * | Value | Type | Description |
  7553. * | --- | --- | --- |
  7554. * | 0 | BILLBOARDMODE_NONE | |
  7555. * | 1 | BILLBOARDMODE_X | |
  7556. * | 2 | BILLBOARDMODE_Y | |
  7557. * | 4 | BILLBOARDMODE_Z | |
  7558. * | 7 | BILLBOARDMODE_ALL | |
  7559. *
  7560. */
  7561. billboardMode: number;
  7562. /**
  7563. * 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
  7564. */
  7565. scalingDeterminant: number;
  7566. /**
  7567. * Sets the distance of the object to max, often used by skybox
  7568. */
  7569. infiniteDistance: boolean;
  7570. /**
  7571. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7572. * By default the system will update normals to compensate
  7573. */
  7574. ignoreNonUniformScaling: boolean;
  7575. /** @hidden */
  7576. _poseMatrix: Matrix;
  7577. /** @hidden */
  7578. _localMatrix: Matrix;
  7579. private _absolutePosition;
  7580. private _pivotMatrix;
  7581. private _pivotMatrixInverse;
  7582. protected _postMultiplyPivotMatrix: boolean;
  7583. private _tempMatrix;
  7584. private _tempMatrix2;
  7585. protected _isWorldMatrixFrozen: boolean;
  7586. /** @hidden */
  7587. _indexInSceneTransformNodesArray: number;
  7588. /**
  7589. * An event triggered after the world matrix is updated
  7590. */
  7591. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7592. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7593. /**
  7594. * Gets a string identifying the name of the class
  7595. * @returns "TransformNode" string
  7596. */
  7597. getClassName(): string;
  7598. /**
  7599. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7600. */
  7601. position: Vector3;
  7602. /**
  7603. * 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)).
  7604. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7605. */
  7606. rotation: Vector3;
  7607. /**
  7608. * 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)).
  7609. */
  7610. scaling: Vector3;
  7611. /**
  7612. * 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).
  7613. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7614. */
  7615. rotationQuaternion: Nullable<Quaternion>;
  7616. /**
  7617. * The forward direction of that transform in world space.
  7618. */
  7619. readonly forward: Vector3;
  7620. /**
  7621. * The up direction of that transform in world space.
  7622. */
  7623. readonly up: Vector3;
  7624. /**
  7625. * The right direction of that transform in world space.
  7626. */
  7627. readonly right: Vector3;
  7628. /**
  7629. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7630. * @param matrix the matrix to copy the pose from
  7631. * @returns this TransformNode.
  7632. */
  7633. updatePoseMatrix(matrix: Matrix): TransformNode;
  7634. /**
  7635. * Returns the mesh Pose matrix.
  7636. * @returns the pose matrix
  7637. */
  7638. getPoseMatrix(): Matrix;
  7639. /** @hidden */
  7640. _isSynchronized(): boolean;
  7641. /** @hidden */
  7642. _initCache(): void;
  7643. /**
  7644. * Flag the transform node as dirty (Forcing it to update everything)
  7645. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7646. * @returns this transform node
  7647. */
  7648. markAsDirty(property: string): TransformNode;
  7649. /**
  7650. * Returns the current mesh absolute position.
  7651. * Returns a Vector3.
  7652. */
  7653. readonly absolutePosition: Vector3;
  7654. /**
  7655. * Sets a new matrix to apply before all other transformation
  7656. * @param matrix defines the transform matrix
  7657. * @returns the current TransformNode
  7658. */
  7659. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7660. /**
  7661. * Sets a new pivot matrix to the current node
  7662. * @param matrix defines the new pivot matrix to use
  7663. * @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
  7664. * @returns the current TransformNode
  7665. */
  7666. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7667. /**
  7668. * Returns the mesh pivot matrix.
  7669. * Default : Identity.
  7670. * @returns the matrix
  7671. */
  7672. getPivotMatrix(): Matrix;
  7673. /**
  7674. * Prevents the World matrix to be computed any longer.
  7675. * @returns the TransformNode.
  7676. */
  7677. freezeWorldMatrix(): TransformNode;
  7678. /**
  7679. * Allows back the World matrix computation.
  7680. * @returns the TransformNode.
  7681. */
  7682. unfreezeWorldMatrix(): this;
  7683. /**
  7684. * True if the World matrix has been frozen.
  7685. */
  7686. readonly isWorldMatrixFrozen: boolean;
  7687. /**
  7688. * Retuns the mesh absolute position in the World.
  7689. * @returns a Vector3.
  7690. */
  7691. getAbsolutePosition(): Vector3;
  7692. /**
  7693. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7694. * @param absolutePosition the absolute position to set
  7695. * @returns the TransformNode.
  7696. */
  7697. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7698. /**
  7699. * Sets the mesh position in its local space.
  7700. * @param vector3 the position to set in localspace
  7701. * @returns the TransformNode.
  7702. */
  7703. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7704. /**
  7705. * Returns the mesh position in the local space from the current World matrix values.
  7706. * @returns a new Vector3.
  7707. */
  7708. getPositionExpressedInLocalSpace(): Vector3;
  7709. /**
  7710. * Translates the mesh along the passed Vector3 in its local space.
  7711. * @param vector3 the distance to translate in localspace
  7712. * @returns the TransformNode.
  7713. */
  7714. locallyTranslate(vector3: Vector3): TransformNode;
  7715. private static _lookAtVectorCache;
  7716. /**
  7717. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7718. * @param targetPoint the position (must be in same space as current mesh) to look at
  7719. * @param yawCor optional yaw (y-axis) correction in radians
  7720. * @param pitchCor optional pitch (x-axis) correction in radians
  7721. * @param rollCor optional roll (z-axis) correction in radians
  7722. * @param space the choosen space of the target
  7723. * @returns the TransformNode.
  7724. */
  7725. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7726. /**
  7727. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7728. * This Vector3 is expressed in the World space.
  7729. * @param localAxis axis to rotate
  7730. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7731. */
  7732. getDirection(localAxis: Vector3): Vector3;
  7733. /**
  7734. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7735. * localAxis is expressed in the mesh local space.
  7736. * result is computed in the Wordl space from the mesh World matrix.
  7737. * @param localAxis axis to rotate
  7738. * @param result the resulting transformnode
  7739. * @returns this TransformNode.
  7740. */
  7741. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7742. /**
  7743. * Sets this transform node rotation to the given local axis.
  7744. * @param localAxis the axis in local space
  7745. * @param yawCor optional yaw (y-axis) correction in radians
  7746. * @param pitchCor optional pitch (x-axis) correction in radians
  7747. * @param rollCor optional roll (z-axis) correction in radians
  7748. * @returns this TransformNode
  7749. */
  7750. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7751. /**
  7752. * Sets a new pivot point to the current node
  7753. * @param point defines the new pivot point to use
  7754. * @param space defines if the point is in world or local space (local by default)
  7755. * @returns the current TransformNode
  7756. */
  7757. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7758. /**
  7759. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7760. * @returns the pivot point
  7761. */
  7762. getPivotPoint(): Vector3;
  7763. /**
  7764. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7765. * @param result the vector3 to store the result
  7766. * @returns this TransformNode.
  7767. */
  7768. getPivotPointToRef(result: Vector3): TransformNode;
  7769. /**
  7770. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7771. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7772. */
  7773. getAbsolutePivotPoint(): Vector3;
  7774. /**
  7775. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7776. * @param result vector3 to store the result
  7777. * @returns this TransformNode.
  7778. */
  7779. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7780. /**
  7781. * Defines the passed node as the parent of the current node.
  7782. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7783. * @param node the node ot set as the parent
  7784. * @returns this TransformNode.
  7785. */
  7786. setParent(node: Nullable<Node>): TransformNode;
  7787. private _nonUniformScaling;
  7788. /**
  7789. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7790. */
  7791. readonly nonUniformScaling: boolean;
  7792. /** @hidden */
  7793. _updateNonUniformScalingState(value: boolean): boolean;
  7794. /**
  7795. * Attach the current TransformNode to another TransformNode associated with a bone
  7796. * @param bone Bone affecting the TransformNode
  7797. * @param affectedTransformNode TransformNode associated with the bone
  7798. * @returns this object
  7799. */
  7800. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7801. /**
  7802. * Detach the transform node if its associated with a bone
  7803. * @returns this object
  7804. */
  7805. detachFromBone(): TransformNode;
  7806. private static _rotationAxisCache;
  7807. /**
  7808. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7809. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7810. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7811. * The passed axis is also normalized.
  7812. * @param axis the axis to rotate around
  7813. * @param amount the amount to rotate in radians
  7814. * @param space Space to rotate in (Default: local)
  7815. * @returns the TransformNode.
  7816. */
  7817. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7818. /**
  7819. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7820. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7821. * The passed axis is also normalized. .
  7822. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7823. * @param point the point to rotate around
  7824. * @param axis the axis to rotate around
  7825. * @param amount the amount to rotate in radians
  7826. * @returns the TransformNode
  7827. */
  7828. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7829. /**
  7830. * Translates the mesh along the axis vector for the passed distance in the given space.
  7831. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7832. * @param axis the axis to translate in
  7833. * @param distance the distance to translate
  7834. * @param space Space to rotate in (Default: local)
  7835. * @returns the TransformNode.
  7836. */
  7837. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7838. /**
  7839. * Adds a rotation step to the mesh current rotation.
  7840. * x, y, z are Euler angles expressed in radians.
  7841. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7842. * This means this rotation is made in the mesh local space only.
  7843. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7844. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7845. * ```javascript
  7846. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7847. * ```
  7848. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7849. * 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.
  7850. * @param x Rotation to add
  7851. * @param y Rotation to add
  7852. * @param z Rotation to add
  7853. * @returns the TransformNode.
  7854. */
  7855. addRotation(x: number, y: number, z: number): TransformNode;
  7856. /**
  7857. * Computes the world matrix of the node
  7858. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7859. * @returns the world matrix
  7860. */
  7861. computeWorldMatrix(force?: boolean): Matrix;
  7862. protected _afterComputeWorldMatrix(): void;
  7863. /**
  7864. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7865. * @param func callback function to add
  7866. *
  7867. * @returns the TransformNode.
  7868. */
  7869. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7870. /**
  7871. * Removes a registered callback function.
  7872. * @param func callback function to remove
  7873. * @returns the TransformNode.
  7874. */
  7875. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7876. /**
  7877. * Gets the position of the current mesh in camera space
  7878. * @param camera defines the camera to use
  7879. * @returns a position
  7880. */
  7881. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7882. /**
  7883. * Returns the distance from the mesh to the active camera
  7884. * @param camera defines the camera to use
  7885. * @returns the distance
  7886. */
  7887. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7888. /**
  7889. * Clone the current transform node
  7890. * @param name Name of the new clone
  7891. * @param newParent New parent for the clone
  7892. * @param doNotCloneChildren Do not clone children hierarchy
  7893. * @returns the new transform node
  7894. */
  7895. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7896. /**
  7897. * Serializes the objects information.
  7898. * @param currentSerializationObject defines the object to serialize in
  7899. * @returns the serialized object
  7900. */
  7901. serialize(currentSerializationObject?: any): any;
  7902. /**
  7903. * Returns a new TransformNode object parsed from the source provided.
  7904. * @param parsedTransformNode is the source.
  7905. * @param scene the scne the object belongs to
  7906. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7907. * @returns a new TransformNode object parsed from the source provided.
  7908. */
  7909. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7910. /**
  7911. * Get all child-transformNodes of this node
  7912. * @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
  7913. * @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
  7914. * @returns an array of TransformNode
  7915. */
  7916. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7917. /**
  7918. * Releases resources associated with this transform node.
  7919. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7920. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7921. */
  7922. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7923. }
  7924. }
  7925. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7926. /**
  7927. * Class used to override all child animations of a given target
  7928. */
  7929. export class AnimationPropertiesOverride {
  7930. /**
  7931. * Gets or sets a value indicating if animation blending must be used
  7932. */
  7933. enableBlending: boolean;
  7934. /**
  7935. * Gets or sets the blending speed to use when enableBlending is true
  7936. */
  7937. blendingSpeed: number;
  7938. /**
  7939. * Gets or sets the default loop mode to use
  7940. */
  7941. loopMode: number;
  7942. }
  7943. }
  7944. declare module "babylonjs/Bones/bone" {
  7945. import { Skeleton } from "babylonjs/Bones/skeleton";
  7946. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  7947. import { Nullable } from "babylonjs/types";
  7948. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7949. import { TransformNode } from "babylonjs/Meshes/transformNode";
  7950. import { Node } from "babylonjs/node";
  7951. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  7952. /**
  7953. * Class used to store bone information
  7954. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7955. */
  7956. export class Bone extends Node {
  7957. /**
  7958. * defines the bone name
  7959. */
  7960. name: string;
  7961. private static _tmpVecs;
  7962. private static _tmpQuat;
  7963. private static _tmpMats;
  7964. /**
  7965. * Gets the list of child bones
  7966. */
  7967. children: Bone[];
  7968. /** Gets the animations associated with this bone */
  7969. animations: import("babylonjs/Animations/animation").Animation[];
  7970. /**
  7971. * Gets or sets bone length
  7972. */
  7973. length: number;
  7974. /**
  7975. * @hidden Internal only
  7976. * Set this value to map this bone to a different index in the transform matrices
  7977. * Set this value to -1 to exclude the bone from the transform matrices
  7978. */
  7979. _index: Nullable<number>;
  7980. private _skeleton;
  7981. private _localMatrix;
  7982. private _restPose;
  7983. private _baseMatrix;
  7984. private _absoluteTransform;
  7985. private _invertedAbsoluteTransform;
  7986. private _parent;
  7987. private _scalingDeterminant;
  7988. private _worldTransform;
  7989. private _localScaling;
  7990. private _localRotation;
  7991. private _localPosition;
  7992. private _needToDecompose;
  7993. private _needToCompose;
  7994. /** @hidden */
  7995. _linkedTransformNode: Nullable<TransformNode>;
  7996. /** @hidden */
  7997. /** @hidden */
  7998. _matrix: Matrix;
  7999. /**
  8000. * Create a new bone
  8001. * @param name defines the bone name
  8002. * @param skeleton defines the parent skeleton
  8003. * @param parentBone defines the parent (can be null if the bone is the root)
  8004. * @param localMatrix defines the local matrix
  8005. * @param restPose defines the rest pose matrix
  8006. * @param baseMatrix defines the base matrix
  8007. * @param index defines index of the bone in the hiearchy
  8008. */
  8009. constructor(
  8010. /**
  8011. * defines the bone name
  8012. */
  8013. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8014. /**
  8015. * Gets the current object class name.
  8016. * @return the class name
  8017. */
  8018. getClassName(): string;
  8019. /**
  8020. * Gets the parent skeleton
  8021. * @returns a skeleton
  8022. */
  8023. getSkeleton(): Skeleton;
  8024. /**
  8025. * Gets parent bone
  8026. * @returns a bone or null if the bone is the root of the bone hierarchy
  8027. */
  8028. getParent(): Nullable<Bone>;
  8029. /**
  8030. * Returns an array containing the root bones
  8031. * @returns an array containing the root bones
  8032. */
  8033. getChildren(): Array<Bone>;
  8034. /**
  8035. * Sets the parent bone
  8036. * @param parent defines the parent (can be null if the bone is the root)
  8037. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8038. */
  8039. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8040. /**
  8041. * Gets the local matrix
  8042. * @returns a matrix
  8043. */
  8044. getLocalMatrix(): Matrix;
  8045. /**
  8046. * Gets the base matrix (initial matrix which remains unchanged)
  8047. * @returns a matrix
  8048. */
  8049. getBaseMatrix(): Matrix;
  8050. /**
  8051. * Gets the rest pose matrix
  8052. * @returns a matrix
  8053. */
  8054. getRestPose(): Matrix;
  8055. /**
  8056. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8057. */
  8058. getWorldMatrix(): Matrix;
  8059. /**
  8060. * Sets the local matrix to rest pose matrix
  8061. */
  8062. returnToRest(): void;
  8063. /**
  8064. * Gets the inverse of the absolute transform matrix.
  8065. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8066. * @returns a matrix
  8067. */
  8068. getInvertedAbsoluteTransform(): Matrix;
  8069. /**
  8070. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8071. * @returns a matrix
  8072. */
  8073. getAbsoluteTransform(): Matrix;
  8074. /**
  8075. * Links with the given transform node.
  8076. * The local matrix of this bone is copied from the transform node every frame.
  8077. * @param transformNode defines the transform node to link to
  8078. */
  8079. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8080. /** Gets or sets current position (in local space) */
  8081. position: Vector3;
  8082. /** Gets or sets current rotation (in local space) */
  8083. rotation: Vector3;
  8084. /** Gets or sets current rotation quaternion (in local space) */
  8085. rotationQuaternion: Quaternion;
  8086. /** Gets or sets current scaling (in local space) */
  8087. scaling: Vector3;
  8088. /**
  8089. * Gets the animation properties override
  8090. */
  8091. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8092. private _decompose;
  8093. private _compose;
  8094. /**
  8095. * Update the base and local matrices
  8096. * @param matrix defines the new base or local matrix
  8097. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8098. * @param updateLocalMatrix defines if the local matrix should be updated
  8099. */
  8100. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8101. /** @hidden */
  8102. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8103. /**
  8104. * Flag the bone as dirty (Forcing it to update everything)
  8105. */
  8106. markAsDirty(): void;
  8107. private _markAsDirtyAndCompose;
  8108. private _markAsDirtyAndDecompose;
  8109. /**
  8110. * Translate the bone in local or world space
  8111. * @param vec The amount to translate the bone
  8112. * @param space The space that the translation is in
  8113. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8114. */
  8115. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8116. /**
  8117. * Set the postion of the bone in local or world space
  8118. * @param position The position to set the bone
  8119. * @param space The space that the position is in
  8120. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8121. */
  8122. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8123. /**
  8124. * Set the absolute position of the bone (world space)
  8125. * @param position The position to set the bone
  8126. * @param mesh The mesh that this bone is attached to
  8127. */
  8128. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8129. /**
  8130. * Scale the bone on the x, y and z axes (in local space)
  8131. * @param x The amount to scale the bone on the x axis
  8132. * @param y The amount to scale the bone on the y axis
  8133. * @param z The amount to scale the bone on the z axis
  8134. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8135. */
  8136. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8137. /**
  8138. * Set the bone scaling in local space
  8139. * @param scale defines the scaling vector
  8140. */
  8141. setScale(scale: Vector3): void;
  8142. /**
  8143. * Gets the current scaling in local space
  8144. * @returns the current scaling vector
  8145. */
  8146. getScale(): Vector3;
  8147. /**
  8148. * Gets the current scaling in local space and stores it in a target vector
  8149. * @param result defines the target vector
  8150. */
  8151. getScaleToRef(result: Vector3): void;
  8152. /**
  8153. * Set the yaw, pitch, and roll of the bone in local or world space
  8154. * @param yaw The rotation of the bone on the y axis
  8155. * @param pitch The rotation of the bone on the x axis
  8156. * @param roll The rotation of the bone on the z axis
  8157. * @param space The space that the axes of rotation are in
  8158. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8159. */
  8160. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8161. /**
  8162. * Add a rotation to the bone on an axis in local or world space
  8163. * @param axis The axis to rotate the bone on
  8164. * @param amount The amount to rotate the bone
  8165. * @param space The space that the axis is in
  8166. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8167. */
  8168. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8169. /**
  8170. * Set the rotation of the bone to a particular axis angle in local or world space
  8171. * @param axis The axis to rotate the bone on
  8172. * @param angle The angle that the bone should be rotated to
  8173. * @param space The space that the axis is in
  8174. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8175. */
  8176. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8177. /**
  8178. * Set the euler rotation of the bone in local of world space
  8179. * @param rotation The euler rotation that the bone should be set to
  8180. * @param space The space that the rotation is in
  8181. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8182. */
  8183. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8184. /**
  8185. * Set the quaternion rotation of the bone in local of world space
  8186. * @param quat The quaternion rotation that the bone should be set to
  8187. * @param space The space that the rotation is in
  8188. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8189. */
  8190. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8191. /**
  8192. * Set the rotation matrix of the bone in local of world space
  8193. * @param rotMat The rotation matrix that the bone should be set to
  8194. * @param space The space that the rotation is in
  8195. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8196. */
  8197. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8198. private _rotateWithMatrix;
  8199. private _getNegativeRotationToRef;
  8200. /**
  8201. * Get the position of the bone in local or world space
  8202. * @param space The space that the returned position is in
  8203. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8204. * @returns The position of the bone
  8205. */
  8206. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8207. /**
  8208. * Copy the position of the bone to a vector3 in local or world space
  8209. * @param space The space that the returned position is in
  8210. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8211. * @param result The vector3 to copy the position to
  8212. */
  8213. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8214. /**
  8215. * Get the absolute position of the bone (world space)
  8216. * @param mesh The mesh that this bone is attached to
  8217. * @returns The absolute position of the bone
  8218. */
  8219. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8220. /**
  8221. * Copy the absolute position of the bone (world space) to the result param
  8222. * @param mesh The mesh that this bone is attached to
  8223. * @param result The vector3 to copy the absolute position to
  8224. */
  8225. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8226. /**
  8227. * Compute the absolute transforms of this bone and its children
  8228. */
  8229. computeAbsoluteTransforms(): void;
  8230. /**
  8231. * Get the world direction from an axis that is in the local space of the bone
  8232. * @param localAxis The local direction that is used to compute the world direction
  8233. * @param mesh The mesh that this bone is attached to
  8234. * @returns The world direction
  8235. */
  8236. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8237. /**
  8238. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8239. * @param localAxis The local direction that is used to compute the world direction
  8240. * @param mesh The mesh that this bone is attached to
  8241. * @param result The vector3 that the world direction will be copied to
  8242. */
  8243. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8244. /**
  8245. * Get the euler rotation of the bone in local or world space
  8246. * @param space The space that the rotation should be in
  8247. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8248. * @returns The euler rotation
  8249. */
  8250. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8251. /**
  8252. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8253. * @param space The space that the rotation should be in
  8254. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8255. * @param result The vector3 that the rotation should be copied to
  8256. */
  8257. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8258. /**
  8259. * Get the quaternion rotation of the bone in either local or world space
  8260. * @param space The space that the rotation should be in
  8261. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8262. * @returns The quaternion rotation
  8263. */
  8264. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8265. /**
  8266. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8267. * @param space The space that the rotation should be in
  8268. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8269. * @param result The quaternion that the rotation should be copied to
  8270. */
  8271. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8272. /**
  8273. * Get the rotation matrix of the bone in local or world space
  8274. * @param space The space that the rotation should be in
  8275. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8276. * @returns The rotation matrix
  8277. */
  8278. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8279. /**
  8280. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8281. * @param space The space that the rotation should be in
  8282. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8283. * @param result The quaternion that the rotation should be copied to
  8284. */
  8285. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8286. /**
  8287. * Get the world position of a point that is in the local space of the bone
  8288. * @param position The local position
  8289. * @param mesh The mesh that this bone is attached to
  8290. * @returns The world position
  8291. */
  8292. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8293. /**
  8294. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8295. * @param position The local position
  8296. * @param mesh The mesh that this bone is attached to
  8297. * @param result The vector3 that the world position should be copied to
  8298. */
  8299. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8300. /**
  8301. * Get the local position of a point that is in world space
  8302. * @param position The world position
  8303. * @param mesh The mesh that this bone is attached to
  8304. * @returns The local position
  8305. */
  8306. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8307. /**
  8308. * Get the local position of a point that is in world space and copy it to the result param
  8309. * @param position The world position
  8310. * @param mesh The mesh that this bone is attached to
  8311. * @param result The vector3 that the local position should be copied to
  8312. */
  8313. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8314. }
  8315. }
  8316. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8317. import { Nullable } from "babylonjs/types";
  8318. import { Scene } from "babylonjs/scene";
  8319. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8320. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8321. /**
  8322. * Class for creating a cube texture
  8323. */
  8324. export class CubeTexture extends BaseTexture {
  8325. private _delayedOnLoad;
  8326. /**
  8327. * The url of the texture
  8328. */
  8329. url: string;
  8330. /**
  8331. * Gets or sets the center of the bounding box associated with the cube texture.
  8332. * It must define where the camera used to render the texture was set
  8333. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8334. */
  8335. boundingBoxPosition: Vector3;
  8336. private _boundingBoxSize;
  8337. /**
  8338. * Gets or sets the size of the bounding box associated with the cube texture
  8339. * When defined, the cubemap will switch to local mode
  8340. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8341. * @example https://www.babylonjs-playground.com/#RNASML
  8342. */
  8343. /**
  8344. * Returns the bounding box size
  8345. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8346. */
  8347. boundingBoxSize: Vector3;
  8348. protected _rotationY: number;
  8349. /**
  8350. * Sets texture matrix rotation angle around Y axis in radians.
  8351. */
  8352. /**
  8353. * Gets texture matrix rotation angle around Y axis radians.
  8354. */
  8355. rotationY: number;
  8356. /**
  8357. * Are mip maps generated for this texture or not.
  8358. */
  8359. readonly noMipmap: boolean;
  8360. private _noMipmap;
  8361. private _files;
  8362. private _extensions;
  8363. private _textureMatrix;
  8364. private _format;
  8365. private _createPolynomials;
  8366. /** @hidden */
  8367. _prefiltered: boolean;
  8368. /**
  8369. * Creates a cube texture from an array of image urls
  8370. * @param files defines an array of image urls
  8371. * @param scene defines the hosting scene
  8372. * @param noMipmap specifies if mip maps are not used
  8373. * @returns a cube texture
  8374. */
  8375. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8376. /**
  8377. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8378. * @param url defines the url of the prefiltered texture
  8379. * @param scene defines the scene the texture is attached to
  8380. * @param forcedExtension defines the extension of the file if different from the url
  8381. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8382. * @return the prefiltered texture
  8383. */
  8384. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8385. /**
  8386. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8387. * as prefiltered data.
  8388. * @param rootUrl defines the url of the texture or the root name of the six images
  8389. * @param scene defines the scene the texture is attached to
  8390. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8391. * @param noMipmap defines if mipmaps should be created or not
  8392. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8393. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8394. * @param onError defines a callback triggered in case of error during load
  8395. * @param format defines the internal format to use for the texture once loaded
  8396. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8397. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8398. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8399. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8400. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8401. * @return the cube texture
  8402. */
  8403. 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);
  8404. /**
  8405. * Get the current class name of the texture useful for serialization or dynamic coding.
  8406. * @returns "CubeTexture"
  8407. */
  8408. getClassName(): string;
  8409. /**
  8410. * Update the url (and optional buffer) of this texture if url was null during construction.
  8411. * @param url the url of the texture
  8412. * @param forcedExtension defines the extension to use
  8413. * @param onLoad callback called when the texture is loaded (defaults to null)
  8414. */
  8415. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8416. /**
  8417. * Delays loading of the cube texture
  8418. * @param forcedExtension defines the extension to use
  8419. */
  8420. delayLoad(forcedExtension?: string): void;
  8421. /**
  8422. * Returns the reflection texture matrix
  8423. * @returns the reflection texture matrix
  8424. */
  8425. getReflectionTextureMatrix(): Matrix;
  8426. /**
  8427. * Sets the reflection texture matrix
  8428. * @param value Reflection texture matrix
  8429. */
  8430. setReflectionTextureMatrix(value: Matrix): void;
  8431. /**
  8432. * Parses text to create a cube texture
  8433. * @param parsedTexture define the serialized text to read from
  8434. * @param scene defines the hosting scene
  8435. * @param rootUrl defines the root url of the cube texture
  8436. * @returns a cube texture
  8437. */
  8438. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8439. /**
  8440. * Makes a clone, or deep copy, of the cube texture
  8441. * @returns a new cube texture
  8442. */
  8443. clone(): CubeTexture;
  8444. }
  8445. }
  8446. declare module "babylonjs/Shaders/postprocess.vertex" {
  8447. /** @hidden */
  8448. export var postprocessVertexShader: {
  8449. name: string;
  8450. shader: string;
  8451. };
  8452. }
  8453. declare module "babylonjs/Cameras/targetCamera" {
  8454. import { Nullable } from "babylonjs/types";
  8455. import { Camera } from "babylonjs/Cameras/camera";
  8456. import { Scene } from "babylonjs/scene";
  8457. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8458. /**
  8459. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8460. * This is the base of the follow, arc rotate cameras and Free camera
  8461. * @see http://doc.babylonjs.com/features/cameras
  8462. */
  8463. export class TargetCamera extends Camera {
  8464. private static _RigCamTransformMatrix;
  8465. private static _TargetTransformMatrix;
  8466. private static _TargetFocalPoint;
  8467. /**
  8468. * Define the current direction the camera is moving to
  8469. */
  8470. cameraDirection: Vector3;
  8471. /**
  8472. * Define the current rotation the camera is rotating to
  8473. */
  8474. cameraRotation: Vector2;
  8475. /**
  8476. * When set, the up vector of the camera will be updated by the rotation of the camera
  8477. */
  8478. updateUpVectorFromRotation: boolean;
  8479. private _tmpQuaternion;
  8480. /**
  8481. * Define the current rotation of the camera
  8482. */
  8483. rotation: Vector3;
  8484. /**
  8485. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8486. */
  8487. rotationQuaternion: Quaternion;
  8488. /**
  8489. * Define the current speed of the camera
  8490. */
  8491. speed: number;
  8492. /**
  8493. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8494. * around all axis.
  8495. */
  8496. noRotationConstraint: boolean;
  8497. /**
  8498. * Define the current target of the camera as an object or a position.
  8499. */
  8500. lockedTarget: any;
  8501. /** @hidden */
  8502. _currentTarget: Vector3;
  8503. /** @hidden */
  8504. _initialFocalDistance: number;
  8505. /** @hidden */
  8506. _viewMatrix: Matrix;
  8507. /** @hidden */
  8508. _camMatrix: Matrix;
  8509. /** @hidden */
  8510. _cameraTransformMatrix: Matrix;
  8511. /** @hidden */
  8512. _cameraRotationMatrix: Matrix;
  8513. /** @hidden */
  8514. _referencePoint: Vector3;
  8515. /** @hidden */
  8516. _transformedReferencePoint: Vector3;
  8517. protected _globalCurrentTarget: Vector3;
  8518. protected _globalCurrentUpVector: Vector3;
  8519. /** @hidden */
  8520. _reset: () => void;
  8521. private _defaultUp;
  8522. /**
  8523. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8524. * This is the base of the follow, arc rotate cameras and Free camera
  8525. * @see http://doc.babylonjs.com/features/cameras
  8526. * @param name Defines the name of the camera in the scene
  8527. * @param position Defines the start position of the camera in the scene
  8528. * @param scene Defines the scene the camera belongs to
  8529. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8530. */
  8531. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8532. /**
  8533. * Gets the position in front of the camera at a given distance.
  8534. * @param distance The distance from the camera we want the position to be
  8535. * @returns the position
  8536. */
  8537. getFrontPosition(distance: number): Vector3;
  8538. /** @hidden */
  8539. _getLockedTargetPosition(): Nullable<Vector3>;
  8540. private _storedPosition;
  8541. private _storedRotation;
  8542. private _storedRotationQuaternion;
  8543. /**
  8544. * Store current camera state of the camera (fov, position, rotation, etc..)
  8545. * @returns the camera
  8546. */
  8547. storeState(): Camera;
  8548. /**
  8549. * Restored camera state. You must call storeState() first
  8550. * @returns whether it was successful or not
  8551. * @hidden
  8552. */
  8553. _restoreStateValues(): boolean;
  8554. /** @hidden */
  8555. _initCache(): void;
  8556. /** @hidden */
  8557. _updateCache(ignoreParentClass?: boolean): void;
  8558. /** @hidden */
  8559. _isSynchronizedViewMatrix(): boolean;
  8560. /** @hidden */
  8561. _computeLocalCameraSpeed(): number;
  8562. /**
  8563. * Defines the target the camera should look at.
  8564. * This will automatically adapt alpha beta and radius to fit within the new target.
  8565. * @param target Defines the new target as a Vector or a mesh
  8566. */
  8567. setTarget(target: Vector3): void;
  8568. /**
  8569. * Return the current target position of the camera. This value is expressed in local space.
  8570. * @returns the target position
  8571. */
  8572. getTarget(): Vector3;
  8573. /** @hidden */
  8574. _decideIfNeedsToMove(): boolean;
  8575. /** @hidden */
  8576. _updatePosition(): void;
  8577. /** @hidden */
  8578. _checkInputs(): void;
  8579. protected _updateCameraRotationMatrix(): void;
  8580. /**
  8581. * 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)
  8582. * @returns the current camera
  8583. */
  8584. private _rotateUpVectorWithCameraRotationMatrix;
  8585. private _cachedRotationZ;
  8586. private _cachedQuaternionRotationZ;
  8587. /** @hidden */
  8588. _getViewMatrix(): Matrix;
  8589. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8590. /**
  8591. * @hidden
  8592. */
  8593. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8594. /**
  8595. * @hidden
  8596. */
  8597. _updateRigCameras(): void;
  8598. private _getRigCamPositionAndTarget;
  8599. /**
  8600. * Gets the current object class name.
  8601. * @return the class name
  8602. */
  8603. getClassName(): string;
  8604. }
  8605. }
  8606. declare module "babylonjs/Cameras/cameraInputsManager" {
  8607. import { Nullable } from "babylonjs/types";
  8608. import { Camera } from "babylonjs/Cameras/camera";
  8609. /**
  8610. * @ignore
  8611. * This is a list of all the different input types that are available in the application.
  8612. * Fo instance: ArcRotateCameraGamepadInput...
  8613. */
  8614. export var CameraInputTypes: {};
  8615. /**
  8616. * This is the contract to implement in order to create a new input class.
  8617. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8618. */
  8619. export interface ICameraInput<TCamera extends Camera> {
  8620. /**
  8621. * Defines the camera the input is attached to.
  8622. */
  8623. camera: Nullable<TCamera>;
  8624. /**
  8625. * Gets the class name of the current intput.
  8626. * @returns the class name
  8627. */
  8628. getClassName(): string;
  8629. /**
  8630. * Get the friendly name associated with the input class.
  8631. * @returns the input friendly name
  8632. */
  8633. getSimpleName(): string;
  8634. /**
  8635. * Attach the input controls to a specific dom element to get the input from.
  8636. * @param element Defines the element the controls should be listened from
  8637. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8638. */
  8639. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8640. /**
  8641. * Detach the current controls from the specified dom element.
  8642. * @param element Defines the element to stop listening the inputs from
  8643. */
  8644. detachControl(element: Nullable<HTMLElement>): void;
  8645. /**
  8646. * Update the current camera state depending on the inputs that have been used this frame.
  8647. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8648. */
  8649. checkInputs?: () => void;
  8650. }
  8651. /**
  8652. * Represents a map of input types to input instance or input index to input instance.
  8653. */
  8654. export interface CameraInputsMap<TCamera extends Camera> {
  8655. /**
  8656. * Accessor to the input by input type.
  8657. */
  8658. [name: string]: ICameraInput<TCamera>;
  8659. /**
  8660. * Accessor to the input by input index.
  8661. */
  8662. [idx: number]: ICameraInput<TCamera>;
  8663. }
  8664. /**
  8665. * This represents the input manager used within a camera.
  8666. * It helps dealing with all the different kind of input attached to a camera.
  8667. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8668. */
  8669. export class CameraInputsManager<TCamera extends Camera> {
  8670. /**
  8671. * Defines the list of inputs attahed to the camera.
  8672. */
  8673. attached: CameraInputsMap<TCamera>;
  8674. /**
  8675. * Defines the dom element the camera is collecting inputs from.
  8676. * This is null if the controls have not been attached.
  8677. */
  8678. attachedElement: Nullable<HTMLElement>;
  8679. /**
  8680. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8681. */
  8682. noPreventDefault: boolean;
  8683. /**
  8684. * Defined the camera the input manager belongs to.
  8685. */
  8686. camera: TCamera;
  8687. /**
  8688. * Update the current camera state depending on the inputs that have been used this frame.
  8689. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8690. */
  8691. checkInputs: () => void;
  8692. /**
  8693. * Instantiate a new Camera Input Manager.
  8694. * @param camera Defines the camera the input manager blongs to
  8695. */
  8696. constructor(camera: TCamera);
  8697. /**
  8698. * Add an input method to a camera
  8699. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8700. * @param input camera input method
  8701. */
  8702. add(input: ICameraInput<TCamera>): void;
  8703. /**
  8704. * Remove a specific input method from a camera
  8705. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8706. * @param inputToRemove camera input method
  8707. */
  8708. remove(inputToRemove: ICameraInput<TCamera>): void;
  8709. /**
  8710. * Remove a specific input type from a camera
  8711. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8712. * @param inputType the type of the input to remove
  8713. */
  8714. removeByType(inputType: string): void;
  8715. private _addCheckInputs;
  8716. /**
  8717. * Attach the input controls to the currently attached dom element to listen the events from.
  8718. * @param input Defines the input to attach
  8719. */
  8720. attachInput(input: ICameraInput<TCamera>): void;
  8721. /**
  8722. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8723. * @param element Defines the dom element to collect the events from
  8724. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8725. */
  8726. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8727. /**
  8728. * Detach the current manager inputs controls from a specific dom element.
  8729. * @param element Defines the dom element to collect the events from
  8730. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8731. */
  8732. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8733. /**
  8734. * Rebuild the dynamic inputCheck function from the current list of
  8735. * defined inputs in the manager.
  8736. */
  8737. rebuildInputCheck(): void;
  8738. /**
  8739. * Remove all attached input methods from a camera
  8740. */
  8741. clear(): void;
  8742. /**
  8743. * Serialize the current input manager attached to a camera.
  8744. * This ensures than once parsed,
  8745. * the input associated to the camera will be identical to the current ones
  8746. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8747. */
  8748. serialize(serializedCamera: any): void;
  8749. /**
  8750. * Parses an input manager serialized JSON to restore the previous list of inputs
  8751. * and states associated to a camera.
  8752. * @param parsedCamera Defines the JSON to parse
  8753. */
  8754. parse(parsedCamera: any): void;
  8755. }
  8756. }
  8757. declare module "babylonjs/Events/keyboardEvents" {
  8758. /**
  8759. * Gather the list of keyboard event types as constants.
  8760. */
  8761. export class KeyboardEventTypes {
  8762. /**
  8763. * The keydown event is fired when a key becomes active (pressed).
  8764. */
  8765. static readonly KEYDOWN: number;
  8766. /**
  8767. * The keyup event is fired when a key has been released.
  8768. */
  8769. static readonly KEYUP: number;
  8770. }
  8771. /**
  8772. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8773. */
  8774. export class KeyboardInfo {
  8775. /**
  8776. * Defines the type of event (KeyboardEventTypes)
  8777. */
  8778. type: number;
  8779. /**
  8780. * Defines the related dom event
  8781. */
  8782. event: KeyboardEvent;
  8783. /**
  8784. * Instantiates a new keyboard info.
  8785. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8786. * @param type Defines the type of event (KeyboardEventTypes)
  8787. * @param event Defines the related dom event
  8788. */
  8789. constructor(
  8790. /**
  8791. * Defines the type of event (KeyboardEventTypes)
  8792. */
  8793. type: number,
  8794. /**
  8795. * Defines the related dom event
  8796. */
  8797. event: KeyboardEvent);
  8798. }
  8799. /**
  8800. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8801. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8802. */
  8803. export class KeyboardInfoPre extends KeyboardInfo {
  8804. /**
  8805. * Defines the type of event (KeyboardEventTypes)
  8806. */
  8807. type: number;
  8808. /**
  8809. * Defines the related dom event
  8810. */
  8811. event: KeyboardEvent;
  8812. /**
  8813. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8814. */
  8815. skipOnPointerObservable: boolean;
  8816. /**
  8817. * Instantiates a new keyboard pre info.
  8818. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8819. * @param type Defines the type of event (KeyboardEventTypes)
  8820. * @param event Defines the related dom event
  8821. */
  8822. constructor(
  8823. /**
  8824. * Defines the type of event (KeyboardEventTypes)
  8825. */
  8826. type: number,
  8827. /**
  8828. * Defines the related dom event
  8829. */
  8830. event: KeyboardEvent);
  8831. }
  8832. }
  8833. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8834. import { Nullable } from "babylonjs/types";
  8835. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8836. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8837. /**
  8838. * Manage the keyboard inputs to control the movement of a free camera.
  8839. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8840. */
  8841. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8842. /**
  8843. * Defines the camera the input is attached to.
  8844. */
  8845. camera: FreeCamera;
  8846. /**
  8847. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8848. */
  8849. keysUp: number[];
  8850. /**
  8851. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8852. */
  8853. keysDown: number[];
  8854. /**
  8855. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8856. */
  8857. keysLeft: number[];
  8858. /**
  8859. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8860. */
  8861. keysRight: number[];
  8862. private _keys;
  8863. private _onCanvasBlurObserver;
  8864. private _onKeyboardObserver;
  8865. private _engine;
  8866. private _scene;
  8867. /**
  8868. * Attach the input controls to a specific dom element to get the input from.
  8869. * @param element Defines the element the controls should be listened from
  8870. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8871. */
  8872. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8873. /**
  8874. * Detach the current controls from the specified dom element.
  8875. * @param element Defines the element to stop listening the inputs from
  8876. */
  8877. detachControl(element: Nullable<HTMLElement>): void;
  8878. /**
  8879. * Update the current camera state depending on the inputs that have been used this frame.
  8880. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8881. */
  8882. checkInputs(): void;
  8883. /**
  8884. * Gets the class name of the current intput.
  8885. * @returns the class name
  8886. */
  8887. getClassName(): string;
  8888. /** @hidden */
  8889. _onLostFocus(): void;
  8890. /**
  8891. * Get the friendly name associated with the input class.
  8892. * @returns the input friendly name
  8893. */
  8894. getSimpleName(): string;
  8895. }
  8896. }
  8897. declare module "babylonjs/Lights/shadowLight" {
  8898. import { Camera } from "babylonjs/Cameras/camera";
  8899. import { Scene } from "babylonjs/scene";
  8900. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8902. import { Light } from "babylonjs/Lights/light";
  8903. /**
  8904. * Interface describing all the common properties and methods a shadow light needs to implement.
  8905. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8906. * as well as binding the different shadow properties to the effects.
  8907. */
  8908. export interface IShadowLight extends Light {
  8909. /**
  8910. * The light id in the scene (used in scene.findLighById for instance)
  8911. */
  8912. id: string;
  8913. /**
  8914. * The position the shdow will be casted from.
  8915. */
  8916. position: Vector3;
  8917. /**
  8918. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8919. */
  8920. direction: Vector3;
  8921. /**
  8922. * The transformed position. Position of the light in world space taking parenting in account.
  8923. */
  8924. transformedPosition: Vector3;
  8925. /**
  8926. * The transformed direction. Direction of the light in world space taking parenting in account.
  8927. */
  8928. transformedDirection: Vector3;
  8929. /**
  8930. * The friendly name of the light in the scene.
  8931. */
  8932. name: string;
  8933. /**
  8934. * Defines the shadow projection clipping minimum z value.
  8935. */
  8936. shadowMinZ: number;
  8937. /**
  8938. * Defines the shadow projection clipping maximum z value.
  8939. */
  8940. shadowMaxZ: number;
  8941. /**
  8942. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8943. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8944. */
  8945. computeTransformedInformation(): boolean;
  8946. /**
  8947. * Gets the scene the light belongs to.
  8948. * @returns The scene
  8949. */
  8950. getScene(): Scene;
  8951. /**
  8952. * Callback defining a custom Projection Matrix Builder.
  8953. * This can be used to override the default projection matrix computation.
  8954. */
  8955. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8956. /**
  8957. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8958. * @param matrix The materix to updated with the projection information
  8959. * @param viewMatrix The transform matrix of the light
  8960. * @param renderList The list of mesh to render in the map
  8961. * @returns The current light
  8962. */
  8963. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8964. /**
  8965. * Gets the current depth scale used in ESM.
  8966. * @returns The scale
  8967. */
  8968. getDepthScale(): number;
  8969. /**
  8970. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8971. * @returns true if a cube texture needs to be use
  8972. */
  8973. needCube(): boolean;
  8974. /**
  8975. * Detects if the projection matrix requires to be recomputed this frame.
  8976. * @returns true if it requires to be recomputed otherwise, false.
  8977. */
  8978. needProjectionMatrixCompute(): boolean;
  8979. /**
  8980. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8981. */
  8982. forceProjectionMatrixCompute(): void;
  8983. /**
  8984. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8985. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8986. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8987. */
  8988. getShadowDirection(faceIndex?: number): Vector3;
  8989. /**
  8990. * Gets the minZ used for shadow according to both the scene and the light.
  8991. * @param activeCamera The camera we are returning the min for
  8992. * @returns the depth min z
  8993. */
  8994. getDepthMinZ(activeCamera: Camera): number;
  8995. /**
  8996. * Gets the maxZ used for shadow according to both the scene and the light.
  8997. * @param activeCamera The camera we are returning the max for
  8998. * @returns the depth max z
  8999. */
  9000. getDepthMaxZ(activeCamera: Camera): number;
  9001. }
  9002. /**
  9003. * Base implementation IShadowLight
  9004. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9005. */
  9006. export abstract class ShadowLight extends Light implements IShadowLight {
  9007. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9008. protected _position: Vector3;
  9009. protected _setPosition(value: Vector3): void;
  9010. /**
  9011. * Sets the position the shadow will be casted from. Also use as the light position for both
  9012. * point and spot lights.
  9013. */
  9014. /**
  9015. * Sets the position the shadow will be casted from. Also use as the light position for both
  9016. * point and spot lights.
  9017. */
  9018. position: Vector3;
  9019. protected _direction: Vector3;
  9020. protected _setDirection(value: Vector3): void;
  9021. /**
  9022. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9023. * Also use as the light direction on spot and directional lights.
  9024. */
  9025. /**
  9026. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9027. * Also use as the light direction on spot and directional lights.
  9028. */
  9029. direction: Vector3;
  9030. private _shadowMinZ;
  9031. /**
  9032. * Gets the shadow projection clipping minimum z value.
  9033. */
  9034. /**
  9035. * Sets the shadow projection clipping minimum z value.
  9036. */
  9037. shadowMinZ: number;
  9038. private _shadowMaxZ;
  9039. /**
  9040. * Sets the shadow projection clipping maximum z value.
  9041. */
  9042. /**
  9043. * Gets the shadow projection clipping maximum z value.
  9044. */
  9045. shadowMaxZ: number;
  9046. /**
  9047. * Callback defining a custom Projection Matrix Builder.
  9048. * This can be used to override the default projection matrix computation.
  9049. */
  9050. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9051. /**
  9052. * The transformed position. Position of the light in world space taking parenting in account.
  9053. */
  9054. transformedPosition: Vector3;
  9055. /**
  9056. * The transformed direction. Direction of the light in world space taking parenting in account.
  9057. */
  9058. transformedDirection: Vector3;
  9059. private _needProjectionMatrixCompute;
  9060. /**
  9061. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9062. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9063. */
  9064. computeTransformedInformation(): boolean;
  9065. /**
  9066. * Return the depth scale used for the shadow map.
  9067. * @returns the depth scale.
  9068. */
  9069. getDepthScale(): number;
  9070. /**
  9071. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9072. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9073. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9074. */
  9075. getShadowDirection(faceIndex?: number): Vector3;
  9076. /**
  9077. * Returns the ShadowLight absolute position in the World.
  9078. * @returns the position vector in world space
  9079. */
  9080. getAbsolutePosition(): Vector3;
  9081. /**
  9082. * Sets the ShadowLight direction toward the passed target.
  9083. * @param target The point to target in local space
  9084. * @returns the updated ShadowLight direction
  9085. */
  9086. setDirectionToTarget(target: Vector3): Vector3;
  9087. /**
  9088. * Returns the light rotation in euler definition.
  9089. * @returns the x y z rotation in local space.
  9090. */
  9091. getRotation(): Vector3;
  9092. /**
  9093. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9094. * @returns true if a cube texture needs to be use
  9095. */
  9096. needCube(): boolean;
  9097. /**
  9098. * Detects if the projection matrix requires to be recomputed this frame.
  9099. * @returns true if it requires to be recomputed otherwise, false.
  9100. */
  9101. needProjectionMatrixCompute(): boolean;
  9102. /**
  9103. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9104. */
  9105. forceProjectionMatrixCompute(): void;
  9106. /** @hidden */
  9107. _initCache(): void;
  9108. /** @hidden */
  9109. _isSynchronized(): boolean;
  9110. /**
  9111. * Computes the world matrix of the node
  9112. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9113. * @returns the world matrix
  9114. */
  9115. computeWorldMatrix(force?: boolean): Matrix;
  9116. /**
  9117. * Gets the minZ used for shadow according to both the scene and the light.
  9118. * @param activeCamera The camera we are returning the min for
  9119. * @returns the depth min z
  9120. */
  9121. getDepthMinZ(activeCamera: Camera): number;
  9122. /**
  9123. * Gets the maxZ used for shadow according to both the scene and the light.
  9124. * @param activeCamera The camera we are returning the max for
  9125. * @returns the depth max z
  9126. */
  9127. getDepthMaxZ(activeCamera: Camera): number;
  9128. /**
  9129. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9130. * @param matrix The materix to updated with the projection information
  9131. * @param viewMatrix The transform matrix of the light
  9132. * @param renderList The list of mesh to render in the map
  9133. * @returns The current light
  9134. */
  9135. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9136. }
  9137. }
  9138. declare module "babylonjs/Materials/materialHelper" {
  9139. import { Nullable } from "babylonjs/types";
  9140. import { Scene } from "babylonjs/scene";
  9141. import { Engine } from "babylonjs/Engines/engine";
  9142. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9143. import { Light } from "babylonjs/Lights/light";
  9144. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9145. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9146. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9147. /**
  9148. * "Static Class" containing the most commonly used helper while dealing with material for
  9149. * rendering purpose.
  9150. *
  9151. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9152. *
  9153. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9154. */
  9155. export class MaterialHelper {
  9156. /**
  9157. * Bind the current view position to an effect.
  9158. * @param effect The effect to be bound
  9159. * @param scene The scene the eyes position is used from
  9160. */
  9161. static BindEyePosition(effect: Effect, scene: Scene): void;
  9162. /**
  9163. * Helps preparing the defines values about the UVs in used in the effect.
  9164. * UVs are shared as much as we can accross channels in the shaders.
  9165. * @param texture The texture we are preparing the UVs for
  9166. * @param defines The defines to update
  9167. * @param key The channel key "diffuse", "specular"... used in the shader
  9168. */
  9169. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9170. /**
  9171. * Binds a texture matrix value to its corrsponding uniform
  9172. * @param texture The texture to bind the matrix for
  9173. * @param uniformBuffer The uniform buffer receivin the data
  9174. * @param key The channel key "diffuse", "specular"... used in the shader
  9175. */
  9176. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9177. /**
  9178. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9179. * @param mesh defines the current mesh
  9180. * @param scene defines the current scene
  9181. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9182. * @param pointsCloud defines if point cloud rendering has to be turned on
  9183. * @param fogEnabled defines if fog has to be turned on
  9184. * @param alphaTest defines if alpha testing has to be turned on
  9185. * @param defines defines the current list of defines
  9186. */
  9187. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9188. /**
  9189. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9190. * @param scene defines the current scene
  9191. * @param engine defines the current engine
  9192. * @param defines specifies the list of active defines
  9193. * @param useInstances defines if instances have to be turned on
  9194. * @param useClipPlane defines if clip plane have to be turned on
  9195. */
  9196. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9197. /**
  9198. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9199. * @param mesh The mesh containing the geometry data we will draw
  9200. * @param defines The defines to update
  9201. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9202. * @param useBones Precise whether bones should be used or not (override mesh info)
  9203. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9204. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9205. * @returns false if defines are considered not dirty and have not been checked
  9206. */
  9207. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9208. /**
  9209. * Prepares the defines related to the light information passed in parameter
  9210. * @param scene The scene we are intending to draw
  9211. * @param mesh The mesh the effect is compiling for
  9212. * @param defines The defines to update
  9213. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9214. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9215. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9216. * @returns true if normals will be required for the rest of the effect
  9217. */
  9218. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9219. /**
  9220. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9221. * that won t be acctive due to defines being turned off.
  9222. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9223. * @param samplersList The samplers list
  9224. * @param defines The defines helping in the list generation
  9225. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9226. */
  9227. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9228. /**
  9229. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9230. * @param defines The defines to update while falling back
  9231. * @param fallbacks The authorized effect fallbacks
  9232. * @param maxSimultaneousLights The maximum number of lights allowed
  9233. * @param rank the current rank of the Effect
  9234. * @returns The newly affected rank
  9235. */
  9236. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9237. /**
  9238. * Prepares the list of attributes required for morph targets according to the effect defines.
  9239. * @param attribs The current list of supported attribs
  9240. * @param mesh The mesh to prepare the morph targets attributes for
  9241. * @param defines The current Defines of the effect
  9242. */
  9243. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9244. /**
  9245. * Prepares the list of attributes required for bones according to the effect defines.
  9246. * @param attribs The current list of supported attribs
  9247. * @param mesh The mesh to prepare the bones attributes for
  9248. * @param defines The current Defines of the effect
  9249. * @param fallbacks The current efffect fallback strategy
  9250. */
  9251. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9252. /**
  9253. * Prepares the list of attributes required for instances according to the effect defines.
  9254. * @param attribs The current list of supported attribs
  9255. * @param defines The current Defines of the effect
  9256. */
  9257. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9258. /**
  9259. * Binds the light shadow information to the effect for the given mesh.
  9260. * @param light The light containing the generator
  9261. * @param scene The scene the lights belongs to
  9262. * @param mesh The mesh we are binding the information to render
  9263. * @param lightIndex The light index in the effect used to render the mesh
  9264. * @param effect The effect we are binding the data to
  9265. */
  9266. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9267. /**
  9268. * Binds the light information to the effect.
  9269. * @param light The light containing the generator
  9270. * @param effect The effect we are binding the data to
  9271. * @param lightIndex The light index in the effect used to render
  9272. */
  9273. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9274. /**
  9275. * Binds the lights information from the scene to the effect for the given mesh.
  9276. * @param scene The scene the lights belongs to
  9277. * @param mesh The mesh we are binding the information to render
  9278. * @param effect The effect we are binding the data to
  9279. * @param defines The generated defines for the effect
  9280. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9281. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9282. */
  9283. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9284. private static _tempFogColor;
  9285. /**
  9286. * Binds the fog information from the scene to the effect for the given mesh.
  9287. * @param scene The scene the lights belongs to
  9288. * @param mesh The mesh we are binding the information to render
  9289. * @param effect The effect we are binding the data to
  9290. * @param linearSpace Defines if the fog effect is applied in linear space
  9291. */
  9292. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9293. /**
  9294. * Binds the bones information from the mesh to the effect.
  9295. * @param mesh The mesh we are binding the information to render
  9296. * @param effect The effect we are binding the data to
  9297. */
  9298. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9299. /**
  9300. * Binds the morph targets information from the mesh to the effect.
  9301. * @param abstractMesh The mesh we are binding the information to render
  9302. * @param effect The effect we are binding the data to
  9303. */
  9304. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9305. /**
  9306. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9307. * @param defines The generated defines used in the effect
  9308. * @param effect The effect we are binding the data to
  9309. * @param scene The scene we are willing to render with logarithmic scale for
  9310. */
  9311. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9312. /**
  9313. * Binds the clip plane information from the scene to the effect.
  9314. * @param scene The scene the clip plane information are extracted from
  9315. * @param effect The effect we are binding the data to
  9316. */
  9317. static BindClipPlane(effect: Effect, scene: Scene): void;
  9318. }
  9319. }
  9320. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9321. /** @hidden */
  9322. export var kernelBlurVaryingDeclaration: {
  9323. name: string;
  9324. shader: string;
  9325. };
  9326. }
  9327. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9328. /** @hidden */
  9329. export var kernelBlurFragment: {
  9330. name: string;
  9331. shader: string;
  9332. };
  9333. }
  9334. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9335. /** @hidden */
  9336. export var kernelBlurFragment2: {
  9337. name: string;
  9338. shader: string;
  9339. };
  9340. }
  9341. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9342. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9343. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9344. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9345. /** @hidden */
  9346. export var kernelBlurPixelShader: {
  9347. name: string;
  9348. shader: string;
  9349. };
  9350. }
  9351. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9352. /** @hidden */
  9353. export var kernelBlurVertex: {
  9354. name: string;
  9355. shader: string;
  9356. };
  9357. }
  9358. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9359. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9360. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9361. /** @hidden */
  9362. export var kernelBlurVertexShader: {
  9363. name: string;
  9364. shader: string;
  9365. };
  9366. }
  9367. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9368. import { Vector2 } from "babylonjs/Maths/math";
  9369. import { Nullable } from "babylonjs/types";
  9370. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9371. import { Camera } from "babylonjs/Cameras/camera";
  9372. import { Effect } from "babylonjs/Materials/effect";
  9373. import { Engine } from "babylonjs/Engines/engine";
  9374. import "babylonjs/Shaders/kernelBlur.fragment";
  9375. import "babylonjs/Shaders/kernelBlur.vertex";
  9376. /**
  9377. * The Blur Post Process which blurs an image based on a kernel and direction.
  9378. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9379. */
  9380. export class BlurPostProcess extends PostProcess {
  9381. /** The direction in which to blur the image. */
  9382. direction: Vector2;
  9383. private blockCompilation;
  9384. protected _kernel: number;
  9385. protected _idealKernel: number;
  9386. protected _packedFloat: boolean;
  9387. private _staticDefines;
  9388. /**
  9389. * Sets the length in pixels of the blur sample region
  9390. */
  9391. /**
  9392. * Gets the length in pixels of the blur sample region
  9393. */
  9394. kernel: number;
  9395. /**
  9396. * Sets wether or not the blur needs to unpack/repack floats
  9397. */
  9398. /**
  9399. * Gets wether or not the blur is unpacking/repacking floats
  9400. */
  9401. packedFloat: boolean;
  9402. /**
  9403. * Creates a new instance BlurPostProcess
  9404. * @param name The name of the effect.
  9405. * @param direction The direction in which to blur the image.
  9406. * @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.
  9407. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9408. * @param camera The camera to apply the render pass to.
  9409. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9410. * @param engine The engine which the post process will be applied. (default: current engine)
  9411. * @param reusable If the post process can be reused on the same frame. (default: false)
  9412. * @param textureType Type of textures used when performing the post process. (default: 0)
  9413. * @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)
  9414. */
  9415. constructor(name: string,
  9416. /** The direction in which to blur the image. */
  9417. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9418. /**
  9419. * Updates the effect with the current post process compile time values and recompiles the shader.
  9420. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9421. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9422. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9423. * @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
  9424. * @param onCompiled Called when the shader has been compiled.
  9425. * @param onError Called if there is an error when compiling a shader.
  9426. */
  9427. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9428. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9429. /**
  9430. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9431. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9432. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9433. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9434. * The gaps between physical kernels are compensated for in the weighting of the samples
  9435. * @param idealKernel Ideal blur kernel.
  9436. * @return Nearest best kernel.
  9437. */
  9438. protected _nearestBestKernel(idealKernel: number): number;
  9439. /**
  9440. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9441. * @param x The point on the Gaussian distribution to sample.
  9442. * @return the value of the Gaussian function at x.
  9443. */
  9444. protected _gaussianWeight(x: number): number;
  9445. /**
  9446. * Generates a string that can be used as a floating point number in GLSL.
  9447. * @param x Value to print.
  9448. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9449. * @return GLSL float string.
  9450. */
  9451. protected _glslFloat(x: number, decimalFigures?: number): string;
  9452. }
  9453. }
  9454. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9455. /** @hidden */
  9456. export var shadowMapPixelShader: {
  9457. name: string;
  9458. shader: string;
  9459. };
  9460. }
  9461. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9462. /** @hidden */
  9463. export var bonesDeclaration: {
  9464. name: string;
  9465. shader: string;
  9466. };
  9467. }
  9468. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9469. /** @hidden */
  9470. export var morphTargetsVertexGlobalDeclaration: {
  9471. name: string;
  9472. shader: string;
  9473. };
  9474. }
  9475. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9476. /** @hidden */
  9477. export var morphTargetsVertexDeclaration: {
  9478. name: string;
  9479. shader: string;
  9480. };
  9481. }
  9482. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9483. /** @hidden */
  9484. export var instancesDeclaration: {
  9485. name: string;
  9486. shader: string;
  9487. };
  9488. }
  9489. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9490. /** @hidden */
  9491. export var helperFunctions: {
  9492. name: string;
  9493. shader: string;
  9494. };
  9495. }
  9496. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9497. /** @hidden */
  9498. export var morphTargetsVertex: {
  9499. name: string;
  9500. shader: string;
  9501. };
  9502. }
  9503. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9504. /** @hidden */
  9505. export var instancesVertex: {
  9506. name: string;
  9507. shader: string;
  9508. };
  9509. }
  9510. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9511. /** @hidden */
  9512. export var bonesVertex: {
  9513. name: string;
  9514. shader: string;
  9515. };
  9516. }
  9517. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9518. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9519. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9520. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9521. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9522. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9523. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9524. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9525. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9526. /** @hidden */
  9527. export var shadowMapVertexShader: {
  9528. name: string;
  9529. shader: string;
  9530. };
  9531. }
  9532. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9533. /** @hidden */
  9534. export var depthBoxBlurPixelShader: {
  9535. name: string;
  9536. shader: string;
  9537. };
  9538. }
  9539. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9540. import { Nullable } from "babylonjs/types";
  9541. import { Scene } from "babylonjs/scene";
  9542. import { Matrix } from "babylonjs/Maths/math";
  9543. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9544. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9545. import { Mesh } from "babylonjs/Meshes/mesh";
  9546. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9547. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9548. import { Effect } from "babylonjs/Materials/effect";
  9549. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9550. import "babylonjs/Shaders/shadowMap.fragment";
  9551. import "babylonjs/Shaders/shadowMap.vertex";
  9552. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9553. import { Observable } from "babylonjs/Misc/observable";
  9554. /**
  9555. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9556. */
  9557. export interface ICustomShaderOptions {
  9558. /**
  9559. * Gets or sets the custom shader name to use
  9560. */
  9561. shaderName: string;
  9562. /**
  9563. * The list of attribute names used in the shader
  9564. */
  9565. attributes?: string[];
  9566. /**
  9567. * The list of unifrom names used in the shader
  9568. */
  9569. uniforms?: string[];
  9570. /**
  9571. * The list of sampler names used in the shader
  9572. */
  9573. samplers?: string[];
  9574. /**
  9575. * The list of defines used in the shader
  9576. */
  9577. defines?: string[];
  9578. }
  9579. /**
  9580. * Interface to implement to create a shadow generator compatible with BJS.
  9581. */
  9582. export interface IShadowGenerator {
  9583. /**
  9584. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9585. * @returns The render target texture if present otherwise, null
  9586. */
  9587. getShadowMap(): Nullable<RenderTargetTexture>;
  9588. /**
  9589. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9590. * @returns The render target texture if the shadow map is present otherwise, null
  9591. */
  9592. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9593. /**
  9594. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9595. * @param subMesh The submesh we want to render in the shadow map
  9596. * @param useInstances Defines wether will draw in the map using instances
  9597. * @returns true if ready otherwise, false
  9598. */
  9599. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9600. /**
  9601. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9602. * @param defines Defines of the material we want to update
  9603. * @param lightIndex Index of the light in the enabled light list of the material
  9604. */
  9605. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9606. /**
  9607. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9608. * defined in the generator but impacting the effect).
  9609. * It implies the unifroms available on the materials are the standard BJS ones.
  9610. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9611. * @param effect The effect we are binfing the information for
  9612. */
  9613. bindShadowLight(lightIndex: string, effect: Effect): void;
  9614. /**
  9615. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9616. * (eq to shadow prjection matrix * light transform matrix)
  9617. * @returns The transform matrix used to create the shadow map
  9618. */
  9619. getTransformMatrix(): Matrix;
  9620. /**
  9621. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9622. * Cube and 2D textures for instance.
  9623. */
  9624. recreateShadowMap(): void;
  9625. /**
  9626. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9627. * @param onCompiled Callback triggered at the and of the effects compilation
  9628. * @param options Sets of optional options forcing the compilation with different modes
  9629. */
  9630. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9631. useInstances: boolean;
  9632. }>): void;
  9633. /**
  9634. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9635. * @param options Sets of optional options forcing the compilation with different modes
  9636. * @returns A promise that resolves when the compilation completes
  9637. */
  9638. forceCompilationAsync(options?: Partial<{
  9639. useInstances: boolean;
  9640. }>): Promise<void>;
  9641. /**
  9642. * Serializes the shadow generator setup to a json object.
  9643. * @returns The serialized JSON object
  9644. */
  9645. serialize(): any;
  9646. /**
  9647. * Disposes the Shadow map and related Textures and effects.
  9648. */
  9649. dispose(): void;
  9650. }
  9651. /**
  9652. * Default implementation IShadowGenerator.
  9653. * This is the main object responsible of generating shadows in the framework.
  9654. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9655. */
  9656. export class ShadowGenerator implements IShadowGenerator {
  9657. /**
  9658. * Shadow generator mode None: no filtering applied.
  9659. */
  9660. static readonly FILTER_NONE: number;
  9661. /**
  9662. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9663. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9664. */
  9665. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9666. /**
  9667. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9668. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9669. */
  9670. static readonly FILTER_POISSONSAMPLING: number;
  9671. /**
  9672. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9673. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9674. */
  9675. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9676. /**
  9677. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9678. * edge artifacts on steep falloff.
  9679. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9680. */
  9681. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9682. /**
  9683. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9684. * edge artifacts on steep falloff.
  9685. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9686. */
  9687. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9688. /**
  9689. * Shadow generator mode PCF: Percentage Closer Filtering
  9690. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9691. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9692. */
  9693. static readonly FILTER_PCF: number;
  9694. /**
  9695. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9696. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9697. * Contact Hardening
  9698. */
  9699. static readonly FILTER_PCSS: number;
  9700. /**
  9701. * Reserved for PCF and PCSS
  9702. * Highest Quality.
  9703. *
  9704. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9705. *
  9706. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9707. */
  9708. static readonly QUALITY_HIGH: number;
  9709. /**
  9710. * Reserved for PCF and PCSS
  9711. * Good tradeoff for quality/perf cross devices
  9712. *
  9713. * Execute PCF on a 3*3 kernel.
  9714. *
  9715. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9716. */
  9717. static readonly QUALITY_MEDIUM: number;
  9718. /**
  9719. * Reserved for PCF and PCSS
  9720. * The lowest quality but the fastest.
  9721. *
  9722. * Execute PCF on a 1*1 kernel.
  9723. *
  9724. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9725. */
  9726. static readonly QUALITY_LOW: number;
  9727. /** Gets or sets the custom shader name to use */
  9728. customShaderOptions: ICustomShaderOptions;
  9729. /**
  9730. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9731. */
  9732. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9733. /**
  9734. * Observable triggered before a mesh is rendered in the shadow map.
  9735. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9736. */
  9737. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9738. private _bias;
  9739. /**
  9740. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9741. */
  9742. /**
  9743. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9744. */
  9745. bias: number;
  9746. private _normalBias;
  9747. /**
  9748. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9749. */
  9750. /**
  9751. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9752. */
  9753. normalBias: number;
  9754. private _blurBoxOffset;
  9755. /**
  9756. * Gets the blur box offset: offset applied during the blur pass.
  9757. * Only useful if useKernelBlur = false
  9758. */
  9759. /**
  9760. * Sets the blur box offset: offset applied during the blur pass.
  9761. * Only useful if useKernelBlur = false
  9762. */
  9763. blurBoxOffset: number;
  9764. private _blurScale;
  9765. /**
  9766. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9767. * 2 means half of the size.
  9768. */
  9769. /**
  9770. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9771. * 2 means half of the size.
  9772. */
  9773. blurScale: number;
  9774. private _blurKernel;
  9775. /**
  9776. * Gets the blur kernel: kernel size of the blur pass.
  9777. * Only useful if useKernelBlur = true
  9778. */
  9779. /**
  9780. * Sets the blur kernel: kernel size of the blur pass.
  9781. * Only useful if useKernelBlur = true
  9782. */
  9783. blurKernel: number;
  9784. private _useKernelBlur;
  9785. /**
  9786. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9787. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9788. */
  9789. /**
  9790. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9791. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9792. */
  9793. useKernelBlur: boolean;
  9794. private _depthScale;
  9795. /**
  9796. * Gets the depth scale used in ESM mode.
  9797. */
  9798. /**
  9799. * Sets the depth scale used in ESM mode.
  9800. * This can override the scale stored on the light.
  9801. */
  9802. depthScale: number;
  9803. private _filter;
  9804. /**
  9805. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9806. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9807. */
  9808. /**
  9809. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9810. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9811. */
  9812. filter: number;
  9813. /**
  9814. * Gets if the current filter is set to Poisson Sampling.
  9815. */
  9816. /**
  9817. * Sets the current filter to Poisson Sampling.
  9818. */
  9819. usePoissonSampling: boolean;
  9820. /**
  9821. * Gets if the current filter is set to ESM.
  9822. */
  9823. /**
  9824. * Sets the current filter is to ESM.
  9825. */
  9826. useExponentialShadowMap: boolean;
  9827. /**
  9828. * Gets if the current filter is set to filtered ESM.
  9829. */
  9830. /**
  9831. * Gets if the current filter is set to filtered ESM.
  9832. */
  9833. useBlurExponentialShadowMap: boolean;
  9834. /**
  9835. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9836. * exponential to prevent steep falloff artifacts).
  9837. */
  9838. /**
  9839. * Sets the current filter to "close ESM" (using the inverse of the
  9840. * exponential to prevent steep falloff artifacts).
  9841. */
  9842. useCloseExponentialShadowMap: boolean;
  9843. /**
  9844. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9845. * exponential to prevent steep falloff artifacts).
  9846. */
  9847. /**
  9848. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9849. * exponential to prevent steep falloff artifacts).
  9850. */
  9851. useBlurCloseExponentialShadowMap: boolean;
  9852. /**
  9853. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9854. */
  9855. /**
  9856. * Sets the current filter to "PCF" (percentage closer filtering).
  9857. */
  9858. usePercentageCloserFiltering: boolean;
  9859. private _filteringQuality;
  9860. /**
  9861. * Gets the PCF or PCSS Quality.
  9862. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9863. */
  9864. /**
  9865. * Sets the PCF or PCSS Quality.
  9866. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9867. */
  9868. filteringQuality: number;
  9869. /**
  9870. * Gets if the current filter is set to "PCSS" (contact hardening).
  9871. */
  9872. /**
  9873. * Sets the current filter to "PCSS" (contact hardening).
  9874. */
  9875. useContactHardeningShadow: boolean;
  9876. private _contactHardeningLightSizeUVRatio;
  9877. /**
  9878. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9879. * Using a ratio helps keeping shape stability independently of the map size.
  9880. *
  9881. * It does not account for the light projection as it was having too much
  9882. * instability during the light setup or during light position changes.
  9883. *
  9884. * Only valid if useContactHardeningShadow is true.
  9885. */
  9886. /**
  9887. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9888. * Using a ratio helps keeping shape stability independently of the map size.
  9889. *
  9890. * It does not account for the light projection as it was having too much
  9891. * instability during the light setup or during light position changes.
  9892. *
  9893. * Only valid if useContactHardeningShadow is true.
  9894. */
  9895. contactHardeningLightSizeUVRatio: number;
  9896. private _darkness;
  9897. /**
  9898. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9899. * 0 means strongest and 1 would means no shadow.
  9900. * @returns the darkness.
  9901. */
  9902. getDarkness(): number;
  9903. /**
  9904. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9905. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9906. * @returns the shadow generator allowing fluent coding.
  9907. */
  9908. setDarkness(darkness: number): ShadowGenerator;
  9909. private _transparencyShadow;
  9910. /**
  9911. * Sets the ability to have transparent shadow (boolean).
  9912. * @param transparent True if transparent else False
  9913. * @returns the shadow generator allowing fluent coding
  9914. */
  9915. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9916. private _shadowMap;
  9917. private _shadowMap2;
  9918. /**
  9919. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9920. * @returns The render target texture if present otherwise, null
  9921. */
  9922. getShadowMap(): Nullable<RenderTargetTexture>;
  9923. /**
  9924. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9925. * @returns The render target texture if the shadow map is present otherwise, null
  9926. */
  9927. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9928. /**
  9929. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9930. * @param mesh Mesh to add
  9931. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9932. * @returns the Shadow Generator itself
  9933. */
  9934. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9935. /**
  9936. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9937. * @param mesh Mesh to remove
  9938. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9939. * @returns the Shadow Generator itself
  9940. */
  9941. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9942. /**
  9943. * Controls the extent to which the shadows fade out at the edge of the frustum
  9944. * Used only by directionals and spots
  9945. */
  9946. frustumEdgeFalloff: number;
  9947. private _light;
  9948. /**
  9949. * Returns the associated light object.
  9950. * @returns the light generating the shadow
  9951. */
  9952. getLight(): IShadowLight;
  9953. /**
  9954. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9955. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9956. * It might on the other hand introduce peter panning.
  9957. */
  9958. forceBackFacesOnly: boolean;
  9959. private _scene;
  9960. private _lightDirection;
  9961. private _effect;
  9962. private _viewMatrix;
  9963. private _projectionMatrix;
  9964. private _transformMatrix;
  9965. private _cachedPosition;
  9966. private _cachedDirection;
  9967. private _cachedDefines;
  9968. private _currentRenderID;
  9969. private _boxBlurPostprocess;
  9970. private _kernelBlurXPostprocess;
  9971. private _kernelBlurYPostprocess;
  9972. private _blurPostProcesses;
  9973. private _mapSize;
  9974. private _currentFaceIndex;
  9975. private _currentFaceIndexCache;
  9976. private _textureType;
  9977. private _defaultTextureMatrix;
  9978. /** @hidden */
  9979. static _SceneComponentInitialization: (scene: Scene) => void;
  9980. /**
  9981. * Creates a ShadowGenerator object.
  9982. * A ShadowGenerator is the required tool to use the shadows.
  9983. * Each light casting shadows needs to use its own ShadowGenerator.
  9984. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9985. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9986. * @param light The light object generating the shadows.
  9987. * @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.
  9988. */
  9989. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9990. private _initializeGenerator;
  9991. private _initializeShadowMap;
  9992. private _initializeBlurRTTAndPostProcesses;
  9993. private _renderForShadowMap;
  9994. private _renderSubMeshForShadowMap;
  9995. private _applyFilterValues;
  9996. /**
  9997. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9998. * @param onCompiled Callback triggered at the and of the effects compilation
  9999. * @param options Sets of optional options forcing the compilation with different modes
  10000. */
  10001. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10002. useInstances: boolean;
  10003. }>): void;
  10004. /**
  10005. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10006. * @param options Sets of optional options forcing the compilation with different modes
  10007. * @returns A promise that resolves when the compilation completes
  10008. */
  10009. forceCompilationAsync(options?: Partial<{
  10010. useInstances: boolean;
  10011. }>): Promise<void>;
  10012. /**
  10013. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10014. * @param subMesh The submesh we want to render in the shadow map
  10015. * @param useInstances Defines wether will draw in the map using instances
  10016. * @returns true if ready otherwise, false
  10017. */
  10018. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10019. /**
  10020. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10021. * @param defines Defines of the material we want to update
  10022. * @param lightIndex Index of the light in the enabled light list of the material
  10023. */
  10024. prepareDefines(defines: any, lightIndex: number): void;
  10025. /**
  10026. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10027. * defined in the generator but impacting the effect).
  10028. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10029. * @param effect The effect we are binfing the information for
  10030. */
  10031. bindShadowLight(lightIndex: string, effect: Effect): void;
  10032. /**
  10033. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10034. * (eq to shadow prjection matrix * light transform matrix)
  10035. * @returns The transform matrix used to create the shadow map
  10036. */
  10037. getTransformMatrix(): Matrix;
  10038. /**
  10039. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10040. * Cube and 2D textures for instance.
  10041. */
  10042. recreateShadowMap(): void;
  10043. private _disposeBlurPostProcesses;
  10044. private _disposeRTTandPostProcesses;
  10045. /**
  10046. * Disposes the ShadowGenerator.
  10047. * Returns nothing.
  10048. */
  10049. dispose(): void;
  10050. /**
  10051. * Serializes the shadow generator setup to a json object.
  10052. * @returns The serialized JSON object
  10053. */
  10054. serialize(): any;
  10055. /**
  10056. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10057. * @param parsedShadowGenerator The JSON object to parse
  10058. * @param scene The scene to create the shadow map for
  10059. * @returns The parsed shadow generator
  10060. */
  10061. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10062. }
  10063. }
  10064. declare module "babylonjs/Lights/light" {
  10065. import { Nullable } from "babylonjs/types";
  10066. import { Scene } from "babylonjs/scene";
  10067. import { Vector3, Color3 } from "babylonjs/Maths/math";
  10068. import { Node } from "babylonjs/node";
  10069. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10070. import { Effect } from "babylonjs/Materials/effect";
  10071. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10072. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10073. /**
  10074. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10075. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10076. * 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.
  10077. */
  10078. export abstract class Light extends Node {
  10079. /**
  10080. * Falloff Default: light is falling off following the material specification:
  10081. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10082. */
  10083. static readonly FALLOFF_DEFAULT: number;
  10084. /**
  10085. * Falloff Physical: light is falling off following the inverse squared distance law.
  10086. */
  10087. static readonly FALLOFF_PHYSICAL: number;
  10088. /**
  10089. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10090. * to enhance interoperability with other engines.
  10091. */
  10092. static readonly FALLOFF_GLTF: number;
  10093. /**
  10094. * Falloff Standard: light is falling off like in the standard material
  10095. * to enhance interoperability with other materials.
  10096. */
  10097. static readonly FALLOFF_STANDARD: number;
  10098. /**
  10099. * If every light affecting the material is in this lightmapMode,
  10100. * material.lightmapTexture adds or multiplies
  10101. * (depends on material.useLightmapAsShadowmap)
  10102. * after every other light calculations.
  10103. */
  10104. static readonly LIGHTMAP_DEFAULT: number;
  10105. /**
  10106. * material.lightmapTexture as only diffuse lighting from this light
  10107. * adds only specular lighting from this light
  10108. * adds dynamic shadows
  10109. */
  10110. static readonly LIGHTMAP_SPECULAR: number;
  10111. /**
  10112. * material.lightmapTexture as only lighting
  10113. * no light calculation from this light
  10114. * only adds dynamic shadows from this light
  10115. */
  10116. static readonly LIGHTMAP_SHADOWSONLY: number;
  10117. /**
  10118. * Each light type uses the default quantity according to its type:
  10119. * point/spot lights use luminous intensity
  10120. * directional lights use illuminance
  10121. */
  10122. static readonly INTENSITYMODE_AUTOMATIC: number;
  10123. /**
  10124. * lumen (lm)
  10125. */
  10126. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10127. /**
  10128. * candela (lm/sr)
  10129. */
  10130. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10131. /**
  10132. * lux (lm/m^2)
  10133. */
  10134. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10135. /**
  10136. * nit (cd/m^2)
  10137. */
  10138. static readonly INTENSITYMODE_LUMINANCE: number;
  10139. /**
  10140. * Light type const id of the point light.
  10141. */
  10142. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10143. /**
  10144. * Light type const id of the directional light.
  10145. */
  10146. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10147. /**
  10148. * Light type const id of the spot light.
  10149. */
  10150. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10151. /**
  10152. * Light type const id of the hemispheric light.
  10153. */
  10154. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10155. /**
  10156. * Diffuse gives the basic color to an object.
  10157. */
  10158. diffuse: Color3;
  10159. /**
  10160. * Specular produces a highlight color on an object.
  10161. * Note: This is note affecting PBR materials.
  10162. */
  10163. specular: Color3;
  10164. /**
  10165. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10166. * falling off base on range or angle.
  10167. * This can be set to any values in Light.FALLOFF_x.
  10168. *
  10169. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10170. * other types of materials.
  10171. */
  10172. falloffType: number;
  10173. /**
  10174. * Strength of the light.
  10175. * Note: By default it is define in the framework own unit.
  10176. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10177. */
  10178. intensity: number;
  10179. private _range;
  10180. protected _inverseSquaredRange: number;
  10181. /**
  10182. * Defines how far from the source the light is impacting in scene units.
  10183. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10184. */
  10185. /**
  10186. * Defines how far from the source the light is impacting in scene units.
  10187. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10188. */
  10189. range: number;
  10190. /**
  10191. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10192. * of light.
  10193. */
  10194. private _photometricScale;
  10195. private _intensityMode;
  10196. /**
  10197. * Gets the photometric scale used to interpret the intensity.
  10198. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10199. */
  10200. /**
  10201. * Sets the photometric scale used to interpret the intensity.
  10202. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10203. */
  10204. intensityMode: number;
  10205. private _radius;
  10206. /**
  10207. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10208. */
  10209. /**
  10210. * sets the light radius used by PBR Materials to simulate soft area lights.
  10211. */
  10212. radius: number;
  10213. private _renderPriority;
  10214. /**
  10215. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10216. * exceeding the number allowed of the materials.
  10217. */
  10218. renderPriority: number;
  10219. private _shadowEnabled;
  10220. /**
  10221. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10222. * the current shadow generator.
  10223. */
  10224. /**
  10225. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10226. * the current shadow generator.
  10227. */
  10228. shadowEnabled: boolean;
  10229. private _includedOnlyMeshes;
  10230. /**
  10231. * Gets the only meshes impacted by this light.
  10232. */
  10233. /**
  10234. * Sets the only meshes impacted by this light.
  10235. */
  10236. includedOnlyMeshes: AbstractMesh[];
  10237. private _excludedMeshes;
  10238. /**
  10239. * Gets the meshes not impacted by this light.
  10240. */
  10241. /**
  10242. * Sets the meshes not impacted by this light.
  10243. */
  10244. excludedMeshes: AbstractMesh[];
  10245. private _excludeWithLayerMask;
  10246. /**
  10247. * Gets the layer id use to find what meshes are not impacted by the light.
  10248. * Inactive if 0
  10249. */
  10250. /**
  10251. * Sets the layer id use to find what meshes are not impacted by the light.
  10252. * Inactive if 0
  10253. */
  10254. excludeWithLayerMask: number;
  10255. private _includeOnlyWithLayerMask;
  10256. /**
  10257. * Gets the layer id use to find what meshes are impacted by the light.
  10258. * Inactive if 0
  10259. */
  10260. /**
  10261. * Sets the layer id use to find what meshes are impacted by the light.
  10262. * Inactive if 0
  10263. */
  10264. includeOnlyWithLayerMask: number;
  10265. private _lightmapMode;
  10266. /**
  10267. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10268. */
  10269. /**
  10270. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10271. */
  10272. lightmapMode: number;
  10273. /**
  10274. * Shadow generator associted to the light.
  10275. * @hidden Internal use only.
  10276. */
  10277. _shadowGenerator: Nullable<IShadowGenerator>;
  10278. /**
  10279. * @hidden Internal use only.
  10280. */
  10281. _excludedMeshesIds: string[];
  10282. /**
  10283. * @hidden Internal use only.
  10284. */
  10285. _includedOnlyMeshesIds: string[];
  10286. /**
  10287. * The current light unifom buffer.
  10288. * @hidden Internal use only.
  10289. */
  10290. _uniformBuffer: UniformBuffer;
  10291. /**
  10292. * Creates a Light object in the scene.
  10293. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10294. * @param name The firendly name of the light
  10295. * @param scene The scene the light belongs too
  10296. */
  10297. constructor(name: string, scene: Scene);
  10298. protected abstract _buildUniformLayout(): void;
  10299. /**
  10300. * Sets the passed Effect "effect" with the Light information.
  10301. * @param effect The effect to update
  10302. * @param lightIndex The index of the light in the effect to update
  10303. * @returns The light
  10304. */
  10305. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10306. /**
  10307. * Returns the string "Light".
  10308. * @returns the class name
  10309. */
  10310. getClassName(): string;
  10311. /** @hidden */
  10312. readonly _isLight: boolean;
  10313. /**
  10314. * Converts the light information to a readable string for debug purpose.
  10315. * @param fullDetails Supports for multiple levels of logging within scene loading
  10316. * @returns the human readable light info
  10317. */
  10318. toString(fullDetails?: boolean): string;
  10319. /** @hidden */
  10320. protected _syncParentEnabledState(): void;
  10321. /**
  10322. * Set the enabled state of this node.
  10323. * @param value - the new enabled state
  10324. */
  10325. setEnabled(value: boolean): void;
  10326. /**
  10327. * Returns the Light associated shadow generator if any.
  10328. * @return the associated shadow generator.
  10329. */
  10330. getShadowGenerator(): Nullable<IShadowGenerator>;
  10331. /**
  10332. * Returns a Vector3, the absolute light position in the World.
  10333. * @returns the world space position of the light
  10334. */
  10335. getAbsolutePosition(): Vector3;
  10336. /**
  10337. * Specifies if the light will affect the passed mesh.
  10338. * @param mesh The mesh to test against the light
  10339. * @return true the mesh is affected otherwise, false.
  10340. */
  10341. canAffectMesh(mesh: AbstractMesh): boolean;
  10342. /**
  10343. * Sort function to order lights for rendering.
  10344. * @param a First Light object to compare to second.
  10345. * @param b Second Light object to compare first.
  10346. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10347. */
  10348. static CompareLightsPriority(a: Light, b: Light): number;
  10349. /**
  10350. * Releases resources associated with this node.
  10351. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10352. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10353. */
  10354. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10355. /**
  10356. * Returns the light type ID (integer).
  10357. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10358. */
  10359. getTypeID(): number;
  10360. /**
  10361. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10362. * @returns the scaled intensity in intensity mode unit
  10363. */
  10364. getScaledIntensity(): number;
  10365. /**
  10366. * Returns a new Light object, named "name", from the current one.
  10367. * @param name The name of the cloned light
  10368. * @returns the new created light
  10369. */
  10370. clone(name: string): Nullable<Light>;
  10371. /**
  10372. * Serializes the current light into a Serialization object.
  10373. * @returns the serialized object.
  10374. */
  10375. serialize(): any;
  10376. /**
  10377. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10378. * This new light is named "name" and added to the passed scene.
  10379. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10380. * @param name The friendly name of the light
  10381. * @param scene The scene the new light will belong to
  10382. * @returns the constructor function
  10383. */
  10384. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10385. /**
  10386. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10387. * @param parsedLight The JSON representation of the light
  10388. * @param scene The scene to create the parsed light in
  10389. * @returns the created light after parsing
  10390. */
  10391. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10392. private _hookArrayForExcluded;
  10393. private _hookArrayForIncludedOnly;
  10394. private _resyncMeshes;
  10395. /**
  10396. * Forces the meshes to update their light related information in their rendering used effects
  10397. * @hidden Internal Use Only
  10398. */
  10399. _markMeshesAsLightDirty(): void;
  10400. /**
  10401. * Recomputes the cached photometric scale if needed.
  10402. */
  10403. private _computePhotometricScale;
  10404. /**
  10405. * Returns the Photometric Scale according to the light type and intensity mode.
  10406. */
  10407. private _getPhotometricScale;
  10408. /**
  10409. * Reorder the light in the scene according to their defined priority.
  10410. * @hidden Internal Use Only
  10411. */
  10412. _reorderLightsInScene(): void;
  10413. /**
  10414. * Prepares the list of defines specific to the light type.
  10415. * @param defines the list of defines
  10416. * @param lightIndex defines the index of the light for the effect
  10417. */
  10418. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10419. }
  10420. }
  10421. declare module "babylonjs/Actions/action" {
  10422. import { Observable } from "babylonjs/Misc/observable";
  10423. import { Condition } from "babylonjs/Actions/condition";
  10424. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10425. import { ActionManager } from "babylonjs/Actions/actionManager";
  10426. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10427. /**
  10428. * Interface used to define Action
  10429. */
  10430. export interface IAction {
  10431. /**
  10432. * Trigger for the action
  10433. */
  10434. trigger: number;
  10435. /** Options of the trigger */
  10436. triggerOptions: any;
  10437. /**
  10438. * Gets the trigger parameters
  10439. * @returns the trigger parameters
  10440. */
  10441. getTriggerParameter(): any;
  10442. /**
  10443. * Internal only - executes current action event
  10444. * @hidden
  10445. */
  10446. _executeCurrent(evt?: ActionEvent): void;
  10447. /**
  10448. * Serialize placeholder for child classes
  10449. * @param parent of child
  10450. * @returns the serialized object
  10451. */
  10452. serialize(parent: any): any;
  10453. /**
  10454. * Internal only
  10455. * @hidden
  10456. */
  10457. _prepare(): void;
  10458. /**
  10459. * Internal only - manager for action
  10460. * @hidden
  10461. */
  10462. _actionManager: AbstractActionManager;
  10463. }
  10464. /**
  10465. * The action to be carried out following a trigger
  10466. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10467. */
  10468. export class Action implements IAction {
  10469. /** the trigger, with or without parameters, for the action */
  10470. triggerOptions: any;
  10471. /**
  10472. * Trigger for the action
  10473. */
  10474. trigger: number;
  10475. /**
  10476. * Internal only - manager for action
  10477. * @hidden
  10478. */
  10479. _actionManager: ActionManager;
  10480. private _nextActiveAction;
  10481. private _child;
  10482. private _condition?;
  10483. private _triggerParameter;
  10484. /**
  10485. * An event triggered prior to action being executed.
  10486. */
  10487. onBeforeExecuteObservable: Observable<Action>;
  10488. /**
  10489. * Creates a new Action
  10490. * @param triggerOptions the trigger, with or without parameters, for the action
  10491. * @param condition an optional determinant of action
  10492. */
  10493. constructor(
  10494. /** the trigger, with or without parameters, for the action */
  10495. triggerOptions: any, condition?: Condition);
  10496. /**
  10497. * Internal only
  10498. * @hidden
  10499. */
  10500. _prepare(): void;
  10501. /**
  10502. * Gets the trigger parameters
  10503. * @returns the trigger parameters
  10504. */
  10505. getTriggerParameter(): any;
  10506. /**
  10507. * Internal only - executes current action event
  10508. * @hidden
  10509. */
  10510. _executeCurrent(evt?: ActionEvent): void;
  10511. /**
  10512. * Execute placeholder for child classes
  10513. * @param evt optional action event
  10514. */
  10515. execute(evt?: ActionEvent): void;
  10516. /**
  10517. * Skips to next active action
  10518. */
  10519. skipToNextActiveAction(): void;
  10520. /**
  10521. * Adds action to chain of actions, may be a DoNothingAction
  10522. * @param action defines the next action to execute
  10523. * @returns The action passed in
  10524. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10525. */
  10526. then(action: Action): Action;
  10527. /**
  10528. * Internal only
  10529. * @hidden
  10530. */
  10531. _getProperty(propertyPath: string): string;
  10532. /**
  10533. * Internal only
  10534. * @hidden
  10535. */
  10536. _getEffectiveTarget(target: any, propertyPath: string): any;
  10537. /**
  10538. * Serialize placeholder for child classes
  10539. * @param parent of child
  10540. * @returns the serialized object
  10541. */
  10542. serialize(parent: any): any;
  10543. /**
  10544. * Internal only called by serialize
  10545. * @hidden
  10546. */
  10547. protected _serialize(serializedAction: any, parent?: any): any;
  10548. /**
  10549. * Internal only
  10550. * @hidden
  10551. */
  10552. static _SerializeValueAsString: (value: any) => string;
  10553. /**
  10554. * Internal only
  10555. * @hidden
  10556. */
  10557. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10558. name: string;
  10559. targetType: string;
  10560. value: string;
  10561. };
  10562. }
  10563. }
  10564. declare module "babylonjs/Actions/condition" {
  10565. import { ActionManager } from "babylonjs/Actions/actionManager";
  10566. /**
  10567. * A Condition applied to an Action
  10568. */
  10569. export class Condition {
  10570. /**
  10571. * Internal only - manager for action
  10572. * @hidden
  10573. */
  10574. _actionManager: ActionManager;
  10575. /**
  10576. * Internal only
  10577. * @hidden
  10578. */
  10579. _evaluationId: number;
  10580. /**
  10581. * Internal only
  10582. * @hidden
  10583. */
  10584. _currentResult: boolean;
  10585. /**
  10586. * Creates a new Condition
  10587. * @param actionManager the manager of the action the condition is applied to
  10588. */
  10589. constructor(actionManager: ActionManager);
  10590. /**
  10591. * Check if the current condition is valid
  10592. * @returns a boolean
  10593. */
  10594. isValid(): boolean;
  10595. /**
  10596. * Internal only
  10597. * @hidden
  10598. */
  10599. _getProperty(propertyPath: string): string;
  10600. /**
  10601. * Internal only
  10602. * @hidden
  10603. */
  10604. _getEffectiveTarget(target: any, propertyPath: string): any;
  10605. /**
  10606. * Serialize placeholder for child classes
  10607. * @returns the serialized object
  10608. */
  10609. serialize(): any;
  10610. /**
  10611. * Internal only
  10612. * @hidden
  10613. */
  10614. protected _serialize(serializedCondition: any): any;
  10615. }
  10616. /**
  10617. * Defines specific conditional operators as extensions of Condition
  10618. */
  10619. export class ValueCondition extends Condition {
  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. * Internal only
  10628. * @hidden
  10629. */
  10630. private static _IsEqual;
  10631. /**
  10632. * Internal only
  10633. * @hidden
  10634. */
  10635. private static _IsDifferent;
  10636. /**
  10637. * Internal only
  10638. * @hidden
  10639. */
  10640. private static _IsGreater;
  10641. /**
  10642. * Internal only
  10643. * @hidden
  10644. */
  10645. private static _IsLesser;
  10646. /**
  10647. * returns the number for IsEqual
  10648. */
  10649. static readonly IsEqual: number;
  10650. /**
  10651. * Returns the number for IsDifferent
  10652. */
  10653. static readonly IsDifferent: number;
  10654. /**
  10655. * Returns the number for IsGreater
  10656. */
  10657. static readonly IsGreater: number;
  10658. /**
  10659. * Returns the number for IsLesser
  10660. */
  10661. static readonly IsLesser: number;
  10662. /**
  10663. * Internal only The action manager for the condition
  10664. * @hidden
  10665. */
  10666. _actionManager: ActionManager;
  10667. /**
  10668. * Internal only
  10669. * @hidden
  10670. */
  10671. private _target;
  10672. /**
  10673. * Internal only
  10674. * @hidden
  10675. */
  10676. private _effectiveTarget;
  10677. /**
  10678. * Internal only
  10679. * @hidden
  10680. */
  10681. private _property;
  10682. /**
  10683. * Creates a new ValueCondition
  10684. * @param actionManager manager for the action the condition applies to
  10685. * @param target for the action
  10686. * @param propertyPath path to specify the property of the target the conditional operator uses
  10687. * @param value the value compared by the conditional operator against the current value of the property
  10688. * @param operator the conditional operator, default ValueCondition.IsEqual
  10689. */
  10690. constructor(actionManager: ActionManager, target: any,
  10691. /** path to specify the property of the target the conditional operator uses */
  10692. propertyPath: string,
  10693. /** the value compared by the conditional operator against the current value of the property */
  10694. value: any,
  10695. /** the conditional operator, default ValueCondition.IsEqual */
  10696. operator?: number);
  10697. /**
  10698. * Compares the given value with the property value for the specified conditional operator
  10699. * @returns the result of the comparison
  10700. */
  10701. isValid(): boolean;
  10702. /**
  10703. * Serialize the ValueCondition into a JSON compatible object
  10704. * @returns serialization object
  10705. */
  10706. serialize(): any;
  10707. /**
  10708. * Gets the name of the conditional operator for the ValueCondition
  10709. * @param operator the conditional operator
  10710. * @returns the name
  10711. */
  10712. static GetOperatorName(operator: number): string;
  10713. }
  10714. /**
  10715. * Defines a predicate condition as an extension of Condition
  10716. */
  10717. export class PredicateCondition extends Condition {
  10718. /** defines the predicate function used to validate the condition */
  10719. predicate: () => boolean;
  10720. /**
  10721. * Internal only - manager for action
  10722. * @hidden
  10723. */
  10724. _actionManager: ActionManager;
  10725. /**
  10726. * Creates a new PredicateCondition
  10727. * @param actionManager manager for the action the condition applies to
  10728. * @param predicate defines the predicate function used to validate the condition
  10729. */
  10730. constructor(actionManager: ActionManager,
  10731. /** defines the predicate function used to validate the condition */
  10732. predicate: () => boolean);
  10733. /**
  10734. * @returns the validity of the predicate condition
  10735. */
  10736. isValid(): boolean;
  10737. }
  10738. /**
  10739. * Defines a state condition as an extension of Condition
  10740. */
  10741. export class StateCondition extends Condition {
  10742. /** Value to compare with target state */
  10743. value: string;
  10744. /**
  10745. * Internal only - manager for action
  10746. * @hidden
  10747. */
  10748. _actionManager: ActionManager;
  10749. /**
  10750. * Internal only
  10751. * @hidden
  10752. */
  10753. private _target;
  10754. /**
  10755. * Creates a new StateCondition
  10756. * @param actionManager manager for the action the condition applies to
  10757. * @param target of the condition
  10758. * @param value to compare with target state
  10759. */
  10760. constructor(actionManager: ActionManager, target: any,
  10761. /** Value to compare with target state */
  10762. value: string);
  10763. /**
  10764. * Gets a boolean indicating if the current condition is met
  10765. * @returns the validity of the state
  10766. */
  10767. isValid(): boolean;
  10768. /**
  10769. * Serialize the StateCondition into a JSON compatible object
  10770. * @returns serialization object
  10771. */
  10772. serialize(): any;
  10773. }
  10774. }
  10775. declare module "babylonjs/Actions/directActions" {
  10776. import { Action } from "babylonjs/Actions/action";
  10777. import { Condition } from "babylonjs/Actions/condition";
  10778. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10779. /**
  10780. * This defines an action responsible to toggle a boolean once triggered.
  10781. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10782. */
  10783. export class SwitchBooleanAction extends Action {
  10784. /**
  10785. * The path to the boolean property in the target object
  10786. */
  10787. propertyPath: string;
  10788. private _target;
  10789. private _effectiveTarget;
  10790. private _property;
  10791. /**
  10792. * Instantiate the action
  10793. * @param triggerOptions defines the trigger options
  10794. * @param target defines the object containing the boolean
  10795. * @param propertyPath defines the path to the boolean property in the target object
  10796. * @param condition defines the trigger related conditions
  10797. */
  10798. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10799. /** @hidden */
  10800. _prepare(): void;
  10801. /**
  10802. * Execute the action toggle the boolean value.
  10803. */
  10804. execute(): void;
  10805. /**
  10806. * Serializes the actions and its related information.
  10807. * @param parent defines the object to serialize in
  10808. * @returns the serialized object
  10809. */
  10810. serialize(parent: any): any;
  10811. }
  10812. /**
  10813. * This defines an action responsible to set a the state field of the target
  10814. * to a desired value once triggered.
  10815. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10816. */
  10817. export class SetStateAction extends Action {
  10818. /**
  10819. * The value to store in the state field.
  10820. */
  10821. value: string;
  10822. private _target;
  10823. /**
  10824. * Instantiate the action
  10825. * @param triggerOptions defines the trigger options
  10826. * @param target defines the object containing the state property
  10827. * @param value defines the value to store in the state field
  10828. * @param condition defines the trigger related conditions
  10829. */
  10830. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10831. /**
  10832. * Execute the action and store the value on the target state property.
  10833. */
  10834. execute(): void;
  10835. /**
  10836. * Serializes the actions and its related information.
  10837. * @param parent defines the object to serialize in
  10838. * @returns the serialized object
  10839. */
  10840. serialize(parent: any): any;
  10841. }
  10842. /**
  10843. * This defines an action responsible to set a property of the target
  10844. * to a desired value once triggered.
  10845. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10846. */
  10847. export class SetValueAction extends Action {
  10848. /**
  10849. * The path of the property to set in the target.
  10850. */
  10851. propertyPath: string;
  10852. /**
  10853. * The value to set in the property
  10854. */
  10855. value: any;
  10856. private _target;
  10857. private _effectiveTarget;
  10858. private _property;
  10859. /**
  10860. * Instantiate the action
  10861. * @param triggerOptions defines the trigger options
  10862. * @param target defines the object containing the property
  10863. * @param propertyPath defines the path of the property to set in the target
  10864. * @param value defines the value to set in the property
  10865. * @param condition defines the trigger related conditions
  10866. */
  10867. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10868. /** @hidden */
  10869. _prepare(): void;
  10870. /**
  10871. * Execute the action and set the targetted property to the desired value.
  10872. */
  10873. execute(): void;
  10874. /**
  10875. * Serializes the actions and its related information.
  10876. * @param parent defines the object to serialize in
  10877. * @returns the serialized object
  10878. */
  10879. serialize(parent: any): any;
  10880. }
  10881. /**
  10882. * This defines an action responsible to increment the target value
  10883. * to a desired value once triggered.
  10884. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10885. */
  10886. export class IncrementValueAction extends Action {
  10887. /**
  10888. * The path of the property to increment in the target.
  10889. */
  10890. propertyPath: string;
  10891. /**
  10892. * The value we should increment the property by.
  10893. */
  10894. value: any;
  10895. private _target;
  10896. private _effectiveTarget;
  10897. private _property;
  10898. /**
  10899. * Instantiate the action
  10900. * @param triggerOptions defines the trigger options
  10901. * @param target defines the object containing the property
  10902. * @param propertyPath defines the path of the property to increment in the target
  10903. * @param value defines the value value we should increment the property by
  10904. * @param condition defines the trigger related conditions
  10905. */
  10906. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10907. /** @hidden */
  10908. _prepare(): void;
  10909. /**
  10910. * Execute the action and increment the target of the value amount.
  10911. */
  10912. execute(): void;
  10913. /**
  10914. * Serializes the actions and its related information.
  10915. * @param parent defines the object to serialize in
  10916. * @returns the serialized object
  10917. */
  10918. serialize(parent: any): any;
  10919. }
  10920. /**
  10921. * This defines an action responsible to start an animation once triggered.
  10922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10923. */
  10924. export class PlayAnimationAction extends Action {
  10925. /**
  10926. * Where the animation should start (animation frame)
  10927. */
  10928. from: number;
  10929. /**
  10930. * Where the animation should stop (animation frame)
  10931. */
  10932. to: number;
  10933. /**
  10934. * Define if the animation should loop or stop after the first play.
  10935. */
  10936. loop?: boolean;
  10937. private _target;
  10938. /**
  10939. * Instantiate the action
  10940. * @param triggerOptions defines the trigger options
  10941. * @param target defines the target animation or animation name
  10942. * @param from defines from where the animation should start (animation frame)
  10943. * @param end defines where the animation should stop (animation frame)
  10944. * @param loop defines if the animation should loop or stop after the first play
  10945. * @param condition defines the trigger related conditions
  10946. */
  10947. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10948. /** @hidden */
  10949. _prepare(): void;
  10950. /**
  10951. * Execute the action and play the animation.
  10952. */
  10953. execute(): void;
  10954. /**
  10955. * Serializes the actions and its related information.
  10956. * @param parent defines the object to serialize in
  10957. * @returns the serialized object
  10958. */
  10959. serialize(parent: any): any;
  10960. }
  10961. /**
  10962. * This defines an action responsible to stop an animation once triggered.
  10963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10964. */
  10965. export class StopAnimationAction extends Action {
  10966. private _target;
  10967. /**
  10968. * Instantiate the action
  10969. * @param triggerOptions defines the trigger options
  10970. * @param target defines the target animation or animation name
  10971. * @param condition defines the trigger related conditions
  10972. */
  10973. constructor(triggerOptions: any, target: any, condition?: Condition);
  10974. /** @hidden */
  10975. _prepare(): void;
  10976. /**
  10977. * Execute the action and stop the animation.
  10978. */
  10979. execute(): void;
  10980. /**
  10981. * Serializes the actions and its related information.
  10982. * @param parent defines the object to serialize in
  10983. * @returns the serialized object
  10984. */
  10985. serialize(parent: any): any;
  10986. }
  10987. /**
  10988. * This defines an action responsible that does nothing once triggered.
  10989. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10990. */
  10991. export class DoNothingAction extends Action {
  10992. /**
  10993. * Instantiate the action
  10994. * @param triggerOptions defines the trigger options
  10995. * @param condition defines the trigger related conditions
  10996. */
  10997. constructor(triggerOptions?: any, condition?: Condition);
  10998. /**
  10999. * Execute the action and do nothing.
  11000. */
  11001. execute(): void;
  11002. /**
  11003. * Serializes the actions and its related information.
  11004. * @param parent defines the object to serialize in
  11005. * @returns the serialized object
  11006. */
  11007. serialize(parent: any): any;
  11008. }
  11009. /**
  11010. * This defines an action responsible to trigger several actions once triggered.
  11011. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11012. */
  11013. export class CombineAction extends Action {
  11014. /**
  11015. * The list of aggregated animations to run.
  11016. */
  11017. children: Action[];
  11018. /**
  11019. * Instantiate the action
  11020. * @param triggerOptions defines the trigger options
  11021. * @param children defines the list of aggregated animations to run
  11022. * @param condition defines the trigger related conditions
  11023. */
  11024. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11025. /** @hidden */
  11026. _prepare(): void;
  11027. /**
  11028. * Execute the action and executes all the aggregated actions.
  11029. */
  11030. execute(evt: ActionEvent): void;
  11031. /**
  11032. * Serializes the actions and its related information.
  11033. * @param parent defines the object to serialize in
  11034. * @returns the serialized object
  11035. */
  11036. serialize(parent: any): any;
  11037. }
  11038. /**
  11039. * This defines an action responsible to run code (external event) once triggered.
  11040. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11041. */
  11042. export class ExecuteCodeAction extends Action {
  11043. /**
  11044. * The callback function to run.
  11045. */
  11046. func: (evt: ActionEvent) => void;
  11047. /**
  11048. * Instantiate the action
  11049. * @param triggerOptions defines the trigger options
  11050. * @param func defines the callback function to run
  11051. * @param condition defines the trigger related conditions
  11052. */
  11053. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11054. /**
  11055. * Execute the action and run the attached code.
  11056. */
  11057. execute(evt: ActionEvent): void;
  11058. }
  11059. /**
  11060. * This defines an action responsible to set the parent property of the target once triggered.
  11061. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11062. */
  11063. export class SetParentAction extends Action {
  11064. private _parent;
  11065. private _target;
  11066. /**
  11067. * Instantiate the action
  11068. * @param triggerOptions defines the trigger options
  11069. * @param target defines the target containing the parent property
  11070. * @param parent defines from where the animation should start (animation frame)
  11071. * @param condition defines the trigger related conditions
  11072. */
  11073. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11074. /** @hidden */
  11075. _prepare(): void;
  11076. /**
  11077. * Execute the action and set the parent property.
  11078. */
  11079. execute(): void;
  11080. /**
  11081. * Serializes the actions and its related information.
  11082. * @param parent defines the object to serialize in
  11083. * @returns the serialized object
  11084. */
  11085. serialize(parent: any): any;
  11086. }
  11087. }
  11088. declare module "babylonjs/Actions/actionManager" {
  11089. import { Nullable } from "babylonjs/types";
  11090. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11091. import { Scene } from "babylonjs/scene";
  11092. import { IAction } from "babylonjs/Actions/action";
  11093. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11094. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11095. /**
  11096. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11097. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11098. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11099. */
  11100. export class ActionManager extends AbstractActionManager {
  11101. /**
  11102. * Nothing
  11103. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11104. */
  11105. static readonly NothingTrigger: number;
  11106. /**
  11107. * On pick
  11108. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11109. */
  11110. static readonly OnPickTrigger: number;
  11111. /**
  11112. * On left pick
  11113. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11114. */
  11115. static readonly OnLeftPickTrigger: number;
  11116. /**
  11117. * On right pick
  11118. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11119. */
  11120. static readonly OnRightPickTrigger: number;
  11121. /**
  11122. * On center pick
  11123. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11124. */
  11125. static readonly OnCenterPickTrigger: number;
  11126. /**
  11127. * On pick down
  11128. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11129. */
  11130. static readonly OnPickDownTrigger: number;
  11131. /**
  11132. * On double pick
  11133. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11134. */
  11135. static readonly OnDoublePickTrigger: number;
  11136. /**
  11137. * On pick up
  11138. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11139. */
  11140. static readonly OnPickUpTrigger: number;
  11141. /**
  11142. * On pick out.
  11143. * This trigger will only be raised if you also declared a OnPickDown
  11144. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11145. */
  11146. static readonly OnPickOutTrigger: number;
  11147. /**
  11148. * On long press
  11149. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11150. */
  11151. static readonly OnLongPressTrigger: number;
  11152. /**
  11153. * On pointer over
  11154. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11155. */
  11156. static readonly OnPointerOverTrigger: number;
  11157. /**
  11158. * On pointer out
  11159. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11160. */
  11161. static readonly OnPointerOutTrigger: number;
  11162. /**
  11163. * On every frame
  11164. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11165. */
  11166. static readonly OnEveryFrameTrigger: number;
  11167. /**
  11168. * On intersection enter
  11169. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11170. */
  11171. static readonly OnIntersectionEnterTrigger: number;
  11172. /**
  11173. * On intersection exit
  11174. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11175. */
  11176. static readonly OnIntersectionExitTrigger: number;
  11177. /**
  11178. * On key down
  11179. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11180. */
  11181. static readonly OnKeyDownTrigger: number;
  11182. /**
  11183. * On key up
  11184. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11185. */
  11186. static readonly OnKeyUpTrigger: number;
  11187. private _scene;
  11188. /**
  11189. * Creates a new action manager
  11190. * @param scene defines the hosting scene
  11191. */
  11192. constructor(scene: Scene);
  11193. /**
  11194. * Releases all associated resources
  11195. */
  11196. dispose(): void;
  11197. /**
  11198. * Gets hosting scene
  11199. * @returns the hosting scene
  11200. */
  11201. getScene(): Scene;
  11202. /**
  11203. * Does this action manager handles actions of any of the given triggers
  11204. * @param triggers defines the triggers to be tested
  11205. * @return a boolean indicating whether one (or more) of the triggers is handled
  11206. */
  11207. hasSpecificTriggers(triggers: number[]): boolean;
  11208. /**
  11209. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11210. * speed.
  11211. * @param triggerA defines the trigger to be tested
  11212. * @param triggerB defines the trigger to be tested
  11213. * @return a boolean indicating whether one (or more) of the triggers is handled
  11214. */
  11215. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11216. /**
  11217. * Does this action manager handles actions of a given trigger
  11218. * @param trigger defines the trigger to be tested
  11219. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11220. * @return whether the trigger is handled
  11221. */
  11222. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11223. /**
  11224. * Does this action manager has pointer triggers
  11225. */
  11226. readonly hasPointerTriggers: boolean;
  11227. /**
  11228. * Does this action manager has pick triggers
  11229. */
  11230. readonly hasPickTriggers: boolean;
  11231. /**
  11232. * Registers an action to this action manager
  11233. * @param action defines the action to be registered
  11234. * @return the action amended (prepared) after registration
  11235. */
  11236. registerAction(action: IAction): Nullable<IAction>;
  11237. /**
  11238. * Unregisters an action to this action manager
  11239. * @param action defines the action to be unregistered
  11240. * @return a boolean indicating whether the action has been unregistered
  11241. */
  11242. unregisterAction(action: IAction): Boolean;
  11243. /**
  11244. * Process a specific trigger
  11245. * @param trigger defines the trigger to process
  11246. * @param evt defines the event details to be processed
  11247. */
  11248. processTrigger(trigger: number, evt?: IActionEvent): void;
  11249. /** @hidden */
  11250. _getEffectiveTarget(target: any, propertyPath: string): any;
  11251. /** @hidden */
  11252. _getProperty(propertyPath: string): string;
  11253. /**
  11254. * Serialize this manager to a JSON object
  11255. * @param name defines the property name to store this manager
  11256. * @returns a JSON representation of this manager
  11257. */
  11258. serialize(name: string): any;
  11259. /**
  11260. * Creates a new ActionManager from a JSON data
  11261. * @param parsedActions defines the JSON data to read from
  11262. * @param object defines the hosting mesh
  11263. * @param scene defines the hosting scene
  11264. */
  11265. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11266. /**
  11267. * Get a trigger name by index
  11268. * @param trigger defines the trigger index
  11269. * @returns a trigger name
  11270. */
  11271. static GetTriggerName(trigger: number): string;
  11272. }
  11273. }
  11274. declare module "babylonjs/Culling/ray" {
  11275. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11276. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11277. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11278. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11279. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11280. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11281. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11282. /**
  11283. * Class representing a ray with position and direction
  11284. */
  11285. export class Ray {
  11286. /** origin point */
  11287. origin: Vector3;
  11288. /** direction */
  11289. direction: Vector3;
  11290. /** length of the ray */
  11291. length: number;
  11292. private static readonly TmpVector3;
  11293. private _tmpRay;
  11294. /**
  11295. * Creates a new ray
  11296. * @param origin origin point
  11297. * @param direction direction
  11298. * @param length length of the ray
  11299. */
  11300. constructor(
  11301. /** origin point */
  11302. origin: Vector3,
  11303. /** direction */
  11304. direction: Vector3,
  11305. /** length of the ray */
  11306. length?: number);
  11307. /**
  11308. * Checks if the ray intersects a box
  11309. * @param minimum bound of the box
  11310. * @param maximum bound of the box
  11311. * @param intersectionTreshold extra extend to be added to the box in all direction
  11312. * @returns if the box was hit
  11313. */
  11314. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11315. /**
  11316. * Checks if the ray intersects a box
  11317. * @param box the bounding box to check
  11318. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11319. * @returns if the box was hit
  11320. */
  11321. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11322. /**
  11323. * If the ray hits a sphere
  11324. * @param sphere the bounding sphere to check
  11325. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11326. * @returns true if it hits the sphere
  11327. */
  11328. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11329. /**
  11330. * If the ray hits a triange
  11331. * @param vertex0 triangle vertex
  11332. * @param vertex1 triangle vertex
  11333. * @param vertex2 triangle vertex
  11334. * @returns intersection information if hit
  11335. */
  11336. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11337. /**
  11338. * Checks if ray intersects a plane
  11339. * @param plane the plane to check
  11340. * @returns the distance away it was hit
  11341. */
  11342. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11343. /**
  11344. * Checks if ray intersects a mesh
  11345. * @param mesh the mesh to check
  11346. * @param fastCheck if only the bounding box should checked
  11347. * @returns picking info of the intersecton
  11348. */
  11349. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11350. /**
  11351. * Checks if ray intersects a mesh
  11352. * @param meshes the meshes to check
  11353. * @param fastCheck if only the bounding box should checked
  11354. * @param results array to store result in
  11355. * @returns Array of picking infos
  11356. */
  11357. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11358. private _comparePickingInfo;
  11359. private static smallnum;
  11360. private static rayl;
  11361. /**
  11362. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11363. * @param sega the first point of the segment to test the intersection against
  11364. * @param segb the second point of the segment to test the intersection against
  11365. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11366. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11367. */
  11368. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11369. /**
  11370. * Update the ray from viewport position
  11371. * @param x position
  11372. * @param y y position
  11373. * @param viewportWidth viewport width
  11374. * @param viewportHeight viewport height
  11375. * @param world world matrix
  11376. * @param view view matrix
  11377. * @param projection projection matrix
  11378. * @returns this ray updated
  11379. */
  11380. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11381. /**
  11382. * Creates a ray with origin and direction of 0,0,0
  11383. * @returns the new ray
  11384. */
  11385. static Zero(): Ray;
  11386. /**
  11387. * Creates a new ray from screen space and viewport
  11388. * @param x position
  11389. * @param y y position
  11390. * @param viewportWidth viewport width
  11391. * @param viewportHeight viewport height
  11392. * @param world world matrix
  11393. * @param view view matrix
  11394. * @param projection projection matrix
  11395. * @returns new ray
  11396. */
  11397. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11398. /**
  11399. * 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
  11400. * transformed to the given world matrix.
  11401. * @param origin The origin point
  11402. * @param end The end point
  11403. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11404. * @returns the new ray
  11405. */
  11406. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11407. /**
  11408. * Transforms a ray by a matrix
  11409. * @param ray ray to transform
  11410. * @param matrix matrix to apply
  11411. * @returns the resulting new ray
  11412. */
  11413. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11414. /**
  11415. * Transforms a ray by a matrix
  11416. * @param ray ray to transform
  11417. * @param matrix matrix to apply
  11418. * @param result ray to store result in
  11419. */
  11420. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11421. /**
  11422. * Unproject a ray from screen space to object space
  11423. * @param sourceX defines the screen space x coordinate to use
  11424. * @param sourceY defines the screen space y coordinate to use
  11425. * @param viewportWidth defines the current width of the viewport
  11426. * @param viewportHeight defines the current height of the viewport
  11427. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11428. * @param view defines the view matrix to use
  11429. * @param projection defines the projection matrix to use
  11430. */
  11431. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11432. }
  11433. /**
  11434. * Type used to define predicate used to select faces when a mesh intersection is detected
  11435. */
  11436. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11437. module "babylonjs/scene" {
  11438. interface Scene {
  11439. /** @hidden */
  11440. _tempPickingRay: Nullable<Ray>;
  11441. /** @hidden */
  11442. _cachedRayForTransform: Ray;
  11443. /** @hidden */
  11444. _pickWithRayInverseMatrix: Matrix;
  11445. /** @hidden */
  11446. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11447. /** @hidden */
  11448. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11449. }
  11450. }
  11451. }
  11452. declare module "babylonjs/sceneComponent" {
  11453. import { Scene } from "babylonjs/scene";
  11454. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11455. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11456. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11457. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11458. import { Nullable } from "babylonjs/types";
  11459. import { Camera } from "babylonjs/Cameras/camera";
  11460. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11461. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11462. import { AbstractScene } from "babylonjs/abstractScene";
  11463. /**
  11464. * Groups all the scene component constants in one place to ease maintenance.
  11465. * @hidden
  11466. */
  11467. export class SceneComponentConstants {
  11468. static readonly NAME_EFFECTLAYER: string;
  11469. static readonly NAME_LAYER: string;
  11470. static readonly NAME_LENSFLARESYSTEM: string;
  11471. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11472. static readonly NAME_PARTICLESYSTEM: string;
  11473. static readonly NAME_GAMEPAD: string;
  11474. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11475. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11476. static readonly NAME_DEPTHRENDERER: string;
  11477. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11478. static readonly NAME_SPRITE: string;
  11479. static readonly NAME_OUTLINERENDERER: string;
  11480. static readonly NAME_PROCEDURALTEXTURE: string;
  11481. static readonly NAME_SHADOWGENERATOR: string;
  11482. static readonly NAME_OCTREE: string;
  11483. static readonly NAME_PHYSICSENGINE: string;
  11484. static readonly NAME_AUDIO: string;
  11485. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11486. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11487. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11488. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11489. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11490. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11491. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11492. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11493. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11494. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11495. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11496. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11497. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11498. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11499. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11500. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11501. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11502. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11503. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11504. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11505. static readonly STEP_AFTERRENDER_AUDIO: number;
  11506. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11507. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11508. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11509. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11510. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11511. static readonly STEP_POINTERMOVE_SPRITE: number;
  11512. static readonly STEP_POINTERDOWN_SPRITE: number;
  11513. static readonly STEP_POINTERUP_SPRITE: number;
  11514. }
  11515. /**
  11516. * This represents a scene component.
  11517. *
  11518. * This is used to decouple the dependency the scene is having on the different workloads like
  11519. * layers, post processes...
  11520. */
  11521. export interface ISceneComponent {
  11522. /**
  11523. * The name of the component. Each component must have a unique name.
  11524. */
  11525. name: string;
  11526. /**
  11527. * The scene the component belongs to.
  11528. */
  11529. scene: Scene;
  11530. /**
  11531. * Register the component to one instance of a scene.
  11532. */
  11533. register(): void;
  11534. /**
  11535. * Rebuilds the elements related to this component in case of
  11536. * context lost for instance.
  11537. */
  11538. rebuild(): void;
  11539. /**
  11540. * Disposes the component and the associated ressources.
  11541. */
  11542. dispose(): void;
  11543. }
  11544. /**
  11545. * This represents a SERIALIZABLE scene component.
  11546. *
  11547. * This extends Scene Component to add Serialization methods on top.
  11548. */
  11549. export interface ISceneSerializableComponent extends ISceneComponent {
  11550. /**
  11551. * Adds all the element from the container to the scene
  11552. * @param container the container holding the elements
  11553. */
  11554. addFromContainer(container: AbstractScene): void;
  11555. /**
  11556. * Removes all the elements in the container from the scene
  11557. * @param container contains the elements to remove
  11558. */
  11559. removeFromContainer(container: AbstractScene): void;
  11560. /**
  11561. * Serializes the component data to the specified json object
  11562. * @param serializationObject The object to serialize to
  11563. */
  11564. serialize(serializationObject: any): void;
  11565. }
  11566. /**
  11567. * Strong typing of a Mesh related stage step action
  11568. */
  11569. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11570. /**
  11571. * Strong typing of a Evaluate Sub Mesh related stage step action
  11572. */
  11573. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11574. /**
  11575. * Strong typing of a Active Mesh related stage step action
  11576. */
  11577. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11578. /**
  11579. * Strong typing of a Camera related stage step action
  11580. */
  11581. export type CameraStageAction = (camera: Camera) => void;
  11582. /**
  11583. * Strong typing of a Render Target related stage step action
  11584. */
  11585. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11586. /**
  11587. * Strong typing of a RenderingGroup related stage step action
  11588. */
  11589. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11590. /**
  11591. * Strong typing of a Mesh Render related stage step action
  11592. */
  11593. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11594. /**
  11595. * Strong typing of a simple stage step action
  11596. */
  11597. export type SimpleStageAction = () => void;
  11598. /**
  11599. * Strong typing of a render target action.
  11600. */
  11601. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11602. /**
  11603. * Strong typing of a pointer move action.
  11604. */
  11605. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11606. /**
  11607. * Strong typing of a pointer up/down action.
  11608. */
  11609. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11610. /**
  11611. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11612. * @hidden
  11613. */
  11614. export class Stage<T extends Function> extends Array<{
  11615. index: number;
  11616. component: ISceneComponent;
  11617. action: T;
  11618. }> {
  11619. /**
  11620. * Hide ctor from the rest of the world.
  11621. * @param items The items to add.
  11622. */
  11623. private constructor();
  11624. /**
  11625. * Creates a new Stage.
  11626. * @returns A new instance of a Stage
  11627. */
  11628. static Create<T extends Function>(): Stage<T>;
  11629. /**
  11630. * Registers a step in an ordered way in the targeted stage.
  11631. * @param index Defines the position to register the step in
  11632. * @param component Defines the component attached to the step
  11633. * @param action Defines the action to launch during the step
  11634. */
  11635. registerStep(index: number, component: ISceneComponent, action: T): void;
  11636. /**
  11637. * Clears all the steps from the stage.
  11638. */
  11639. clear(): void;
  11640. }
  11641. }
  11642. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11643. import { Nullable } from "babylonjs/types";
  11644. import { Observable } from "babylonjs/Misc/observable";
  11645. import { Scene } from "babylonjs/scene";
  11646. import { Sprite } from "babylonjs/Sprites/sprite";
  11647. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11648. import { Ray } from "babylonjs/Culling/ray";
  11649. import { Camera } from "babylonjs/Cameras/camera";
  11650. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11651. import { ISceneComponent } from "babylonjs/sceneComponent";
  11652. module "babylonjs/scene" {
  11653. interface Scene {
  11654. /** @hidden */
  11655. _pointerOverSprite: Nullable<Sprite>;
  11656. /** @hidden */
  11657. _pickedDownSprite: Nullable<Sprite>;
  11658. /** @hidden */
  11659. _tempSpritePickingRay: Nullable<Ray>;
  11660. /**
  11661. * All of the sprite managers added to this scene
  11662. * @see http://doc.babylonjs.com/babylon101/sprites
  11663. */
  11664. spriteManagers: Array<ISpriteManager>;
  11665. /**
  11666. * An event triggered when sprites rendering is about to start
  11667. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11668. */
  11669. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11670. /**
  11671. * An event triggered when sprites rendering is done
  11672. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11673. */
  11674. onAfterSpritesRenderingObservable: Observable<Scene>;
  11675. /** @hidden */
  11676. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11677. /** Launch a ray to try to pick a sprite in the scene
  11678. * @param x position on screen
  11679. * @param y position on screen
  11680. * @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
  11681. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11682. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11683. * @returns a PickingInfo
  11684. */
  11685. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11686. /** Use the given ray to pick a sprite in the scene
  11687. * @param ray The ray (in world space) to use to pick meshes
  11688. * @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
  11689. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11690. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11691. * @returns a PickingInfo
  11692. */
  11693. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11694. /**
  11695. * Force the sprite under the pointer
  11696. * @param sprite defines the sprite to use
  11697. */
  11698. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11699. /**
  11700. * Gets the sprite under the pointer
  11701. * @returns a Sprite or null if no sprite is under the pointer
  11702. */
  11703. getPointerOverSprite(): Nullable<Sprite>;
  11704. }
  11705. }
  11706. /**
  11707. * Defines the sprite scene component responsible to manage sprites
  11708. * in a given scene.
  11709. */
  11710. export class SpriteSceneComponent implements ISceneComponent {
  11711. /**
  11712. * The component name helpfull to identify the component in the list of scene components.
  11713. */
  11714. readonly name: string;
  11715. /**
  11716. * The scene the component belongs to.
  11717. */
  11718. scene: Scene;
  11719. /** @hidden */
  11720. private _spritePredicate;
  11721. /**
  11722. * Creates a new instance of the component for the given scene
  11723. * @param scene Defines the scene to register the component in
  11724. */
  11725. constructor(scene: Scene);
  11726. /**
  11727. * Registers the component in a given scene
  11728. */
  11729. register(): void;
  11730. /**
  11731. * Rebuilds the elements related to this component in case of
  11732. * context lost for instance.
  11733. */
  11734. rebuild(): void;
  11735. /**
  11736. * Disposes the component and the associated ressources.
  11737. */
  11738. dispose(): void;
  11739. private _pickSpriteButKeepRay;
  11740. private _pointerMove;
  11741. private _pointerDown;
  11742. private _pointerUp;
  11743. }
  11744. }
  11745. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11746. /** @hidden */
  11747. export var fogFragmentDeclaration: {
  11748. name: string;
  11749. shader: string;
  11750. };
  11751. }
  11752. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11753. /** @hidden */
  11754. export var fogFragment: {
  11755. name: string;
  11756. shader: string;
  11757. };
  11758. }
  11759. declare module "babylonjs/Shaders/sprites.fragment" {
  11760. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11761. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11762. /** @hidden */
  11763. export var spritesPixelShader: {
  11764. name: string;
  11765. shader: string;
  11766. };
  11767. }
  11768. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11769. /** @hidden */
  11770. export var fogVertexDeclaration: {
  11771. name: string;
  11772. shader: string;
  11773. };
  11774. }
  11775. declare module "babylonjs/Shaders/sprites.vertex" {
  11776. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11777. /** @hidden */
  11778. export var spritesVertexShader: {
  11779. name: string;
  11780. shader: string;
  11781. };
  11782. }
  11783. declare module "babylonjs/Sprites/spriteManager" {
  11784. import { IDisposable, Scene } from "babylonjs/scene";
  11785. import { Nullable } from "babylonjs/types";
  11786. import { Observable } from "babylonjs/Misc/observable";
  11787. import { Sprite } from "babylonjs/Sprites/sprite";
  11788. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11789. import { Camera } from "babylonjs/Cameras/camera";
  11790. import { Texture } from "babylonjs/Materials/Textures/texture";
  11791. import "babylonjs/Shaders/sprites.fragment";
  11792. import "babylonjs/Shaders/sprites.vertex";
  11793. import { Ray } from "babylonjs/Culling/ray";
  11794. /**
  11795. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11796. */
  11797. export interface ISpriteManager extends IDisposable {
  11798. /**
  11799. * Restricts the camera to viewing objects with the same layerMask.
  11800. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11801. */
  11802. layerMask: number;
  11803. /**
  11804. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11805. */
  11806. isPickable: boolean;
  11807. /**
  11808. * Specifies the rendering group id for this mesh (0 by default)
  11809. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11810. */
  11811. renderingGroupId: number;
  11812. /**
  11813. * Defines the list of sprites managed by the manager.
  11814. */
  11815. sprites: Array<Sprite>;
  11816. /**
  11817. * Tests the intersection of a sprite with a specific ray.
  11818. * @param ray The ray we are sending to test the collision
  11819. * @param camera The camera space we are sending rays in
  11820. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11821. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11822. * @returns picking info or null.
  11823. */
  11824. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11825. /**
  11826. * Renders the list of sprites on screen.
  11827. */
  11828. render(): void;
  11829. }
  11830. /**
  11831. * Class used to manage multiple sprites on the same spritesheet
  11832. * @see http://doc.babylonjs.com/babylon101/sprites
  11833. */
  11834. export class SpriteManager implements ISpriteManager {
  11835. /** defines the manager's name */
  11836. name: string;
  11837. /** Gets the list of sprites */
  11838. sprites: Sprite[];
  11839. /** Gets or sets the rendering group id (0 by default) */
  11840. renderingGroupId: number;
  11841. /** Gets or sets camera layer mask */
  11842. layerMask: number;
  11843. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11844. fogEnabled: boolean;
  11845. /** Gets or sets a boolean indicating if the sprites are pickable */
  11846. isPickable: boolean;
  11847. /** Defines the default width of a cell in the spritesheet */
  11848. cellWidth: number;
  11849. /** Defines the default height of a cell in the spritesheet */
  11850. cellHeight: number;
  11851. /**
  11852. * An event triggered when the manager is disposed.
  11853. */
  11854. onDisposeObservable: Observable<SpriteManager>;
  11855. private _onDisposeObserver;
  11856. /**
  11857. * Callback called when the manager is disposed
  11858. */
  11859. onDispose: () => void;
  11860. private _capacity;
  11861. private _spriteTexture;
  11862. private _epsilon;
  11863. private _scene;
  11864. private _vertexData;
  11865. private _buffer;
  11866. private _vertexBuffers;
  11867. private _indexBuffer;
  11868. private _effectBase;
  11869. private _effectFog;
  11870. /**
  11871. * Gets or sets the spritesheet texture
  11872. */
  11873. texture: Texture;
  11874. /**
  11875. * Creates a new sprite manager
  11876. * @param name defines the manager's name
  11877. * @param imgUrl defines the sprite sheet url
  11878. * @param capacity defines the maximum allowed number of sprites
  11879. * @param cellSize defines the size of a sprite cell
  11880. * @param scene defines the hosting scene
  11881. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11882. * @param samplingMode defines the smapling mode to use with spritesheet
  11883. */
  11884. constructor(
  11885. /** defines the manager's name */
  11886. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11887. private _appendSpriteVertex;
  11888. /**
  11889. * Intersects the sprites with a ray
  11890. * @param ray defines the ray to intersect with
  11891. * @param camera defines the current active camera
  11892. * @param predicate defines a predicate used to select candidate sprites
  11893. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11894. * @returns null if no hit or a PickingInfo
  11895. */
  11896. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11897. /**
  11898. * Render all child sprites
  11899. */
  11900. render(): void;
  11901. /**
  11902. * Release associated resources
  11903. */
  11904. dispose(): void;
  11905. }
  11906. }
  11907. declare module "babylonjs/Sprites/sprite" {
  11908. import { Vector3, Color4 } from "babylonjs/Maths/math";
  11909. import { Nullable } from "babylonjs/types";
  11910. import { ActionManager } from "babylonjs/Actions/actionManager";
  11911. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11912. /**
  11913. * Class used to represent a sprite
  11914. * @see http://doc.babylonjs.com/babylon101/sprites
  11915. */
  11916. export class Sprite {
  11917. /** defines the name */
  11918. name: string;
  11919. /** Gets or sets the current world position */
  11920. position: Vector3;
  11921. /** Gets or sets the main color */
  11922. color: Color4;
  11923. /** Gets or sets the width */
  11924. width: number;
  11925. /** Gets or sets the height */
  11926. height: number;
  11927. /** Gets or sets rotation angle */
  11928. angle: number;
  11929. /** Gets or sets the cell index in the sprite sheet */
  11930. cellIndex: number;
  11931. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11932. invertU: number;
  11933. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11934. invertV: number;
  11935. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11936. disposeWhenFinishedAnimating: boolean;
  11937. /** Gets the list of attached animations */
  11938. animations: Animation[];
  11939. /** Gets or sets a boolean indicating if the sprite can be picked */
  11940. isPickable: boolean;
  11941. /**
  11942. * Gets or sets the associated action manager
  11943. */
  11944. actionManager: Nullable<ActionManager>;
  11945. private _animationStarted;
  11946. private _loopAnimation;
  11947. private _fromIndex;
  11948. private _toIndex;
  11949. private _delay;
  11950. private _direction;
  11951. private _manager;
  11952. private _time;
  11953. private _onAnimationEnd;
  11954. /**
  11955. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11956. */
  11957. isVisible: boolean;
  11958. /**
  11959. * Gets or sets the sprite size
  11960. */
  11961. size: number;
  11962. /**
  11963. * Creates a new Sprite
  11964. * @param name defines the name
  11965. * @param manager defines the manager
  11966. */
  11967. constructor(
  11968. /** defines the name */
  11969. name: string, manager: ISpriteManager);
  11970. /**
  11971. * Starts an animation
  11972. * @param from defines the initial key
  11973. * @param to defines the end key
  11974. * @param loop defines if the animation must loop
  11975. * @param delay defines the start delay (in ms)
  11976. * @param onAnimationEnd defines a callback to call when animation ends
  11977. */
  11978. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11979. /** Stops current animation (if any) */
  11980. stopAnimation(): void;
  11981. /** @hidden */
  11982. _animate(deltaTime: number): void;
  11983. /** Release associated resources */
  11984. dispose(): void;
  11985. }
  11986. }
  11987. declare module "babylonjs/Collisions/pickingInfo" {
  11988. import { Nullable } from "babylonjs/types";
  11989. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  11990. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11991. import { Sprite } from "babylonjs/Sprites/sprite";
  11992. import { Ray } from "babylonjs/Culling/ray";
  11993. /**
  11994. * Information about the result of picking within a scene
  11995. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11996. */
  11997. export class PickingInfo {
  11998. /** @hidden */
  11999. _pickingUnavailable: boolean;
  12000. /**
  12001. * If the pick collided with an object
  12002. */
  12003. hit: boolean;
  12004. /**
  12005. * Distance away where the pick collided
  12006. */
  12007. distance: number;
  12008. /**
  12009. * The location of pick collision
  12010. */
  12011. pickedPoint: Nullable<Vector3>;
  12012. /**
  12013. * The mesh corresponding the the pick collision
  12014. */
  12015. pickedMesh: Nullable<AbstractMesh>;
  12016. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  12017. bu: number;
  12018. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  12019. bv: number;
  12020. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12021. faceId: number;
  12022. /** Id of the the submesh that was picked */
  12023. subMeshId: number;
  12024. /** If a sprite was picked, this will be the sprite the pick collided with */
  12025. pickedSprite: Nullable<Sprite>;
  12026. /**
  12027. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12028. */
  12029. originMesh: Nullable<AbstractMesh>;
  12030. /**
  12031. * The ray that was used to perform the picking.
  12032. */
  12033. ray: Nullable<Ray>;
  12034. /**
  12035. * Gets the normal correspodning to the face the pick collided with
  12036. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12037. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12038. * @returns The normal correspodning to the face the pick collided with
  12039. */
  12040. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12041. /**
  12042. * Gets the texture coordinates of where the pick occured
  12043. * @returns the vector containing the coordnates of the texture
  12044. */
  12045. getTextureCoordinates(): Nullable<Vector2>;
  12046. }
  12047. }
  12048. declare module "babylonjs/Events/pointerEvents" {
  12049. import { Nullable } from "babylonjs/types";
  12050. import { Vector2 } from "babylonjs/Maths/math";
  12051. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12052. import { Ray } from "babylonjs/Culling/ray";
  12053. /**
  12054. * Gather the list of pointer event types as constants.
  12055. */
  12056. export class PointerEventTypes {
  12057. /**
  12058. * 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.
  12059. */
  12060. static readonly POINTERDOWN: number;
  12061. /**
  12062. * The pointerup event is fired when a pointer is no longer active.
  12063. */
  12064. static readonly POINTERUP: number;
  12065. /**
  12066. * The pointermove event is fired when a pointer changes coordinates.
  12067. */
  12068. static readonly POINTERMOVE: number;
  12069. /**
  12070. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12071. */
  12072. static readonly POINTERWHEEL: number;
  12073. /**
  12074. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12075. */
  12076. static readonly POINTERPICK: number;
  12077. /**
  12078. * The pointertap event is fired when a the object has been touched and released without drag.
  12079. */
  12080. static readonly POINTERTAP: number;
  12081. /**
  12082. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12083. */
  12084. static readonly POINTERDOUBLETAP: number;
  12085. }
  12086. /**
  12087. * Base class of pointer info types.
  12088. */
  12089. export class PointerInfoBase {
  12090. /**
  12091. * Defines the type of event (PointerEventTypes)
  12092. */
  12093. type: number;
  12094. /**
  12095. * Defines the related dom event
  12096. */
  12097. event: PointerEvent | MouseWheelEvent;
  12098. /**
  12099. * Instantiates the base class of pointers info.
  12100. * @param type Defines the type of event (PointerEventTypes)
  12101. * @param event Defines the related dom event
  12102. */
  12103. constructor(
  12104. /**
  12105. * Defines the type of event (PointerEventTypes)
  12106. */
  12107. type: number,
  12108. /**
  12109. * Defines the related dom event
  12110. */
  12111. event: PointerEvent | MouseWheelEvent);
  12112. }
  12113. /**
  12114. * This class is used to store pointer related info for the onPrePointerObservable event.
  12115. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12116. */
  12117. export class PointerInfoPre extends PointerInfoBase {
  12118. /**
  12119. * Ray from a pointer if availible (eg. 6dof controller)
  12120. */
  12121. ray: Nullable<Ray>;
  12122. /**
  12123. * Defines the local position of the pointer on the canvas.
  12124. */
  12125. localPosition: Vector2;
  12126. /**
  12127. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12128. */
  12129. skipOnPointerObservable: boolean;
  12130. /**
  12131. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12132. * @param type Defines the type of event (PointerEventTypes)
  12133. * @param event Defines the related dom event
  12134. * @param localX Defines the local x coordinates of the pointer when the event occured
  12135. * @param localY Defines the local y coordinates of the pointer when the event occured
  12136. */
  12137. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12138. }
  12139. /**
  12140. * This type contains all the data related to a pointer event in Babylon.js.
  12141. * 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.
  12142. */
  12143. export class PointerInfo extends PointerInfoBase {
  12144. /**
  12145. * Defines the picking info associated to the info (if any)\
  12146. */
  12147. pickInfo: Nullable<PickingInfo>;
  12148. /**
  12149. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12150. * @param type Defines the type of event (PointerEventTypes)
  12151. * @param event Defines the related dom event
  12152. * @param pickInfo Defines the picking info associated to the info (if any)\
  12153. */
  12154. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12155. /**
  12156. * Defines the picking info associated to the info (if any)\
  12157. */
  12158. pickInfo: Nullable<PickingInfo>);
  12159. }
  12160. /**
  12161. * Data relating to a touch event on the screen.
  12162. */
  12163. export interface PointerTouch {
  12164. /**
  12165. * X coordinate of touch.
  12166. */
  12167. x: number;
  12168. /**
  12169. * Y coordinate of touch.
  12170. */
  12171. y: number;
  12172. /**
  12173. * Id of touch. Unique for each finger.
  12174. */
  12175. pointerId: number;
  12176. /**
  12177. * Event type passed from DOM.
  12178. */
  12179. type: any;
  12180. }
  12181. }
  12182. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12183. import { Nullable } from "babylonjs/types";
  12184. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12185. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12186. /**
  12187. * Manage the mouse inputs to control the movement of a free camera.
  12188. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12189. */
  12190. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12191. /**
  12192. * Define if touch is enabled in the mouse input
  12193. */
  12194. touchEnabled: boolean;
  12195. /**
  12196. * Defines the camera the input is attached to.
  12197. */
  12198. camera: FreeCamera;
  12199. /**
  12200. * Defines the buttons associated with the input to handle camera move.
  12201. */
  12202. buttons: number[];
  12203. /**
  12204. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12205. */
  12206. angularSensibility: number;
  12207. private _pointerInput;
  12208. private _onMouseMove;
  12209. private _observer;
  12210. private previousPosition;
  12211. /**
  12212. * Manage the mouse inputs to control the movement of a free camera.
  12213. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12214. * @param touchEnabled Defines if touch is enabled or not
  12215. */
  12216. constructor(
  12217. /**
  12218. * Define if touch is enabled in the mouse input
  12219. */
  12220. touchEnabled?: boolean);
  12221. /**
  12222. * Attach the input controls to a specific dom element to get the input from.
  12223. * @param element Defines the element the controls should be listened from
  12224. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12225. */
  12226. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12227. /**
  12228. * Called on JS contextmenu event.
  12229. * Override this method to provide functionality.
  12230. */
  12231. protected onContextMenu(evt: PointerEvent): void;
  12232. /**
  12233. * Detach the current controls from the specified dom element.
  12234. * @param element Defines the element to stop listening the inputs from
  12235. */
  12236. detachControl(element: Nullable<HTMLElement>): void;
  12237. /**
  12238. * Gets the class name of the current intput.
  12239. * @returns the class name
  12240. */
  12241. getClassName(): string;
  12242. /**
  12243. * Get the friendly name associated with the input class.
  12244. * @returns the input friendly name
  12245. */
  12246. getSimpleName(): string;
  12247. }
  12248. }
  12249. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12250. import { Nullable } from "babylonjs/types";
  12251. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12252. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12253. /**
  12254. * Manage the touch inputs to control the movement of a free camera.
  12255. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12256. */
  12257. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12258. /**
  12259. * Defines the camera the input is attached to.
  12260. */
  12261. camera: FreeCamera;
  12262. /**
  12263. * Defines the touch sensibility for rotation.
  12264. * The higher the faster.
  12265. */
  12266. touchAngularSensibility: number;
  12267. /**
  12268. * Defines the touch sensibility for move.
  12269. * The higher the faster.
  12270. */
  12271. touchMoveSensibility: number;
  12272. private _offsetX;
  12273. private _offsetY;
  12274. private _pointerPressed;
  12275. private _pointerInput;
  12276. private _observer;
  12277. private _onLostFocus;
  12278. /**
  12279. * Attach the input controls to a specific dom element to get the input from.
  12280. * @param element Defines the element the controls should be listened from
  12281. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12282. */
  12283. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12284. /**
  12285. * Detach the current controls from the specified dom element.
  12286. * @param element Defines the element to stop listening the inputs from
  12287. */
  12288. detachControl(element: Nullable<HTMLElement>): void;
  12289. /**
  12290. * Update the current camera state depending on the inputs that have been used this frame.
  12291. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12292. */
  12293. checkInputs(): void;
  12294. /**
  12295. * Gets the class name of the current intput.
  12296. * @returns the class name
  12297. */
  12298. getClassName(): string;
  12299. /**
  12300. * Get the friendly name associated with the input class.
  12301. * @returns the input friendly name
  12302. */
  12303. getSimpleName(): string;
  12304. }
  12305. }
  12306. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12307. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12308. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12309. /**
  12310. * Default Inputs manager for the FreeCamera.
  12311. * It groups all the default supported inputs for ease of use.
  12312. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12313. */
  12314. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12315. /**
  12316. * Instantiates a new FreeCameraInputsManager.
  12317. * @param camera Defines the camera the inputs belong to
  12318. */
  12319. constructor(camera: FreeCamera);
  12320. /**
  12321. * Add keyboard input support to the input manager.
  12322. * @returns the current input manager
  12323. */
  12324. addKeyboard(): FreeCameraInputsManager;
  12325. /**
  12326. * Add mouse input support to the input manager.
  12327. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12328. * @returns the current input manager
  12329. */
  12330. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12331. /**
  12332. * Add touch input support to the input manager.
  12333. * @returns the current input manager
  12334. */
  12335. addTouch(): FreeCameraInputsManager;
  12336. }
  12337. }
  12338. declare module "babylonjs/Cameras/freeCamera" {
  12339. import { Vector3 } from "babylonjs/Maths/math";
  12340. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12341. import { Scene } from "babylonjs/scene";
  12342. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12343. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12344. /**
  12345. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12346. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12347. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12348. */
  12349. export class FreeCamera extends TargetCamera {
  12350. /**
  12351. * Define the collision ellipsoid of the camera.
  12352. * This is helpful to simulate a camera body like the player body around the camera
  12353. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12354. */
  12355. ellipsoid: Vector3;
  12356. /**
  12357. * Define an offset for the position of the ellipsoid around the camera.
  12358. * This can be helpful to determine the center of the body near the gravity center of the body
  12359. * instead of its head.
  12360. */
  12361. ellipsoidOffset: Vector3;
  12362. /**
  12363. * Enable or disable collisions of the camera with the rest of the scene objects.
  12364. */
  12365. checkCollisions: boolean;
  12366. /**
  12367. * Enable or disable gravity on the camera.
  12368. */
  12369. applyGravity: boolean;
  12370. /**
  12371. * Define the input manager associated to the camera.
  12372. */
  12373. inputs: FreeCameraInputsManager;
  12374. /**
  12375. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12376. * Higher values reduce sensitivity.
  12377. */
  12378. /**
  12379. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12380. * Higher values reduce sensitivity.
  12381. */
  12382. angularSensibility: number;
  12383. /**
  12384. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12385. */
  12386. keysUp: number[];
  12387. /**
  12388. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12389. */
  12390. keysDown: number[];
  12391. /**
  12392. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12393. */
  12394. keysLeft: number[];
  12395. /**
  12396. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12397. */
  12398. keysRight: number[];
  12399. /**
  12400. * Event raised when the camera collide with a mesh in the scene.
  12401. */
  12402. onCollide: (collidedMesh: AbstractMesh) => void;
  12403. private _collider;
  12404. private _needMoveForGravity;
  12405. private _oldPosition;
  12406. private _diffPosition;
  12407. private _newPosition;
  12408. /** @hidden */
  12409. _localDirection: Vector3;
  12410. /** @hidden */
  12411. _transformedDirection: Vector3;
  12412. /**
  12413. * Instantiates a Free Camera.
  12414. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12415. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12416. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12417. * @param name Define the name of the camera in the scene
  12418. * @param position Define the start position of the camera in the scene
  12419. * @param scene Define the scene the camera belongs to
  12420. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12421. */
  12422. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12423. /**
  12424. * Attached controls to the current camera.
  12425. * @param element Defines the element the controls should be listened from
  12426. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12427. */
  12428. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12429. /**
  12430. * Detach the current controls from the camera.
  12431. * The camera will stop reacting to inputs.
  12432. * @param element Defines the element to stop listening the inputs from
  12433. */
  12434. detachControl(element: HTMLElement): void;
  12435. private _collisionMask;
  12436. /**
  12437. * Define a collision mask to limit the list of object the camera can collide with
  12438. */
  12439. collisionMask: number;
  12440. /** @hidden */
  12441. _collideWithWorld(displacement: Vector3): void;
  12442. private _onCollisionPositionChange;
  12443. /** @hidden */
  12444. _checkInputs(): void;
  12445. /** @hidden */
  12446. _decideIfNeedsToMove(): boolean;
  12447. /** @hidden */
  12448. _updatePosition(): void;
  12449. /**
  12450. * Destroy the camera and release the current resources hold by it.
  12451. */
  12452. dispose(): void;
  12453. /**
  12454. * Gets the current object class name.
  12455. * @return the class name
  12456. */
  12457. getClassName(): string;
  12458. }
  12459. }
  12460. declare module "babylonjs/Gamepads/gamepad" {
  12461. import { Observable } from "babylonjs/Misc/observable";
  12462. /**
  12463. * Represents a gamepad control stick position
  12464. */
  12465. export class StickValues {
  12466. /**
  12467. * The x component of the control stick
  12468. */
  12469. x: number;
  12470. /**
  12471. * The y component of the control stick
  12472. */
  12473. y: number;
  12474. /**
  12475. * Initializes the gamepad x and y control stick values
  12476. * @param x The x component of the gamepad control stick value
  12477. * @param y The y component of the gamepad control stick value
  12478. */
  12479. constructor(
  12480. /**
  12481. * The x component of the control stick
  12482. */
  12483. x: number,
  12484. /**
  12485. * The y component of the control stick
  12486. */
  12487. y: number);
  12488. }
  12489. /**
  12490. * An interface which manages callbacks for gamepad button changes
  12491. */
  12492. export interface GamepadButtonChanges {
  12493. /**
  12494. * Called when a gamepad has been changed
  12495. */
  12496. changed: boolean;
  12497. /**
  12498. * Called when a gamepad press event has been triggered
  12499. */
  12500. pressChanged: boolean;
  12501. /**
  12502. * Called when a touch event has been triggered
  12503. */
  12504. touchChanged: boolean;
  12505. /**
  12506. * Called when a value has changed
  12507. */
  12508. valueChanged: boolean;
  12509. }
  12510. /**
  12511. * Represents a gamepad
  12512. */
  12513. export class Gamepad {
  12514. /**
  12515. * The id of the gamepad
  12516. */
  12517. id: string;
  12518. /**
  12519. * The index of the gamepad
  12520. */
  12521. index: number;
  12522. /**
  12523. * The browser gamepad
  12524. */
  12525. browserGamepad: any;
  12526. /**
  12527. * Specifies what type of gamepad this represents
  12528. */
  12529. type: number;
  12530. private _leftStick;
  12531. private _rightStick;
  12532. /** @hidden */
  12533. _isConnected: boolean;
  12534. private _leftStickAxisX;
  12535. private _leftStickAxisY;
  12536. private _rightStickAxisX;
  12537. private _rightStickAxisY;
  12538. /**
  12539. * Triggered when the left control stick has been changed
  12540. */
  12541. private _onleftstickchanged;
  12542. /**
  12543. * Triggered when the right control stick has been changed
  12544. */
  12545. private _onrightstickchanged;
  12546. /**
  12547. * Represents a gamepad controller
  12548. */
  12549. static GAMEPAD: number;
  12550. /**
  12551. * Represents a generic controller
  12552. */
  12553. static GENERIC: number;
  12554. /**
  12555. * Represents an XBox controller
  12556. */
  12557. static XBOX: number;
  12558. /**
  12559. * Represents a pose-enabled controller
  12560. */
  12561. static POSE_ENABLED: number;
  12562. /**
  12563. * Specifies whether the left control stick should be Y-inverted
  12564. */
  12565. protected _invertLeftStickY: boolean;
  12566. /**
  12567. * Specifies if the gamepad has been connected
  12568. */
  12569. readonly isConnected: boolean;
  12570. /**
  12571. * Initializes the gamepad
  12572. * @param id The id of the gamepad
  12573. * @param index The index of the gamepad
  12574. * @param browserGamepad The browser gamepad
  12575. * @param leftStickX The x component of the left joystick
  12576. * @param leftStickY The y component of the left joystick
  12577. * @param rightStickX The x component of the right joystick
  12578. * @param rightStickY The y component of the right joystick
  12579. */
  12580. constructor(
  12581. /**
  12582. * The id of the gamepad
  12583. */
  12584. id: string,
  12585. /**
  12586. * The index of the gamepad
  12587. */
  12588. index: number,
  12589. /**
  12590. * The browser gamepad
  12591. */
  12592. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12593. /**
  12594. * Callback triggered when the left joystick has changed
  12595. * @param callback
  12596. */
  12597. onleftstickchanged(callback: (values: StickValues) => void): void;
  12598. /**
  12599. * Callback triggered when the right joystick has changed
  12600. * @param callback
  12601. */
  12602. onrightstickchanged(callback: (values: StickValues) => void): void;
  12603. /**
  12604. * Gets the left joystick
  12605. */
  12606. /**
  12607. * Sets the left joystick values
  12608. */
  12609. leftStick: StickValues;
  12610. /**
  12611. * Gets the right joystick
  12612. */
  12613. /**
  12614. * Sets the right joystick value
  12615. */
  12616. rightStick: StickValues;
  12617. /**
  12618. * Updates the gamepad joystick positions
  12619. */
  12620. update(): void;
  12621. /**
  12622. * Disposes the gamepad
  12623. */
  12624. dispose(): void;
  12625. }
  12626. /**
  12627. * Represents a generic gamepad
  12628. */
  12629. export class GenericPad extends Gamepad {
  12630. private _buttons;
  12631. private _onbuttondown;
  12632. private _onbuttonup;
  12633. /**
  12634. * Observable triggered when a button has been pressed
  12635. */
  12636. onButtonDownObservable: Observable<number>;
  12637. /**
  12638. * Observable triggered when a button has been released
  12639. */
  12640. onButtonUpObservable: Observable<number>;
  12641. /**
  12642. * Callback triggered when a button has been pressed
  12643. * @param callback Called when a button has been pressed
  12644. */
  12645. onbuttondown(callback: (buttonPressed: number) => void): void;
  12646. /**
  12647. * Callback triggered when a button has been released
  12648. * @param callback Called when a button has been released
  12649. */
  12650. onbuttonup(callback: (buttonReleased: number) => void): void;
  12651. /**
  12652. * Initializes the generic gamepad
  12653. * @param id The id of the generic gamepad
  12654. * @param index The index of the generic gamepad
  12655. * @param browserGamepad The browser gamepad
  12656. */
  12657. constructor(id: string, index: number, browserGamepad: any);
  12658. private _setButtonValue;
  12659. /**
  12660. * Updates the generic gamepad
  12661. */
  12662. update(): void;
  12663. /**
  12664. * Disposes the generic gamepad
  12665. */
  12666. dispose(): void;
  12667. }
  12668. }
  12669. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12670. import { Observable } from "babylonjs/Misc/observable";
  12671. import { Nullable } from "babylonjs/types";
  12672. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12673. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12674. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12675. import { Ray } from "babylonjs/Culling/ray";
  12676. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12677. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12678. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12679. /**
  12680. * Defines the types of pose enabled controllers that are supported
  12681. */
  12682. export enum PoseEnabledControllerType {
  12683. /**
  12684. * HTC Vive
  12685. */
  12686. VIVE = 0,
  12687. /**
  12688. * Oculus Rift
  12689. */
  12690. OCULUS = 1,
  12691. /**
  12692. * Windows mixed reality
  12693. */
  12694. WINDOWS = 2,
  12695. /**
  12696. * Samsung gear VR
  12697. */
  12698. GEAR_VR = 3,
  12699. /**
  12700. * Google Daydream
  12701. */
  12702. DAYDREAM = 4,
  12703. /**
  12704. * Generic
  12705. */
  12706. GENERIC = 5
  12707. }
  12708. /**
  12709. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12710. */
  12711. export interface MutableGamepadButton {
  12712. /**
  12713. * Value of the button/trigger
  12714. */
  12715. value: number;
  12716. /**
  12717. * If the button/trigger is currently touched
  12718. */
  12719. touched: boolean;
  12720. /**
  12721. * If the button/trigger is currently pressed
  12722. */
  12723. pressed: boolean;
  12724. }
  12725. /**
  12726. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12727. * @hidden
  12728. */
  12729. export interface ExtendedGamepadButton extends GamepadButton {
  12730. /**
  12731. * If the button/trigger is currently pressed
  12732. */
  12733. readonly pressed: boolean;
  12734. /**
  12735. * If the button/trigger is currently touched
  12736. */
  12737. readonly touched: boolean;
  12738. /**
  12739. * Value of the button/trigger
  12740. */
  12741. readonly value: number;
  12742. }
  12743. /** @hidden */
  12744. export interface _GamePadFactory {
  12745. /**
  12746. * Returns wether or not the current gamepad can be created for this type of controller.
  12747. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12748. * @returns true if it can be created, otherwise false
  12749. */
  12750. canCreate(gamepadInfo: any): boolean;
  12751. /**
  12752. * Creates a new instance of the Gamepad.
  12753. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12754. * @returns the new gamepad instance
  12755. */
  12756. create(gamepadInfo: any): Gamepad;
  12757. }
  12758. /**
  12759. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12760. */
  12761. export class PoseEnabledControllerHelper {
  12762. /** @hidden */
  12763. static _ControllerFactories: _GamePadFactory[];
  12764. /** @hidden */
  12765. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12766. /**
  12767. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12768. * @param vrGamepad the gamepad to initialized
  12769. * @returns a vr controller of the type the gamepad identified as
  12770. */
  12771. static InitiateController(vrGamepad: any): Gamepad;
  12772. }
  12773. /**
  12774. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12775. */
  12776. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12777. private _deviceRoomPosition;
  12778. private _deviceRoomRotationQuaternion;
  12779. /**
  12780. * The device position in babylon space
  12781. */
  12782. devicePosition: Vector3;
  12783. /**
  12784. * The device rotation in babylon space
  12785. */
  12786. deviceRotationQuaternion: Quaternion;
  12787. /**
  12788. * The scale factor of the device in babylon space
  12789. */
  12790. deviceScaleFactor: number;
  12791. /**
  12792. * (Likely devicePosition should be used instead) The device position in its room space
  12793. */
  12794. position: Vector3;
  12795. /**
  12796. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12797. */
  12798. rotationQuaternion: Quaternion;
  12799. /**
  12800. * The type of controller (Eg. Windows mixed reality)
  12801. */
  12802. controllerType: PoseEnabledControllerType;
  12803. protected _calculatedPosition: Vector3;
  12804. private _calculatedRotation;
  12805. /**
  12806. * The raw pose from the device
  12807. */
  12808. rawPose: DevicePose;
  12809. private _trackPosition;
  12810. private _maxRotationDistFromHeadset;
  12811. private _draggedRoomRotation;
  12812. /**
  12813. * @hidden
  12814. */
  12815. _disableTrackPosition(fixedPosition: Vector3): void;
  12816. /**
  12817. * Internal, the mesh attached to the controller
  12818. * @hidden
  12819. */
  12820. _mesh: Nullable<AbstractMesh>;
  12821. private _poseControlledCamera;
  12822. private _leftHandSystemQuaternion;
  12823. /**
  12824. * Internal, matrix used to convert room space to babylon space
  12825. * @hidden
  12826. */
  12827. _deviceToWorld: Matrix;
  12828. /**
  12829. * Node to be used when casting a ray from the controller
  12830. * @hidden
  12831. */
  12832. _pointingPoseNode: Nullable<TransformNode>;
  12833. /**
  12834. * Name of the child mesh that can be used to cast a ray from the controller
  12835. */
  12836. static readonly POINTING_POSE: string;
  12837. /**
  12838. * Creates a new PoseEnabledController from a gamepad
  12839. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12840. */
  12841. constructor(browserGamepad: any);
  12842. private _workingMatrix;
  12843. /**
  12844. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12845. */
  12846. update(): void;
  12847. /**
  12848. * Updates only the pose device and mesh without doing any button event checking
  12849. */
  12850. protected _updatePoseAndMesh(): void;
  12851. /**
  12852. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12853. * @param poseData raw pose fromthe device
  12854. */
  12855. updateFromDevice(poseData: DevicePose): void;
  12856. /**
  12857. * @hidden
  12858. */
  12859. _meshAttachedObservable: Observable<AbstractMesh>;
  12860. /**
  12861. * Attaches a mesh to the controller
  12862. * @param mesh the mesh to be attached
  12863. */
  12864. attachToMesh(mesh: AbstractMesh): void;
  12865. /**
  12866. * Attaches the controllers mesh to a camera
  12867. * @param camera the camera the mesh should be attached to
  12868. */
  12869. attachToPoseControlledCamera(camera: TargetCamera): void;
  12870. /**
  12871. * Disposes of the controller
  12872. */
  12873. dispose(): void;
  12874. /**
  12875. * The mesh that is attached to the controller
  12876. */
  12877. readonly mesh: Nullable<AbstractMesh>;
  12878. /**
  12879. * Gets the ray of the controller in the direction the controller is pointing
  12880. * @param length the length the resulting ray should be
  12881. * @returns a ray in the direction the controller is pointing
  12882. */
  12883. getForwardRay(length?: number): Ray;
  12884. }
  12885. }
  12886. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  12887. import { Observable } from "babylonjs/Misc/observable";
  12888. import { Scene } from "babylonjs/scene";
  12889. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12890. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  12891. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  12892. /**
  12893. * Defines the WebVRController object that represents controllers tracked in 3D space
  12894. */
  12895. export abstract class WebVRController extends PoseEnabledController {
  12896. /**
  12897. * Internal, the default controller model for the controller
  12898. */
  12899. protected _defaultModel: AbstractMesh;
  12900. /**
  12901. * Fired when the trigger state has changed
  12902. */
  12903. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12904. /**
  12905. * Fired when the main button state has changed
  12906. */
  12907. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12908. /**
  12909. * Fired when the secondary button state has changed
  12910. */
  12911. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12912. /**
  12913. * Fired when the pad state has changed
  12914. */
  12915. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12916. /**
  12917. * Fired when controllers stick values have changed
  12918. */
  12919. onPadValuesChangedObservable: Observable<StickValues>;
  12920. /**
  12921. * Array of button availible on the controller
  12922. */
  12923. protected _buttons: Array<MutableGamepadButton>;
  12924. private _onButtonStateChange;
  12925. /**
  12926. * Fired when a controller button's state has changed
  12927. * @param callback the callback containing the button that was modified
  12928. */
  12929. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12930. /**
  12931. * X and Y axis corrisponding to the controllers joystick
  12932. */
  12933. pad: StickValues;
  12934. /**
  12935. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12936. */
  12937. hand: string;
  12938. /**
  12939. * The default controller model for the controller
  12940. */
  12941. readonly defaultModel: AbstractMesh;
  12942. /**
  12943. * Creates a new WebVRController from a gamepad
  12944. * @param vrGamepad the gamepad that the WebVRController should be created from
  12945. */
  12946. constructor(vrGamepad: any);
  12947. /**
  12948. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  12949. */
  12950. update(): void;
  12951. /**
  12952. * Function to be called when a button is modified
  12953. */
  12954. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  12955. /**
  12956. * Loads a mesh and attaches it to the controller
  12957. * @param scene the scene the mesh should be added to
  12958. * @param meshLoaded callback for when the mesh has been loaded
  12959. */
  12960. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  12961. private _setButtonValue;
  12962. private _changes;
  12963. private _checkChanges;
  12964. /**
  12965. * Disposes of th webVRCOntroller
  12966. */
  12967. dispose(): void;
  12968. }
  12969. }
  12970. declare module "babylonjs/Lights/hemisphericLight" {
  12971. import { Nullable } from "babylonjs/types";
  12972. import { Scene } from "babylonjs/scene";
  12973. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  12974. import { Effect } from "babylonjs/Materials/effect";
  12975. import { Light } from "babylonjs/Lights/light";
  12976. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  12977. /**
  12978. * The HemisphericLight simulates the ambient environment light,
  12979. * so the passed direction is the light reflection direction, not the incoming direction.
  12980. */
  12981. export class HemisphericLight extends Light {
  12982. /**
  12983. * The groundColor is the light in the opposite direction to the one specified during creation.
  12984. * 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.
  12985. */
  12986. groundColor: Color3;
  12987. /**
  12988. * The light reflection direction, not the incoming direction.
  12989. */
  12990. direction: Vector3;
  12991. /**
  12992. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12993. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12994. * The HemisphericLight can't cast shadows.
  12995. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12996. * @param name The friendly name of the light
  12997. * @param direction The direction of the light reflection
  12998. * @param scene The scene the light belongs to
  12999. */
  13000. constructor(name: string, direction: Vector3, scene: Scene);
  13001. protected _buildUniformLayout(): void;
  13002. /**
  13003. * Returns the string "HemisphericLight".
  13004. * @return The class name
  13005. */
  13006. getClassName(): string;
  13007. /**
  13008. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13009. * Returns the updated direction.
  13010. * @param target The target the direction should point to
  13011. * @return The computed direction
  13012. */
  13013. setDirectionToTarget(target: Vector3): Vector3;
  13014. /**
  13015. * Returns the shadow generator associated to the light.
  13016. * @returns Always null for hemispheric lights because it does not support shadows.
  13017. */
  13018. getShadowGenerator(): Nullable<IShadowGenerator>;
  13019. /**
  13020. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13021. * @param effect The effect to update
  13022. * @param lightIndex The index of the light in the effect to update
  13023. * @returns The hemispheric light
  13024. */
  13025. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13026. /**
  13027. * Computes the world matrix of the node
  13028. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13029. * @param useWasUpdatedFlag defines a reserved property
  13030. * @returns the world matrix
  13031. */
  13032. computeWorldMatrix(): Matrix;
  13033. /**
  13034. * Returns the integer 3.
  13035. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13036. */
  13037. getTypeID(): number;
  13038. /**
  13039. * Prepares the list of defines specific to the light type.
  13040. * @param defines the list of defines
  13041. * @param lightIndex defines the index of the light for the effect
  13042. */
  13043. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13044. }
  13045. }
  13046. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  13047. declare module "babylonjs/Cameras/VR/webVRCamera" {
  13048. import { Nullable } from "babylonjs/types";
  13049. import { Observable } from "babylonjs/Misc/observable";
  13050. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  13051. import { Scene } from "babylonjs/scene";
  13052. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  13053. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  13054. import { Node } from "babylonjs/node";
  13055. import { Ray } from "babylonjs/Culling/ray";
  13056. import "babylonjs/Cameras/RigModes/webVRRigMode";
  13057. /**
  13058. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13059. * IMPORTANT!! The data is right-hand data.
  13060. * @export
  13061. * @interface DevicePose
  13062. */
  13063. export interface DevicePose {
  13064. /**
  13065. * The position of the device, values in array are [x,y,z].
  13066. */
  13067. readonly position: Nullable<Float32Array>;
  13068. /**
  13069. * The linearVelocity of the device, values in array are [x,y,z].
  13070. */
  13071. readonly linearVelocity: Nullable<Float32Array>;
  13072. /**
  13073. * The linearAcceleration of the device, values in array are [x,y,z].
  13074. */
  13075. readonly linearAcceleration: Nullable<Float32Array>;
  13076. /**
  13077. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13078. */
  13079. readonly orientation: Nullable<Float32Array>;
  13080. /**
  13081. * The angularVelocity of the device, values in array are [x,y,z].
  13082. */
  13083. readonly angularVelocity: Nullable<Float32Array>;
  13084. /**
  13085. * The angularAcceleration of the device, values in array are [x,y,z].
  13086. */
  13087. readonly angularAcceleration: Nullable<Float32Array>;
  13088. }
  13089. /**
  13090. * Interface representing a pose controlled object in Babylon.
  13091. * A pose controlled object has both regular pose values as well as pose values
  13092. * from an external device such as a VR head mounted display
  13093. */
  13094. export interface PoseControlled {
  13095. /**
  13096. * The position of the object in babylon space.
  13097. */
  13098. position: Vector3;
  13099. /**
  13100. * The rotation quaternion of the object in babylon space.
  13101. */
  13102. rotationQuaternion: Quaternion;
  13103. /**
  13104. * The position of the device in babylon space.
  13105. */
  13106. devicePosition?: Vector3;
  13107. /**
  13108. * The rotation quaternion of the device in babylon space.
  13109. */
  13110. deviceRotationQuaternion: Quaternion;
  13111. /**
  13112. * The raw pose coming from the device.
  13113. */
  13114. rawPose: Nullable<DevicePose>;
  13115. /**
  13116. * The scale of the device to be used when translating from device space to babylon space.
  13117. */
  13118. deviceScaleFactor: number;
  13119. /**
  13120. * Updates the poseControlled values based on the input device pose.
  13121. * @param poseData the pose data to update the object with
  13122. */
  13123. updateFromDevice(poseData: DevicePose): void;
  13124. }
  13125. /**
  13126. * Set of options to customize the webVRCamera
  13127. */
  13128. export interface WebVROptions {
  13129. /**
  13130. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13131. */
  13132. trackPosition?: boolean;
  13133. /**
  13134. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13135. */
  13136. positionScale?: number;
  13137. /**
  13138. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13139. */
  13140. displayName?: string;
  13141. /**
  13142. * Should the native controller meshes be initialized. (default: true)
  13143. */
  13144. controllerMeshes?: boolean;
  13145. /**
  13146. * Creating a default HemiLight only on controllers. (default: true)
  13147. */
  13148. defaultLightingOnControllers?: boolean;
  13149. /**
  13150. * If you don't want to use the default VR button of the helper. (default: false)
  13151. */
  13152. useCustomVRButton?: boolean;
  13153. /**
  13154. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13155. */
  13156. customVRButton?: HTMLButtonElement;
  13157. /**
  13158. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13159. */
  13160. rayLength?: number;
  13161. /**
  13162. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13163. */
  13164. defaultHeight?: number;
  13165. }
  13166. /**
  13167. * This represents a WebVR camera.
  13168. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13169. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13170. */
  13171. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13172. private webVROptions;
  13173. /**
  13174. * @hidden
  13175. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13176. */
  13177. _vrDevice: any;
  13178. /**
  13179. * The rawPose of the vrDevice.
  13180. */
  13181. rawPose: Nullable<DevicePose>;
  13182. private _onVREnabled;
  13183. private _specsVersion;
  13184. private _attached;
  13185. private _frameData;
  13186. protected _descendants: Array<Node>;
  13187. private _deviceRoomPosition;
  13188. /** @hidden */
  13189. _deviceRoomRotationQuaternion: Quaternion;
  13190. private _standingMatrix;
  13191. /**
  13192. * Represents device position in babylon space.
  13193. */
  13194. devicePosition: Vector3;
  13195. /**
  13196. * Represents device rotation in babylon space.
  13197. */
  13198. deviceRotationQuaternion: Quaternion;
  13199. /**
  13200. * The scale of the device to be used when translating from device space to babylon space.
  13201. */
  13202. deviceScaleFactor: number;
  13203. private _deviceToWorld;
  13204. private _worldToDevice;
  13205. /**
  13206. * References to the webVR controllers for the vrDevice.
  13207. */
  13208. controllers: Array<WebVRController>;
  13209. /**
  13210. * Emits an event when a controller is attached.
  13211. */
  13212. onControllersAttachedObservable: Observable<WebVRController[]>;
  13213. /**
  13214. * Emits an event when a controller's mesh has been loaded;
  13215. */
  13216. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13217. /**
  13218. * Emits an event when the HMD's pose has been updated.
  13219. */
  13220. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13221. private _poseSet;
  13222. /**
  13223. * If the rig cameras be used as parent instead of this camera.
  13224. */
  13225. rigParenting: boolean;
  13226. private _lightOnControllers;
  13227. private _defaultHeight?;
  13228. /**
  13229. * Instantiates a WebVRFreeCamera.
  13230. * @param name The name of the WebVRFreeCamera
  13231. * @param position The starting anchor position for the camera
  13232. * @param scene The scene the camera belongs to
  13233. * @param webVROptions a set of customizable options for the webVRCamera
  13234. */
  13235. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13236. /**
  13237. * Gets the device distance from the ground in meters.
  13238. * @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.
  13239. */
  13240. deviceDistanceToRoomGround(): number;
  13241. /**
  13242. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13243. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13244. */
  13245. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13246. /**
  13247. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13248. * @returns A promise with a boolean set to if the standing matrix is supported.
  13249. */
  13250. useStandingMatrixAsync(): Promise<boolean>;
  13251. /**
  13252. * Disposes the camera
  13253. */
  13254. dispose(): void;
  13255. /**
  13256. * Gets a vrController by name.
  13257. * @param name The name of the controller to retreive
  13258. * @returns the controller matching the name specified or null if not found
  13259. */
  13260. getControllerByName(name: string): Nullable<WebVRController>;
  13261. private _leftController;
  13262. /**
  13263. * The controller corrisponding to the users left hand.
  13264. */
  13265. readonly leftController: Nullable<WebVRController>;
  13266. private _rightController;
  13267. /**
  13268. * The controller corrisponding to the users right hand.
  13269. */
  13270. readonly rightController: Nullable<WebVRController>;
  13271. /**
  13272. * Casts a ray forward from the vrCamera's gaze.
  13273. * @param length Length of the ray (default: 100)
  13274. * @returns the ray corrisponding to the gaze
  13275. */
  13276. getForwardRay(length?: number): Ray;
  13277. /**
  13278. * @hidden
  13279. * Updates the camera based on device's frame data
  13280. */
  13281. _checkInputs(): void;
  13282. /**
  13283. * Updates the poseControlled values based on the input device pose.
  13284. * @param poseData Pose coming from the device
  13285. */
  13286. updateFromDevice(poseData: DevicePose): void;
  13287. private _htmlElementAttached;
  13288. private _detachIfAttached;
  13289. /**
  13290. * WebVR's attach control will start broadcasting frames to the device.
  13291. * Note that in certain browsers (chrome for example) this function must be called
  13292. * within a user-interaction callback. Example:
  13293. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13294. *
  13295. * @param element html element to attach the vrDevice to
  13296. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13297. */
  13298. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13299. /**
  13300. * Detaches the camera from the html element and disables VR
  13301. *
  13302. * @param element html element to detach from
  13303. */
  13304. detachControl(element: HTMLElement): void;
  13305. /**
  13306. * @returns the name of this class
  13307. */
  13308. getClassName(): string;
  13309. /**
  13310. * Calls resetPose on the vrDisplay
  13311. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13312. */
  13313. resetToCurrentRotation(): void;
  13314. /**
  13315. * @hidden
  13316. * Updates the rig cameras (left and right eye)
  13317. */
  13318. _updateRigCameras(): void;
  13319. private _workingVector;
  13320. private _oneVector;
  13321. private _workingMatrix;
  13322. private updateCacheCalled;
  13323. private _correctPositionIfNotTrackPosition;
  13324. /**
  13325. * @hidden
  13326. * Updates the cached values of the camera
  13327. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13328. */
  13329. _updateCache(ignoreParentClass?: boolean): void;
  13330. /**
  13331. * @hidden
  13332. * Get current device position in babylon world
  13333. */
  13334. _computeDevicePosition(): void;
  13335. /**
  13336. * Updates the current device position and rotation in the babylon world
  13337. */
  13338. update(): void;
  13339. /**
  13340. * @hidden
  13341. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13342. * @returns an identity matrix
  13343. */
  13344. _getViewMatrix(): Matrix;
  13345. private _tmpMatrix;
  13346. /**
  13347. * This function is called by the two RIG cameras.
  13348. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13349. * @hidden
  13350. */
  13351. _getWebVRViewMatrix(): Matrix;
  13352. /** @hidden */
  13353. _getWebVRProjectionMatrix(): Matrix;
  13354. private _onGamepadConnectedObserver;
  13355. private _onGamepadDisconnectedObserver;
  13356. private _updateCacheWhenTrackingDisabledObserver;
  13357. /**
  13358. * Initializes the controllers and their meshes
  13359. */
  13360. initControllers(): void;
  13361. }
  13362. }
  13363. declare module "babylonjs/PostProcesses/postProcess" {
  13364. import { Nullable } from "babylonjs/types";
  13365. import { SmartArray } from "babylonjs/Misc/smartArray";
  13366. import { Observable } from "babylonjs/Misc/observable";
  13367. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13368. import { Camera } from "babylonjs/Cameras/camera";
  13369. import { Effect } from "babylonjs/Materials/effect";
  13370. import "babylonjs/Shaders/postprocess.vertex";
  13371. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13372. import { Engine } from "babylonjs/Engines/engine";
  13373. /**
  13374. * Size options for a post process
  13375. */
  13376. export type PostProcessOptions = {
  13377. width: number;
  13378. height: number;
  13379. };
  13380. /**
  13381. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13382. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13383. */
  13384. export class PostProcess {
  13385. /** Name of the PostProcess. */
  13386. name: string;
  13387. /**
  13388. * Gets or sets the unique id of the post process
  13389. */
  13390. uniqueId: number;
  13391. /**
  13392. * Width of the texture to apply the post process on
  13393. */
  13394. width: number;
  13395. /**
  13396. * Height of the texture to apply the post process on
  13397. */
  13398. height: number;
  13399. /**
  13400. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13401. * @hidden
  13402. */
  13403. _outputTexture: Nullable<InternalTexture>;
  13404. /**
  13405. * Sampling mode used by the shader
  13406. * See https://doc.babylonjs.com/classes/3.1/texture
  13407. */
  13408. renderTargetSamplingMode: number;
  13409. /**
  13410. * Clear color to use when screen clearing
  13411. */
  13412. clearColor: Color4;
  13413. /**
  13414. * If the buffer needs to be cleared before applying the post process. (default: true)
  13415. * Should be set to false if shader will overwrite all previous pixels.
  13416. */
  13417. autoClear: boolean;
  13418. /**
  13419. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13420. */
  13421. alphaMode: number;
  13422. /**
  13423. * Sets the setAlphaBlendConstants of the babylon engine
  13424. */
  13425. alphaConstants: Color4;
  13426. /**
  13427. * Animations to be used for the post processing
  13428. */
  13429. animations: import("babylonjs/Animations/animation").Animation[];
  13430. /**
  13431. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13432. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13433. */
  13434. enablePixelPerfectMode: boolean;
  13435. /**
  13436. * Force the postprocess to be applied without taking in account viewport
  13437. */
  13438. forceFullscreenViewport: boolean;
  13439. /**
  13440. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13441. *
  13442. * | Value | Type | Description |
  13443. * | ----- | ----------------------------------- | ----------- |
  13444. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13445. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13446. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13447. *
  13448. */
  13449. scaleMode: number;
  13450. /**
  13451. * Force textures to be a power of two (default: false)
  13452. */
  13453. alwaysForcePOT: boolean;
  13454. private _samples;
  13455. /**
  13456. * Number of sample textures (default: 1)
  13457. */
  13458. samples: number;
  13459. /**
  13460. * Modify the scale of the post process to be the same as the viewport (default: false)
  13461. */
  13462. adaptScaleToCurrentViewport: boolean;
  13463. private _camera;
  13464. private _scene;
  13465. private _engine;
  13466. private _options;
  13467. private _reusable;
  13468. private _textureType;
  13469. /**
  13470. * Smart array of input and output textures for the post process.
  13471. * @hidden
  13472. */
  13473. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13474. /**
  13475. * The index in _textures that corresponds to the output texture.
  13476. * @hidden
  13477. */
  13478. _currentRenderTextureInd: number;
  13479. private _effect;
  13480. private _samplers;
  13481. private _fragmentUrl;
  13482. private _vertexUrl;
  13483. private _parameters;
  13484. private _scaleRatio;
  13485. protected _indexParameters: any;
  13486. private _shareOutputWithPostProcess;
  13487. private _texelSize;
  13488. private _forcedOutputTexture;
  13489. /**
  13490. * Returns the fragment url or shader name used in the post process.
  13491. * @returns the fragment url or name in the shader store.
  13492. */
  13493. getEffectName(): string;
  13494. /**
  13495. * An event triggered when the postprocess is activated.
  13496. */
  13497. onActivateObservable: Observable<Camera>;
  13498. private _onActivateObserver;
  13499. /**
  13500. * A function that is added to the onActivateObservable
  13501. */
  13502. onActivate: Nullable<(camera: Camera) => void>;
  13503. /**
  13504. * An event triggered when the postprocess changes its size.
  13505. */
  13506. onSizeChangedObservable: Observable<PostProcess>;
  13507. private _onSizeChangedObserver;
  13508. /**
  13509. * A function that is added to the onSizeChangedObservable
  13510. */
  13511. onSizeChanged: (postProcess: PostProcess) => void;
  13512. /**
  13513. * An event triggered when the postprocess applies its effect.
  13514. */
  13515. onApplyObservable: Observable<Effect>;
  13516. private _onApplyObserver;
  13517. /**
  13518. * A function that is added to the onApplyObservable
  13519. */
  13520. onApply: (effect: Effect) => void;
  13521. /**
  13522. * An event triggered before rendering the postprocess
  13523. */
  13524. onBeforeRenderObservable: Observable<Effect>;
  13525. private _onBeforeRenderObserver;
  13526. /**
  13527. * A function that is added to the onBeforeRenderObservable
  13528. */
  13529. onBeforeRender: (effect: Effect) => void;
  13530. /**
  13531. * An event triggered after rendering the postprocess
  13532. */
  13533. onAfterRenderObservable: Observable<Effect>;
  13534. private _onAfterRenderObserver;
  13535. /**
  13536. * A function that is added to the onAfterRenderObservable
  13537. */
  13538. onAfterRender: (efect: Effect) => void;
  13539. /**
  13540. * 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
  13541. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13542. */
  13543. inputTexture: InternalTexture;
  13544. /**
  13545. * Gets the camera which post process is applied to.
  13546. * @returns The camera the post process is applied to.
  13547. */
  13548. getCamera(): Camera;
  13549. /**
  13550. * Gets the texel size of the postprocess.
  13551. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13552. */
  13553. readonly texelSize: Vector2;
  13554. /**
  13555. * Creates a new instance PostProcess
  13556. * @param name The name of the PostProcess.
  13557. * @param fragmentUrl The url of the fragment shader to be used.
  13558. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13559. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13560. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13561. * @param camera The camera to apply the render pass to.
  13562. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13563. * @param engine The engine which the post process will be applied. (default: current engine)
  13564. * @param reusable If the post process can be reused on the same frame. (default: false)
  13565. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13566. * @param textureType Type of textures used when performing the post process. (default: 0)
  13567. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13568. * @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
  13569. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13570. */
  13571. constructor(
  13572. /** Name of the PostProcess. */
  13573. 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);
  13574. /**
  13575. * Gets a string idenfifying the name of the class
  13576. * @returns "PostProcess" string
  13577. */
  13578. getClassName(): string;
  13579. /**
  13580. * Gets the engine which this post process belongs to.
  13581. * @returns The engine the post process was enabled with.
  13582. */
  13583. getEngine(): Engine;
  13584. /**
  13585. * The effect that is created when initializing the post process.
  13586. * @returns The created effect corrisponding the the postprocess.
  13587. */
  13588. getEffect(): Effect;
  13589. /**
  13590. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13591. * @param postProcess The post process to share the output with.
  13592. * @returns This post process.
  13593. */
  13594. shareOutputWith(postProcess: PostProcess): PostProcess;
  13595. /**
  13596. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13597. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13598. */
  13599. useOwnOutput(): void;
  13600. /**
  13601. * Updates the effect with the current post process compile time values and recompiles the shader.
  13602. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13603. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13604. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13605. * @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
  13606. * @param onCompiled Called when the shader has been compiled.
  13607. * @param onError Called if there is an error when compiling a shader.
  13608. */
  13609. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13610. /**
  13611. * The post process is reusable if it can be used multiple times within one frame.
  13612. * @returns If the post process is reusable
  13613. */
  13614. isReusable(): boolean;
  13615. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13616. markTextureDirty(): void;
  13617. /**
  13618. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13619. * 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.
  13620. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13621. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13622. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13623. * @returns The target texture that was bound to be written to.
  13624. */
  13625. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13626. /**
  13627. * If the post process is supported.
  13628. */
  13629. readonly isSupported: boolean;
  13630. /**
  13631. * The aspect ratio of the output texture.
  13632. */
  13633. readonly aspectRatio: number;
  13634. /**
  13635. * Get a value indicating if the post-process is ready to be used
  13636. * @returns true if the post-process is ready (shader is compiled)
  13637. */
  13638. isReady(): boolean;
  13639. /**
  13640. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13641. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13642. */
  13643. apply(): Nullable<Effect>;
  13644. private _disposeTextures;
  13645. /**
  13646. * Disposes the post process.
  13647. * @param camera The camera to dispose the post process on.
  13648. */
  13649. dispose(camera?: Camera): void;
  13650. }
  13651. }
  13652. declare module "babylonjs/PostProcesses/postProcessManager" {
  13653. import { Nullable } from "babylonjs/types";
  13654. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13655. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13656. import { Scene } from "babylonjs/scene";
  13657. /**
  13658. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13659. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13660. */
  13661. export class PostProcessManager {
  13662. private _scene;
  13663. private _indexBuffer;
  13664. private _vertexBuffers;
  13665. /**
  13666. * Creates a new instance PostProcess
  13667. * @param scene The scene that the post process is associated with.
  13668. */
  13669. constructor(scene: Scene);
  13670. private _prepareBuffers;
  13671. private _buildIndexBuffer;
  13672. /**
  13673. * Rebuilds the vertex buffers of the manager.
  13674. * @hidden
  13675. */
  13676. _rebuild(): void;
  13677. /**
  13678. * Prepares a frame to be run through a post process.
  13679. * @param sourceTexture The input texture to the post procesess. (default: null)
  13680. * @param postProcesses An array of post processes to be run. (default: null)
  13681. * @returns True if the post processes were able to be run.
  13682. * @hidden
  13683. */
  13684. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13685. /**
  13686. * Manually render a set of post processes to a texture.
  13687. * @param postProcesses An array of post processes to be run.
  13688. * @param targetTexture The target texture to render to.
  13689. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13690. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13691. * @param lodLevel defines which lod of the texture to render to
  13692. */
  13693. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13694. /**
  13695. * Finalize the result of the output of the postprocesses.
  13696. * @param doNotPresent If true the result will not be displayed to the screen.
  13697. * @param targetTexture The target texture to render to.
  13698. * @param faceIndex The index of the face to bind the target texture to.
  13699. * @param postProcesses The array of post processes to render.
  13700. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13701. * @hidden
  13702. */
  13703. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13704. /**
  13705. * Disposes of the post process manager.
  13706. */
  13707. dispose(): void;
  13708. }
  13709. }
  13710. declare module "babylonjs/Layers/layerSceneComponent" {
  13711. import { Scene } from "babylonjs/scene";
  13712. import { ISceneComponent } from "babylonjs/sceneComponent";
  13713. import { Layer } from "babylonjs/Layers/layer";
  13714. module "babylonjs/abstractScene" {
  13715. interface AbstractScene {
  13716. /**
  13717. * The list of layers (background and foreground) of the scene
  13718. */
  13719. layers: Array<Layer>;
  13720. }
  13721. }
  13722. /**
  13723. * Defines the layer scene component responsible to manage any layers
  13724. * in a given scene.
  13725. */
  13726. export class LayerSceneComponent implements ISceneComponent {
  13727. /**
  13728. * The component name helpfull to identify the component in the list of scene components.
  13729. */
  13730. readonly name: string;
  13731. /**
  13732. * The scene the component belongs to.
  13733. */
  13734. scene: Scene;
  13735. private _engine;
  13736. /**
  13737. * Creates a new instance of the component for the given scene
  13738. * @param scene Defines the scene to register the component in
  13739. */
  13740. constructor(scene: Scene);
  13741. /**
  13742. * Registers the component in a given scene
  13743. */
  13744. register(): void;
  13745. /**
  13746. * Rebuilds the elements related to this component in case of
  13747. * context lost for instance.
  13748. */
  13749. rebuild(): void;
  13750. /**
  13751. * Disposes the component and the associated ressources.
  13752. */
  13753. dispose(): void;
  13754. private _draw;
  13755. private _drawCameraPredicate;
  13756. private _drawCameraBackground;
  13757. private _drawCameraForeground;
  13758. private _drawRenderTargetPredicate;
  13759. private _drawRenderTargetBackground;
  13760. private _drawRenderTargetForeground;
  13761. }
  13762. }
  13763. declare module "babylonjs/Shaders/layer.fragment" {
  13764. /** @hidden */
  13765. export var layerPixelShader: {
  13766. name: string;
  13767. shader: string;
  13768. };
  13769. }
  13770. declare module "babylonjs/Shaders/layer.vertex" {
  13771. /** @hidden */
  13772. export var layerVertexShader: {
  13773. name: string;
  13774. shader: string;
  13775. };
  13776. }
  13777. declare module "babylonjs/Layers/layer" {
  13778. import { Observable } from "babylonjs/Misc/observable";
  13779. import { Nullable } from "babylonjs/types";
  13780. import { Scene } from "babylonjs/scene";
  13781. import { Vector2, Color4 } from "babylonjs/Maths/math";
  13782. import { Texture } from "babylonjs/Materials/Textures/texture";
  13783. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13784. import "babylonjs/Shaders/layer.fragment";
  13785. import "babylonjs/Shaders/layer.vertex";
  13786. /**
  13787. * This represents a full screen 2d layer.
  13788. * This can be useful to display a picture in the background of your scene for instance.
  13789. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13790. */
  13791. export class Layer {
  13792. /**
  13793. * Define the name of the layer.
  13794. */
  13795. name: string;
  13796. /**
  13797. * Define the texture the layer should display.
  13798. */
  13799. texture: Nullable<Texture>;
  13800. /**
  13801. * Is the layer in background or foreground.
  13802. */
  13803. isBackground: boolean;
  13804. /**
  13805. * Define the color of the layer (instead of texture).
  13806. */
  13807. color: Color4;
  13808. /**
  13809. * Define the scale of the layer in order to zoom in out of the texture.
  13810. */
  13811. scale: Vector2;
  13812. /**
  13813. * Define an offset for the layer in order to shift the texture.
  13814. */
  13815. offset: Vector2;
  13816. /**
  13817. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13818. */
  13819. alphaBlendingMode: number;
  13820. /**
  13821. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13822. * Alpha test will not mix with the background color in case of transparency.
  13823. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13824. */
  13825. alphaTest: boolean;
  13826. /**
  13827. * Define a mask to restrict the layer to only some of the scene cameras.
  13828. */
  13829. layerMask: number;
  13830. /**
  13831. * Define the list of render target the layer is visible into.
  13832. */
  13833. renderTargetTextures: RenderTargetTexture[];
  13834. /**
  13835. * Define if the layer is only used in renderTarget or if it also
  13836. * renders in the main frame buffer of the canvas.
  13837. */
  13838. renderOnlyInRenderTargetTextures: boolean;
  13839. private _scene;
  13840. private _vertexBuffers;
  13841. private _indexBuffer;
  13842. private _effect;
  13843. private _alphaTestEffect;
  13844. /**
  13845. * An event triggered when the layer is disposed.
  13846. */
  13847. onDisposeObservable: Observable<Layer>;
  13848. private _onDisposeObserver;
  13849. /**
  13850. * Back compatibility with callback before the onDisposeObservable existed.
  13851. * The set callback will be triggered when the layer has been disposed.
  13852. */
  13853. onDispose: () => void;
  13854. /**
  13855. * An event triggered before rendering the scene
  13856. */
  13857. onBeforeRenderObservable: Observable<Layer>;
  13858. private _onBeforeRenderObserver;
  13859. /**
  13860. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13861. * The set callback will be triggered just before rendering the layer.
  13862. */
  13863. onBeforeRender: () => void;
  13864. /**
  13865. * An event triggered after rendering the scene
  13866. */
  13867. onAfterRenderObservable: Observable<Layer>;
  13868. private _onAfterRenderObserver;
  13869. /**
  13870. * Back compatibility with callback before the onAfterRenderObservable existed.
  13871. * The set callback will be triggered just after rendering the layer.
  13872. */
  13873. onAfterRender: () => void;
  13874. /**
  13875. * Instantiates a new layer.
  13876. * This represents a full screen 2d layer.
  13877. * This can be useful to display a picture in the background of your scene for instance.
  13878. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13879. * @param name Define the name of the layer in the scene
  13880. * @param imgUrl Define the url of the texture to display in the layer
  13881. * @param scene Define the scene the layer belongs to
  13882. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13883. * @param color Defines a color for the layer
  13884. */
  13885. constructor(
  13886. /**
  13887. * Define the name of the layer.
  13888. */
  13889. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13890. private _createIndexBuffer;
  13891. /** @hidden */
  13892. _rebuild(): void;
  13893. /**
  13894. * Renders the layer in the scene.
  13895. */
  13896. render(): void;
  13897. /**
  13898. * Disposes and releases the associated ressources.
  13899. */
  13900. dispose(): void;
  13901. }
  13902. }
  13903. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  13904. import { Scene } from "babylonjs/scene";
  13905. import { ISceneComponent } from "babylonjs/sceneComponent";
  13906. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  13907. module "babylonjs/abstractScene" {
  13908. interface AbstractScene {
  13909. /**
  13910. * The list of procedural textures added to the scene
  13911. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13912. */
  13913. proceduralTextures: Array<ProceduralTexture>;
  13914. }
  13915. }
  13916. /**
  13917. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13918. * in a given scene.
  13919. */
  13920. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13921. /**
  13922. * The component name helpfull to identify the component in the list of scene components.
  13923. */
  13924. readonly name: string;
  13925. /**
  13926. * The scene the component belongs to.
  13927. */
  13928. scene: Scene;
  13929. /**
  13930. * Creates a new instance of the component for the given scene
  13931. * @param scene Defines the scene to register the component in
  13932. */
  13933. constructor(scene: Scene);
  13934. /**
  13935. * Registers the component in a given scene
  13936. */
  13937. register(): void;
  13938. /**
  13939. * Rebuilds the elements related to this component in case of
  13940. * context lost for instance.
  13941. */
  13942. rebuild(): void;
  13943. /**
  13944. * Disposes the component and the associated ressources.
  13945. */
  13946. dispose(): void;
  13947. private _beforeClear;
  13948. }
  13949. }
  13950. declare module "babylonjs/Shaders/procedural.vertex" {
  13951. /** @hidden */
  13952. export var proceduralVertexShader: {
  13953. name: string;
  13954. shader: string;
  13955. };
  13956. }
  13957. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  13958. import { Observable } from "babylonjs/Misc/observable";
  13959. import { Nullable } from "babylonjs/types";
  13960. import { Scene } from "babylonjs/scene";
  13961. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  13962. import { Effect } from "babylonjs/Materials/effect";
  13963. import { Texture } from "babylonjs/Materials/Textures/texture";
  13964. import "babylonjs/Shaders/procedural.vertex";
  13965. /**
  13966. * 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.
  13967. * This is the base class of any Procedural texture and contains most of the shareable code.
  13968. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13969. */
  13970. export class ProceduralTexture extends Texture {
  13971. isCube: boolean;
  13972. /**
  13973. * Define if the texture is enabled or not (disabled texture will not render)
  13974. */
  13975. isEnabled: boolean;
  13976. /**
  13977. * Define if the texture must be cleared before rendering (default is true)
  13978. */
  13979. autoClear: boolean;
  13980. /**
  13981. * Callback called when the texture is generated
  13982. */
  13983. onGenerated: () => void;
  13984. /**
  13985. * Event raised when the texture is generated
  13986. */
  13987. onGeneratedObservable: Observable<ProceduralTexture>;
  13988. /** @hidden */
  13989. _generateMipMaps: boolean;
  13990. /** @hidden **/
  13991. _effect: Effect;
  13992. /** @hidden */
  13993. _textures: {
  13994. [key: string]: Texture;
  13995. };
  13996. private _size;
  13997. private _currentRefreshId;
  13998. private _refreshRate;
  13999. private _vertexBuffers;
  14000. private _indexBuffer;
  14001. private _uniforms;
  14002. private _samplers;
  14003. private _fragment;
  14004. private _floats;
  14005. private _ints;
  14006. private _floatsArrays;
  14007. private _colors3;
  14008. private _colors4;
  14009. private _vectors2;
  14010. private _vectors3;
  14011. private _matrices;
  14012. private _fallbackTexture;
  14013. private _fallbackTextureUsed;
  14014. private _engine;
  14015. private _cachedDefines;
  14016. private _contentUpdateId;
  14017. private _contentData;
  14018. /**
  14019. * Instantiates a new procedural texture.
  14020. * 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.
  14021. * This is the base class of any Procedural texture and contains most of the shareable code.
  14022. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14023. * @param name Define the name of the texture
  14024. * @param size Define the size of the texture to create
  14025. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14026. * @param scene Define the scene the texture belongs to
  14027. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14028. * @param generateMipMaps Define if the texture should creates mip maps or not
  14029. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14030. */
  14031. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14032. /**
  14033. * The effect that is created when initializing the post process.
  14034. * @returns The created effect corrisponding the the postprocess.
  14035. */
  14036. getEffect(): Effect;
  14037. /**
  14038. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14039. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14040. */
  14041. getContent(): Nullable<ArrayBufferView>;
  14042. private _createIndexBuffer;
  14043. /** @hidden */
  14044. _rebuild(): void;
  14045. /**
  14046. * Resets the texture in order to recreate its associated resources.
  14047. * This can be called in case of context loss
  14048. */
  14049. reset(): void;
  14050. protected _getDefines(): string;
  14051. /**
  14052. * Is the texture ready to be used ? (rendered at least once)
  14053. * @returns true if ready, otherwise, false.
  14054. */
  14055. isReady(): boolean;
  14056. /**
  14057. * Resets the refresh counter of the texture and start bak from scratch.
  14058. * Could be useful to regenerate the texture if it is setup to render only once.
  14059. */
  14060. resetRefreshCounter(): void;
  14061. /**
  14062. * Set the fragment shader to use in order to render the texture.
  14063. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14064. */
  14065. setFragment(fragment: any): void;
  14066. /**
  14067. * Define the refresh rate of the texture or the rendering frequency.
  14068. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14069. */
  14070. refreshRate: number;
  14071. /** @hidden */
  14072. _shouldRender(): boolean;
  14073. /**
  14074. * Get the size the texture is rendering at.
  14075. * @returns the size (texture is always squared)
  14076. */
  14077. getRenderSize(): number;
  14078. /**
  14079. * Resize the texture to new value.
  14080. * @param size Define the new size the texture should have
  14081. * @param generateMipMaps Define whether the new texture should create mip maps
  14082. */
  14083. resize(size: number, generateMipMaps: boolean): void;
  14084. private _checkUniform;
  14085. /**
  14086. * Set a texture in the shader program used to render.
  14087. * @param name Define the name of the uniform samplers as defined in the shader
  14088. * @param texture Define the texture to bind to this sampler
  14089. * @return the texture itself allowing "fluent" like uniform updates
  14090. */
  14091. setTexture(name: string, texture: Texture): ProceduralTexture;
  14092. /**
  14093. * Set a float in the shader.
  14094. * @param name Define the name of the uniform as defined in the shader
  14095. * @param value Define the value to give to the uniform
  14096. * @return the texture itself allowing "fluent" like uniform updates
  14097. */
  14098. setFloat(name: string, value: number): ProceduralTexture;
  14099. /**
  14100. * Set a int in the shader.
  14101. * @param name Define the name of the uniform as defined in the shader
  14102. * @param value Define the value to give to the uniform
  14103. * @return the texture itself allowing "fluent" like uniform updates
  14104. */
  14105. setInt(name: string, value: number): ProceduralTexture;
  14106. /**
  14107. * Set an array of floats in the shader.
  14108. * @param name Define the name of the uniform as defined in the shader
  14109. * @param value Define the value to give to the uniform
  14110. * @return the texture itself allowing "fluent" like uniform updates
  14111. */
  14112. setFloats(name: string, value: number[]): ProceduralTexture;
  14113. /**
  14114. * Set a vec3 in the shader from a Color3.
  14115. * @param name Define the name of the uniform as defined in the shader
  14116. * @param value Define the value to give to the uniform
  14117. * @return the texture itself allowing "fluent" like uniform updates
  14118. */
  14119. setColor3(name: string, value: Color3): ProceduralTexture;
  14120. /**
  14121. * Set a vec4 in the shader from a Color4.
  14122. * @param name Define the name of the uniform as defined in the shader
  14123. * @param value Define the value to give to the uniform
  14124. * @return the texture itself allowing "fluent" like uniform updates
  14125. */
  14126. setColor4(name: string, value: Color4): ProceduralTexture;
  14127. /**
  14128. * Set a vec2 in the shader from a Vector2.
  14129. * @param name Define the name of the uniform as defined in the shader
  14130. * @param value Define the value to give to the uniform
  14131. * @return the texture itself allowing "fluent" like uniform updates
  14132. */
  14133. setVector2(name: string, value: Vector2): ProceduralTexture;
  14134. /**
  14135. * Set a vec3 in the shader from a Vector3.
  14136. * @param name Define the name of the uniform as defined in the shader
  14137. * @param value Define the value to give to the uniform
  14138. * @return the texture itself allowing "fluent" like uniform updates
  14139. */
  14140. setVector3(name: string, value: Vector3): ProceduralTexture;
  14141. /**
  14142. * Set a mat4 in the shader from a MAtrix.
  14143. * @param name Define the name of the uniform as defined in the shader
  14144. * @param value Define the value to give to the uniform
  14145. * @return the texture itself allowing "fluent" like uniform updates
  14146. */
  14147. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14148. /**
  14149. * Render the texture to its associated render target.
  14150. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14151. */
  14152. render(useCameraPostProcess?: boolean): void;
  14153. /**
  14154. * Clone the texture.
  14155. * @returns the cloned texture
  14156. */
  14157. clone(): ProceduralTexture;
  14158. /**
  14159. * Dispose the texture and release its asoociated resources.
  14160. */
  14161. dispose(): void;
  14162. }
  14163. }
  14164. declare module "babylonjs/Particles/baseParticleSystem" {
  14165. import { Nullable } from "babylonjs/types";
  14166. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14167. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14168. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14169. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14170. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14171. import { Scene } from "babylonjs/scene";
  14172. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14173. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14174. import { Texture } from "babylonjs/Materials/Textures/texture";
  14175. import { Animation } from "babylonjs/Animations/animation";
  14176. /**
  14177. * This represents the base class for particle system in Babylon.
  14178. * 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.
  14179. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14180. * @example https://doc.babylonjs.com/babylon101/particles
  14181. */
  14182. export class BaseParticleSystem {
  14183. /**
  14184. * Source color is added to the destination color without alpha affecting the result
  14185. */
  14186. static BLENDMODE_ONEONE: number;
  14187. /**
  14188. * Blend current color and particle color using particle’s alpha
  14189. */
  14190. static BLENDMODE_STANDARD: number;
  14191. /**
  14192. * Add current color and particle color multiplied by particle’s alpha
  14193. */
  14194. static BLENDMODE_ADD: number;
  14195. /**
  14196. * Multiply current color with particle color
  14197. */
  14198. static BLENDMODE_MULTIPLY: number;
  14199. /**
  14200. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14201. */
  14202. static BLENDMODE_MULTIPLYADD: number;
  14203. /**
  14204. * List of animations used by the particle system.
  14205. */
  14206. animations: Animation[];
  14207. /**
  14208. * The id of the Particle system.
  14209. */
  14210. id: string;
  14211. /**
  14212. * The friendly name of the Particle system.
  14213. */
  14214. name: string;
  14215. /**
  14216. * The rendering group used by the Particle system to chose when to render.
  14217. */
  14218. renderingGroupId: number;
  14219. /**
  14220. * The emitter represents the Mesh or position we are attaching the particle system to.
  14221. */
  14222. emitter: Nullable<AbstractMesh | Vector3>;
  14223. /**
  14224. * The maximum number of particles to emit per frame
  14225. */
  14226. emitRate: number;
  14227. /**
  14228. * If you want to launch only a few particles at once, that can be done, as well.
  14229. */
  14230. manualEmitCount: number;
  14231. /**
  14232. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14233. */
  14234. updateSpeed: number;
  14235. /**
  14236. * The amount of time the particle system is running (depends of the overall update speed).
  14237. */
  14238. targetStopDuration: number;
  14239. /**
  14240. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14241. */
  14242. disposeOnStop: boolean;
  14243. /**
  14244. * Minimum power of emitting particles.
  14245. */
  14246. minEmitPower: number;
  14247. /**
  14248. * Maximum power of emitting particles.
  14249. */
  14250. maxEmitPower: number;
  14251. /**
  14252. * Minimum life time of emitting particles.
  14253. */
  14254. minLifeTime: number;
  14255. /**
  14256. * Maximum life time of emitting particles.
  14257. */
  14258. maxLifeTime: number;
  14259. /**
  14260. * Minimum Size of emitting particles.
  14261. */
  14262. minSize: number;
  14263. /**
  14264. * Maximum Size of emitting particles.
  14265. */
  14266. maxSize: number;
  14267. /**
  14268. * Minimum scale of emitting particles on X axis.
  14269. */
  14270. minScaleX: number;
  14271. /**
  14272. * Maximum scale of emitting particles on X axis.
  14273. */
  14274. maxScaleX: number;
  14275. /**
  14276. * Minimum scale of emitting particles on Y axis.
  14277. */
  14278. minScaleY: number;
  14279. /**
  14280. * Maximum scale of emitting particles on Y axis.
  14281. */
  14282. maxScaleY: number;
  14283. /**
  14284. * Gets or sets the minimal initial rotation in radians.
  14285. */
  14286. minInitialRotation: number;
  14287. /**
  14288. * Gets or sets the maximal initial rotation in radians.
  14289. */
  14290. maxInitialRotation: number;
  14291. /**
  14292. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14293. */
  14294. minAngularSpeed: number;
  14295. /**
  14296. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14297. */
  14298. maxAngularSpeed: number;
  14299. /**
  14300. * The texture used to render each particle. (this can be a spritesheet)
  14301. */
  14302. particleTexture: Nullable<Texture>;
  14303. /**
  14304. * The layer mask we are rendering the particles through.
  14305. */
  14306. layerMask: number;
  14307. /**
  14308. * This can help using your own shader to render the particle system.
  14309. * The according effect will be created
  14310. */
  14311. customShader: any;
  14312. /**
  14313. * By default particle system starts as soon as they are created. This prevents the
  14314. * automatic start to happen and let you decide when to start emitting particles.
  14315. */
  14316. preventAutoStart: boolean;
  14317. private _noiseTexture;
  14318. /**
  14319. * Gets or sets a texture used to add random noise to particle positions
  14320. */
  14321. noiseTexture: Nullable<ProceduralTexture>;
  14322. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14323. noiseStrength: Vector3;
  14324. /**
  14325. * Callback triggered when the particle animation is ending.
  14326. */
  14327. onAnimationEnd: Nullable<() => void>;
  14328. /**
  14329. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14330. */
  14331. blendMode: number;
  14332. /**
  14333. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14334. * to override the particles.
  14335. */
  14336. forceDepthWrite: boolean;
  14337. /** 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 */
  14338. preWarmCycles: number;
  14339. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14340. preWarmStepOffset: number;
  14341. /**
  14342. * 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)
  14343. */
  14344. spriteCellChangeSpeed: number;
  14345. /**
  14346. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14347. */
  14348. startSpriteCellID: number;
  14349. /**
  14350. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14351. */
  14352. endSpriteCellID: number;
  14353. /**
  14354. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14355. */
  14356. spriteCellWidth: number;
  14357. /**
  14358. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14359. */
  14360. spriteCellHeight: number;
  14361. /**
  14362. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14363. */
  14364. spriteRandomStartCell: boolean;
  14365. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14366. translationPivot: Vector2;
  14367. /** @hidden */
  14368. protected _isAnimationSheetEnabled: boolean;
  14369. /**
  14370. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14371. */
  14372. beginAnimationOnStart: boolean;
  14373. /**
  14374. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14375. */
  14376. beginAnimationFrom: number;
  14377. /**
  14378. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14379. */
  14380. beginAnimationTo: number;
  14381. /**
  14382. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14383. */
  14384. beginAnimationLoop: boolean;
  14385. /**
  14386. * Gets or sets a world offset applied to all particles
  14387. */
  14388. worldOffset: Vector3;
  14389. /**
  14390. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14391. */
  14392. isAnimationSheetEnabled: boolean;
  14393. /**
  14394. * Get hosting scene
  14395. * @returns the scene
  14396. */
  14397. getScene(): Scene;
  14398. /**
  14399. * You can use gravity if you want to give an orientation to your particles.
  14400. */
  14401. gravity: Vector3;
  14402. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14403. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14404. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14405. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14406. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14407. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14408. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14409. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14410. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14411. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14412. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14413. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14414. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14415. /**
  14416. * Defines the delay in milliseconds before starting the system (0 by default)
  14417. */
  14418. startDelay: number;
  14419. /**
  14420. * Gets the current list of drag gradients.
  14421. * You must use addDragGradient and removeDragGradient to udpate this list
  14422. * @returns the list of drag gradients
  14423. */
  14424. getDragGradients(): Nullable<Array<FactorGradient>>;
  14425. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14426. limitVelocityDamping: number;
  14427. /**
  14428. * Gets the current list of limit velocity gradients.
  14429. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14430. * @returns the list of limit velocity gradients
  14431. */
  14432. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14433. /**
  14434. * Gets the current list of color gradients.
  14435. * You must use addColorGradient and removeColorGradient to udpate this list
  14436. * @returns the list of color gradients
  14437. */
  14438. getColorGradients(): Nullable<Array<ColorGradient>>;
  14439. /**
  14440. * Gets the current list of size gradients.
  14441. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14442. * @returns the list of size gradients
  14443. */
  14444. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14445. /**
  14446. * Gets the current list of color remap gradients.
  14447. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14448. * @returns the list of color remap gradients
  14449. */
  14450. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14451. /**
  14452. * Gets the current list of alpha remap gradients.
  14453. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14454. * @returns the list of alpha remap gradients
  14455. */
  14456. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14457. /**
  14458. * Gets the current list of life time gradients.
  14459. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14460. * @returns the list of life time gradients
  14461. */
  14462. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14463. /**
  14464. * Gets the current list of angular speed gradients.
  14465. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14466. * @returns the list of angular speed gradients
  14467. */
  14468. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14469. /**
  14470. * Gets the current list of velocity gradients.
  14471. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14472. * @returns the list of velocity gradients
  14473. */
  14474. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14475. /**
  14476. * Gets the current list of start size gradients.
  14477. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14478. * @returns the list of start size gradients
  14479. */
  14480. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14481. /**
  14482. * Gets the current list of emit rate gradients.
  14483. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14484. * @returns the list of emit rate gradients
  14485. */
  14486. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14487. /**
  14488. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14489. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14490. */
  14491. direction1: Vector3;
  14492. /**
  14493. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14494. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14495. */
  14496. direction2: Vector3;
  14497. /**
  14498. * 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.
  14499. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14500. */
  14501. minEmitBox: Vector3;
  14502. /**
  14503. * 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.
  14504. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14505. */
  14506. maxEmitBox: Vector3;
  14507. /**
  14508. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14509. */
  14510. color1: Color4;
  14511. /**
  14512. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14513. */
  14514. color2: Color4;
  14515. /**
  14516. * Color the particle will have at the end of its lifetime
  14517. */
  14518. colorDead: Color4;
  14519. /**
  14520. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14521. */
  14522. textureMask: Color4;
  14523. /**
  14524. * The particle emitter type defines the emitter used by the particle system.
  14525. * It can be for example box, sphere, or cone...
  14526. */
  14527. particleEmitterType: IParticleEmitterType;
  14528. /** @hidden */
  14529. _isSubEmitter: boolean;
  14530. /**
  14531. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14532. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14533. */
  14534. billboardMode: number;
  14535. protected _isBillboardBased: boolean;
  14536. /**
  14537. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14538. */
  14539. isBillboardBased: boolean;
  14540. /**
  14541. * The scene the particle system belongs to.
  14542. */
  14543. protected _scene: Scene;
  14544. /**
  14545. * Local cache of defines for image processing.
  14546. */
  14547. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14548. /**
  14549. * Default configuration related to image processing available in the standard Material.
  14550. */
  14551. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14552. /**
  14553. * Gets the image processing configuration used either in this material.
  14554. */
  14555. /**
  14556. * Sets the Default image processing configuration used either in the this material.
  14557. *
  14558. * If sets to null, the scene one is in use.
  14559. */
  14560. imageProcessingConfiguration: ImageProcessingConfiguration;
  14561. /**
  14562. * Attaches a new image processing configuration to the Standard Material.
  14563. * @param configuration
  14564. */
  14565. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14566. /** @hidden */
  14567. protected _reset(): void;
  14568. /** @hidden */
  14569. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14570. /**
  14571. * Instantiates a particle system.
  14572. * 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.
  14573. * @param name The name of the particle system
  14574. */
  14575. constructor(name: string);
  14576. /**
  14577. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14578. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14579. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14580. * @returns the emitter
  14581. */
  14582. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14583. /**
  14584. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14585. * @param radius The radius of the hemisphere to emit from
  14586. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14587. * @returns the emitter
  14588. */
  14589. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14590. /**
  14591. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14592. * @param radius The radius of the sphere to emit from
  14593. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14594. * @returns the emitter
  14595. */
  14596. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14597. /**
  14598. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14599. * @param radius The radius of the sphere to emit from
  14600. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14601. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14602. * @returns the emitter
  14603. */
  14604. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14605. /**
  14606. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14607. * @param radius The radius of the emission cylinder
  14608. * @param height The height of the emission cylinder
  14609. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14610. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14611. * @returns the emitter
  14612. */
  14613. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14614. /**
  14615. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14616. * @param radius The radius of the cylinder to emit from
  14617. * @param height The height of the emission cylinder
  14618. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14619. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14620. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14621. * @returns the emitter
  14622. */
  14623. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14624. /**
  14625. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14626. * @param radius The radius of the cone to emit from
  14627. * @param angle The base angle of the cone
  14628. * @returns the emitter
  14629. */
  14630. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14631. /**
  14632. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14633. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14634. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14635. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14636. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14637. * @returns the emitter
  14638. */
  14639. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14640. }
  14641. }
  14642. declare module "babylonjs/Particles/subEmitter" {
  14643. import { Scene } from "babylonjs/scene";
  14644. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  14645. /**
  14646. * Type of sub emitter
  14647. */
  14648. export enum SubEmitterType {
  14649. /**
  14650. * Attached to the particle over it's lifetime
  14651. */
  14652. ATTACHED = 0,
  14653. /**
  14654. * Created when the particle dies
  14655. */
  14656. END = 1
  14657. }
  14658. /**
  14659. * Sub emitter class used to emit particles from an existing particle
  14660. */
  14661. export class SubEmitter {
  14662. /**
  14663. * the particle system to be used by the sub emitter
  14664. */
  14665. particleSystem: ParticleSystem;
  14666. /**
  14667. * Type of the submitter (Default: END)
  14668. */
  14669. type: SubEmitterType;
  14670. /**
  14671. * 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)
  14672. * Note: This only is supported when using an emitter of type Mesh
  14673. */
  14674. inheritDirection: boolean;
  14675. /**
  14676. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14677. */
  14678. inheritedVelocityAmount: number;
  14679. /**
  14680. * Creates a sub emitter
  14681. * @param particleSystem the particle system to be used by the sub emitter
  14682. */
  14683. constructor(
  14684. /**
  14685. * the particle system to be used by the sub emitter
  14686. */
  14687. particleSystem: ParticleSystem);
  14688. /**
  14689. * Clones the sub emitter
  14690. * @returns the cloned sub emitter
  14691. */
  14692. clone(): SubEmitter;
  14693. /**
  14694. * Serialize current object to a JSON object
  14695. * @returns the serialized object
  14696. */
  14697. serialize(): any;
  14698. /** @hidden */
  14699. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14700. /**
  14701. * Creates a new SubEmitter from a serialized JSON version
  14702. * @param serializationObject defines the JSON object to read from
  14703. * @param scene defines the hosting scene
  14704. * @param rootUrl defines the rootUrl for data loading
  14705. * @returns a new SubEmitter
  14706. */
  14707. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14708. /** Release associated resources */
  14709. dispose(): void;
  14710. }
  14711. }
  14712. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  14713. /** @hidden */
  14714. export var clipPlaneFragmentDeclaration: {
  14715. name: string;
  14716. shader: string;
  14717. };
  14718. }
  14719. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  14720. /** @hidden */
  14721. export var imageProcessingDeclaration: {
  14722. name: string;
  14723. shader: string;
  14724. };
  14725. }
  14726. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  14727. /** @hidden */
  14728. export var imageProcessingFunctions: {
  14729. name: string;
  14730. shader: string;
  14731. };
  14732. }
  14733. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  14734. /** @hidden */
  14735. export var clipPlaneFragment: {
  14736. name: string;
  14737. shader: string;
  14738. };
  14739. }
  14740. declare module "babylonjs/Shaders/particles.fragment" {
  14741. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  14742. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  14743. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  14744. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  14745. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  14746. /** @hidden */
  14747. export var particlesPixelShader: {
  14748. name: string;
  14749. shader: string;
  14750. };
  14751. }
  14752. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  14753. /** @hidden */
  14754. export var clipPlaneVertexDeclaration: {
  14755. name: string;
  14756. shader: string;
  14757. };
  14758. }
  14759. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  14760. /** @hidden */
  14761. export var clipPlaneVertex: {
  14762. name: string;
  14763. shader: string;
  14764. };
  14765. }
  14766. declare module "babylonjs/Shaders/particles.vertex" {
  14767. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  14768. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  14769. /** @hidden */
  14770. export var particlesVertexShader: {
  14771. name: string;
  14772. shader: string;
  14773. };
  14774. }
  14775. declare module "babylonjs/Particles/particleSystem" {
  14776. import { Nullable } from "babylonjs/types";
  14777. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  14778. import { Observable } from "babylonjs/Misc/observable";
  14779. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  14780. import { Effect } from "babylonjs/Materials/effect";
  14781. import { Scene, IDisposable } from "babylonjs/scene";
  14782. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  14783. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  14784. import { Particle } from "babylonjs/Particles/particle";
  14785. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  14786. import "babylonjs/Shaders/particles.fragment";
  14787. import "babylonjs/Shaders/particles.vertex";
  14788. /**
  14789. * This represents a particle system in Babylon.
  14790. * 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.
  14791. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14792. * @example https://doc.babylonjs.com/babylon101/particles
  14793. */
  14794. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14795. /**
  14796. * Billboard mode will only apply to Y axis
  14797. */
  14798. static readonly BILLBOARDMODE_Y: number;
  14799. /**
  14800. * Billboard mode will apply to all axes
  14801. */
  14802. static readonly BILLBOARDMODE_ALL: number;
  14803. /**
  14804. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14805. */
  14806. static readonly BILLBOARDMODE_STRETCHED: number;
  14807. /**
  14808. * This function can be defined to provide custom update for active particles.
  14809. * This function will be called instead of regular update (age, position, color, etc.).
  14810. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14811. */
  14812. updateFunction: (particles: Particle[]) => void;
  14813. private _emitterWorldMatrix;
  14814. /**
  14815. * This function can be defined to specify initial direction for every new particle.
  14816. * It by default use the emitterType defined function
  14817. */
  14818. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14819. /**
  14820. * This function can be defined to specify initial position for every new particle.
  14821. * It by default use the emitterType defined function
  14822. */
  14823. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14824. /**
  14825. * @hidden
  14826. */
  14827. _inheritedVelocityOffset: Vector3;
  14828. /**
  14829. * An event triggered when the system is disposed
  14830. */
  14831. onDisposeObservable: Observable<ParticleSystem>;
  14832. private _onDisposeObserver;
  14833. /**
  14834. * Sets a callback that will be triggered when the system is disposed
  14835. */
  14836. onDispose: () => void;
  14837. private _particles;
  14838. private _epsilon;
  14839. private _capacity;
  14840. private _stockParticles;
  14841. private _newPartsExcess;
  14842. private _vertexData;
  14843. private _vertexBuffer;
  14844. private _vertexBuffers;
  14845. private _spriteBuffer;
  14846. private _indexBuffer;
  14847. private _effect;
  14848. private _customEffect;
  14849. private _cachedDefines;
  14850. private _scaledColorStep;
  14851. private _colorDiff;
  14852. private _scaledDirection;
  14853. private _scaledGravity;
  14854. private _currentRenderId;
  14855. private _alive;
  14856. private _useInstancing;
  14857. private _started;
  14858. private _stopped;
  14859. private _actualFrame;
  14860. private _scaledUpdateSpeed;
  14861. private _vertexBufferSize;
  14862. /** @hidden */
  14863. _currentEmitRateGradient: Nullable<FactorGradient>;
  14864. /** @hidden */
  14865. _currentEmitRate1: number;
  14866. /** @hidden */
  14867. _currentEmitRate2: number;
  14868. /** @hidden */
  14869. _currentStartSizeGradient: Nullable<FactorGradient>;
  14870. /** @hidden */
  14871. _currentStartSize1: number;
  14872. /** @hidden */
  14873. _currentStartSize2: number;
  14874. private readonly _rawTextureWidth;
  14875. private _rampGradientsTexture;
  14876. private _useRampGradients;
  14877. /** Gets or sets a boolean indicating that ramp gradients must be used
  14878. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14879. */
  14880. useRampGradients: boolean;
  14881. /**
  14882. * 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.
  14883. * 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: [])
  14884. */
  14885. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14886. private _subEmitters;
  14887. /**
  14888. * @hidden
  14889. * If the particle systems emitter should be disposed when the particle system is disposed
  14890. */
  14891. _disposeEmitterOnDispose: boolean;
  14892. /**
  14893. * The current active Sub-systems, this property is used by the root particle system only.
  14894. */
  14895. activeSubSystems: Array<ParticleSystem>;
  14896. private _rootParticleSystem;
  14897. /**
  14898. * Gets the current list of active particles
  14899. */
  14900. readonly particles: Particle[];
  14901. /**
  14902. * Returns the string "ParticleSystem"
  14903. * @returns a string containing the class name
  14904. */
  14905. getClassName(): string;
  14906. /**
  14907. * Instantiates a particle system.
  14908. * 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.
  14909. * @param name The name of the particle system
  14910. * @param capacity The max number of particles alive at the same time
  14911. * @param scene The scene the particle system belongs to
  14912. * @param customEffect a custom effect used to change the way particles are rendered by default
  14913. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14914. * @param epsilon Offset used to render the particles
  14915. */
  14916. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14917. private _addFactorGradient;
  14918. private _removeFactorGradient;
  14919. /**
  14920. * Adds a new life time gradient
  14921. * @param gradient defines the gradient to use (between 0 and 1)
  14922. * @param factor defines the life time factor to affect to the specified gradient
  14923. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14924. * @returns the current particle system
  14925. */
  14926. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14927. /**
  14928. * Remove a specific life time gradient
  14929. * @param gradient defines the gradient to remove
  14930. * @returns the current particle system
  14931. */
  14932. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14933. /**
  14934. * Adds a new size gradient
  14935. * @param gradient defines the gradient to use (between 0 and 1)
  14936. * @param factor defines the size factor to affect to the specified gradient
  14937. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14938. * @returns the current particle system
  14939. */
  14940. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14941. /**
  14942. * Remove a specific size gradient
  14943. * @param gradient defines the gradient to remove
  14944. * @returns the current particle system
  14945. */
  14946. removeSizeGradient(gradient: number): IParticleSystem;
  14947. /**
  14948. * Adds a new color remap gradient
  14949. * @param gradient defines the gradient to use (between 0 and 1)
  14950. * @param min defines the color remap minimal range
  14951. * @param max defines the color remap maximal range
  14952. * @returns the current particle system
  14953. */
  14954. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14955. /**
  14956. * Remove a specific color remap gradient
  14957. * @param gradient defines the gradient to remove
  14958. * @returns the current particle system
  14959. */
  14960. removeColorRemapGradient(gradient: number): IParticleSystem;
  14961. /**
  14962. * Adds a new alpha remap gradient
  14963. * @param gradient defines the gradient to use (between 0 and 1)
  14964. * @param min defines the alpha remap minimal range
  14965. * @param max defines the alpha remap maximal range
  14966. * @returns the current particle system
  14967. */
  14968. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14969. /**
  14970. * Remove a specific alpha remap gradient
  14971. * @param gradient defines the gradient to remove
  14972. * @returns the current particle system
  14973. */
  14974. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14975. /**
  14976. * Adds a new angular speed gradient
  14977. * @param gradient defines the gradient to use (between 0 and 1)
  14978. * @param factor defines the angular speed to affect to the specified gradient
  14979. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14980. * @returns the current particle system
  14981. */
  14982. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14983. /**
  14984. * Remove a specific angular speed gradient
  14985. * @param gradient defines the gradient to remove
  14986. * @returns the current particle system
  14987. */
  14988. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14989. /**
  14990. * Adds a new velocity gradient
  14991. * @param gradient defines the gradient to use (between 0 and 1)
  14992. * @param factor defines the velocity to affect to the specified gradient
  14993. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14994. * @returns the current particle system
  14995. */
  14996. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14997. /**
  14998. * Remove a specific velocity gradient
  14999. * @param gradient defines the gradient to remove
  15000. * @returns the current particle system
  15001. */
  15002. removeVelocityGradient(gradient: number): IParticleSystem;
  15003. /**
  15004. * Adds a new limit velocity gradient
  15005. * @param gradient defines the gradient to use (between 0 and 1)
  15006. * @param factor defines the limit velocity value to affect to the specified gradient
  15007. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15008. * @returns the current particle system
  15009. */
  15010. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15011. /**
  15012. * Remove a specific limit velocity gradient
  15013. * @param gradient defines the gradient to remove
  15014. * @returns the current particle system
  15015. */
  15016. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15017. /**
  15018. * Adds a new drag gradient
  15019. * @param gradient defines the gradient to use (between 0 and 1)
  15020. * @param factor defines the drag value to affect to the specified gradient
  15021. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15022. * @returns the current particle system
  15023. */
  15024. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15025. /**
  15026. * Remove a specific drag gradient
  15027. * @param gradient defines the gradient to remove
  15028. * @returns the current particle system
  15029. */
  15030. removeDragGradient(gradient: number): IParticleSystem;
  15031. /**
  15032. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15033. * @param gradient defines the gradient to use (between 0 and 1)
  15034. * @param factor defines the emit rate value to affect to the specified gradient
  15035. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15036. * @returns the current particle system
  15037. */
  15038. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15039. /**
  15040. * Remove a specific emit rate gradient
  15041. * @param gradient defines the gradient to remove
  15042. * @returns the current particle system
  15043. */
  15044. removeEmitRateGradient(gradient: number): IParticleSystem;
  15045. /**
  15046. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15047. * @param gradient defines the gradient to use (between 0 and 1)
  15048. * @param factor defines the start size value to affect to the specified gradient
  15049. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15050. * @returns the current particle system
  15051. */
  15052. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15053. /**
  15054. * Remove a specific start size gradient
  15055. * @param gradient defines the gradient to remove
  15056. * @returns the current particle system
  15057. */
  15058. removeStartSizeGradient(gradient: number): IParticleSystem;
  15059. private _createRampGradientTexture;
  15060. /**
  15061. * Gets the current list of ramp gradients.
  15062. * You must use addRampGradient and removeRampGradient to udpate this list
  15063. * @returns the list of ramp gradients
  15064. */
  15065. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15066. /**
  15067. * Adds a new ramp gradient used to remap particle colors
  15068. * @param gradient defines the gradient to use (between 0 and 1)
  15069. * @param color defines the color to affect to the specified gradient
  15070. * @returns the current particle system
  15071. */
  15072. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15073. /**
  15074. * Remove a specific ramp gradient
  15075. * @param gradient defines the gradient to remove
  15076. * @returns the current particle system
  15077. */
  15078. removeRampGradient(gradient: number): ParticleSystem;
  15079. /**
  15080. * Adds a new color gradient
  15081. * @param gradient defines the gradient to use (between 0 and 1)
  15082. * @param color1 defines the color to affect to the specified gradient
  15083. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15084. * @returns this particle system
  15085. */
  15086. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15087. /**
  15088. * Remove a specific color gradient
  15089. * @param gradient defines the gradient to remove
  15090. * @returns this particle system
  15091. */
  15092. removeColorGradient(gradient: number): IParticleSystem;
  15093. private _fetchR;
  15094. protected _reset(): void;
  15095. private _resetEffect;
  15096. private _createVertexBuffers;
  15097. private _createIndexBuffer;
  15098. /**
  15099. * Gets the maximum number of particles active at the same time.
  15100. * @returns The max number of active particles.
  15101. */
  15102. getCapacity(): number;
  15103. /**
  15104. * Gets whether there are still active particles in the system.
  15105. * @returns True if it is alive, otherwise false.
  15106. */
  15107. isAlive(): boolean;
  15108. /**
  15109. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15110. * @returns True if it has been started, otherwise false.
  15111. */
  15112. isStarted(): boolean;
  15113. private _prepareSubEmitterInternalArray;
  15114. /**
  15115. * Starts the particle system and begins to emit
  15116. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15117. */
  15118. start(delay?: number): void;
  15119. /**
  15120. * Stops the particle system.
  15121. * @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.
  15122. */
  15123. stop(stopSubEmitters?: boolean): void;
  15124. /**
  15125. * Remove all active particles
  15126. */
  15127. reset(): void;
  15128. /**
  15129. * @hidden (for internal use only)
  15130. */
  15131. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15132. /**
  15133. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15134. * Its lifetime will start back at 0.
  15135. */
  15136. recycleParticle: (particle: Particle) => void;
  15137. private _stopSubEmitters;
  15138. private _createParticle;
  15139. private _removeFromRoot;
  15140. private _emitFromParticle;
  15141. private _update;
  15142. /** @hidden */
  15143. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15144. /** @hidden */
  15145. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15146. /** @hidden */
  15147. private _getEffect;
  15148. /**
  15149. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15150. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15151. */
  15152. animate(preWarmOnly?: boolean): void;
  15153. private _appendParticleVertices;
  15154. /**
  15155. * Rebuilds the particle system.
  15156. */
  15157. rebuild(): void;
  15158. /**
  15159. * Is this system ready to be used/rendered
  15160. * @return true if the system is ready
  15161. */
  15162. isReady(): boolean;
  15163. private _render;
  15164. /**
  15165. * Renders the particle system in its current state.
  15166. * @returns the current number of particles
  15167. */
  15168. render(): number;
  15169. /**
  15170. * Disposes the particle system and free the associated resources
  15171. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15172. */
  15173. dispose(disposeTexture?: boolean): void;
  15174. /**
  15175. * Clones the particle system.
  15176. * @param name The name of the cloned object
  15177. * @param newEmitter The new emitter to use
  15178. * @returns the cloned particle system
  15179. */
  15180. clone(name: string, newEmitter: any): ParticleSystem;
  15181. /**
  15182. * Serializes the particle system to a JSON object.
  15183. * @returns the JSON object
  15184. */
  15185. serialize(): any;
  15186. /** @hidden */
  15187. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15188. /** @hidden */
  15189. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15190. /**
  15191. * Parses a JSON object to create a particle system.
  15192. * @param parsedParticleSystem The JSON object to parse
  15193. * @param scene The scene to create the particle system in
  15194. * @param rootUrl The root url to use to load external dependencies like texture
  15195. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15196. * @returns the Parsed particle system
  15197. */
  15198. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15199. }
  15200. }
  15201. declare module "babylonjs/Particles/particle" {
  15202. import { Nullable } from "babylonjs/types";
  15203. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15204. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15205. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15206. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15207. /**
  15208. * A particle represents one of the element emitted by a particle system.
  15209. * This is mainly define by its coordinates, direction, velocity and age.
  15210. */
  15211. export class Particle {
  15212. /**
  15213. * The particle system the particle belongs to.
  15214. */
  15215. particleSystem: ParticleSystem;
  15216. private static _Count;
  15217. /**
  15218. * Unique ID of the particle
  15219. */
  15220. id: number;
  15221. /**
  15222. * The world position of the particle in the scene.
  15223. */
  15224. position: Vector3;
  15225. /**
  15226. * The world direction of the particle in the scene.
  15227. */
  15228. direction: Vector3;
  15229. /**
  15230. * The color of the particle.
  15231. */
  15232. color: Color4;
  15233. /**
  15234. * The color change of the particle per step.
  15235. */
  15236. colorStep: Color4;
  15237. /**
  15238. * Defines how long will the life of the particle be.
  15239. */
  15240. lifeTime: number;
  15241. /**
  15242. * The current age of the particle.
  15243. */
  15244. age: number;
  15245. /**
  15246. * The current size of the particle.
  15247. */
  15248. size: number;
  15249. /**
  15250. * The current scale of the particle.
  15251. */
  15252. scale: Vector2;
  15253. /**
  15254. * The current angle of the particle.
  15255. */
  15256. angle: number;
  15257. /**
  15258. * Defines how fast is the angle changing.
  15259. */
  15260. angularSpeed: number;
  15261. /**
  15262. * Defines the cell index used by the particle to be rendered from a sprite.
  15263. */
  15264. cellIndex: number;
  15265. /**
  15266. * The information required to support color remapping
  15267. */
  15268. remapData: Vector4;
  15269. /** @hidden */
  15270. _randomCellOffset?: number;
  15271. /** @hidden */
  15272. _initialDirection: Nullable<Vector3>;
  15273. /** @hidden */
  15274. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15275. /** @hidden */
  15276. _initialStartSpriteCellID: number;
  15277. /** @hidden */
  15278. _initialEndSpriteCellID: number;
  15279. /** @hidden */
  15280. _currentColorGradient: Nullable<ColorGradient>;
  15281. /** @hidden */
  15282. _currentColor1: Color4;
  15283. /** @hidden */
  15284. _currentColor2: Color4;
  15285. /** @hidden */
  15286. _currentSizeGradient: Nullable<FactorGradient>;
  15287. /** @hidden */
  15288. _currentSize1: number;
  15289. /** @hidden */
  15290. _currentSize2: number;
  15291. /** @hidden */
  15292. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15293. /** @hidden */
  15294. _currentAngularSpeed1: number;
  15295. /** @hidden */
  15296. _currentAngularSpeed2: number;
  15297. /** @hidden */
  15298. _currentVelocityGradient: Nullable<FactorGradient>;
  15299. /** @hidden */
  15300. _currentVelocity1: number;
  15301. /** @hidden */
  15302. _currentVelocity2: number;
  15303. /** @hidden */
  15304. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15305. /** @hidden */
  15306. _currentLimitVelocity1: number;
  15307. /** @hidden */
  15308. _currentLimitVelocity2: number;
  15309. /** @hidden */
  15310. _currentDragGradient: Nullable<FactorGradient>;
  15311. /** @hidden */
  15312. _currentDrag1: number;
  15313. /** @hidden */
  15314. _currentDrag2: number;
  15315. /** @hidden */
  15316. _randomNoiseCoordinates1: Vector3;
  15317. /** @hidden */
  15318. _randomNoiseCoordinates2: Vector3;
  15319. /**
  15320. * Creates a new instance Particle
  15321. * @param particleSystem the particle system the particle belongs to
  15322. */
  15323. constructor(
  15324. /**
  15325. * The particle system the particle belongs to.
  15326. */
  15327. particleSystem: ParticleSystem);
  15328. private updateCellInfoFromSystem;
  15329. /**
  15330. * Defines how the sprite cell index is updated for the particle
  15331. */
  15332. updateCellIndex(): void;
  15333. /** @hidden */
  15334. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15335. /** @hidden */
  15336. _inheritParticleInfoToSubEmitters(): void;
  15337. /** @hidden */
  15338. _reset(): void;
  15339. /**
  15340. * Copy the properties of particle to another one.
  15341. * @param other the particle to copy the information to.
  15342. */
  15343. copyTo(other: Particle): void;
  15344. }
  15345. }
  15346. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15347. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15348. import { Effect } from "babylonjs/Materials/effect";
  15349. import { Particle } from "babylonjs/Particles/particle";
  15350. /**
  15351. * Particle emitter represents a volume emitting particles.
  15352. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15353. */
  15354. export interface IParticleEmitterType {
  15355. /**
  15356. * Called by the particle System when the direction is computed for the created particle.
  15357. * @param worldMatrix is the world matrix of the particle system
  15358. * @param directionToUpdate is the direction vector to update with the result
  15359. * @param particle is the particle we are computed the direction for
  15360. */
  15361. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15362. /**
  15363. * Called by the particle System when the position is computed for the created particle.
  15364. * @param worldMatrix is the world matrix of the particle system
  15365. * @param positionToUpdate is the position vector to update with the result
  15366. * @param particle is the particle we are computed the position for
  15367. */
  15368. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15369. /**
  15370. * Clones the current emitter and returns a copy of it
  15371. * @returns the new emitter
  15372. */
  15373. clone(): IParticleEmitterType;
  15374. /**
  15375. * Called by the GPUParticleSystem to setup the update shader
  15376. * @param effect defines the update shader
  15377. */
  15378. applyToShader(effect: Effect): void;
  15379. /**
  15380. * Returns a string to use to update the GPU particles update shader
  15381. * @returns the effect defines string
  15382. */
  15383. getEffectDefines(): string;
  15384. /**
  15385. * Returns a string representing the class name
  15386. * @returns a string containing the class name
  15387. */
  15388. getClassName(): string;
  15389. /**
  15390. * Serializes the particle system to a JSON object.
  15391. * @returns the JSON object
  15392. */
  15393. serialize(): any;
  15394. /**
  15395. * Parse properties from a JSON object
  15396. * @param serializationObject defines the JSON object
  15397. */
  15398. parse(serializationObject: any): void;
  15399. }
  15400. }
  15401. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15402. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15403. import { Effect } from "babylonjs/Materials/effect";
  15404. import { Particle } from "babylonjs/Particles/particle";
  15405. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15406. /**
  15407. * Particle emitter emitting particles from the inside of a box.
  15408. * It emits the particles randomly between 2 given directions.
  15409. */
  15410. export class BoxParticleEmitter implements IParticleEmitterType {
  15411. /**
  15412. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15413. */
  15414. direction1: Vector3;
  15415. /**
  15416. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15417. */
  15418. direction2: Vector3;
  15419. /**
  15420. * 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.
  15421. */
  15422. minEmitBox: Vector3;
  15423. /**
  15424. * 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.
  15425. */
  15426. maxEmitBox: Vector3;
  15427. /**
  15428. * Creates a new instance BoxParticleEmitter
  15429. */
  15430. constructor();
  15431. /**
  15432. * Called by the particle System when the direction is computed for the created particle.
  15433. * @param worldMatrix is the world matrix of the particle system
  15434. * @param directionToUpdate is the direction vector to update with the result
  15435. * @param particle is the particle we are computed the direction for
  15436. */
  15437. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15438. /**
  15439. * Called by the particle System when the position is computed for the created particle.
  15440. * @param worldMatrix is the world matrix of the particle system
  15441. * @param positionToUpdate is the position vector to update with the result
  15442. * @param particle is the particle we are computed the position for
  15443. */
  15444. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15445. /**
  15446. * Clones the current emitter and returns a copy of it
  15447. * @returns the new emitter
  15448. */
  15449. clone(): BoxParticleEmitter;
  15450. /**
  15451. * Called by the GPUParticleSystem to setup the update shader
  15452. * @param effect defines the update shader
  15453. */
  15454. applyToShader(effect: Effect): void;
  15455. /**
  15456. * Returns a string to use to update the GPU particles update shader
  15457. * @returns a string containng the defines string
  15458. */
  15459. getEffectDefines(): string;
  15460. /**
  15461. * Returns the string "BoxParticleEmitter"
  15462. * @returns a string containing the class name
  15463. */
  15464. getClassName(): string;
  15465. /**
  15466. * Serializes the particle system to a JSON object.
  15467. * @returns the JSON object
  15468. */
  15469. serialize(): any;
  15470. /**
  15471. * Parse properties from a JSON object
  15472. * @param serializationObject defines the JSON object
  15473. */
  15474. parse(serializationObject: any): void;
  15475. }
  15476. }
  15477. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  15478. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15479. import { Effect } from "babylonjs/Materials/effect";
  15480. import { Particle } from "babylonjs/Particles/particle";
  15481. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15482. /**
  15483. * Particle emitter emitting particles from the inside of a cone.
  15484. * It emits the particles alongside the cone volume from the base to the particle.
  15485. * The emission direction might be randomized.
  15486. */
  15487. export class ConeParticleEmitter implements IParticleEmitterType {
  15488. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15489. directionRandomizer: number;
  15490. private _radius;
  15491. private _angle;
  15492. private _height;
  15493. /**
  15494. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15495. */
  15496. radiusRange: number;
  15497. /**
  15498. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15499. */
  15500. heightRange: number;
  15501. /**
  15502. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15503. */
  15504. emitFromSpawnPointOnly: boolean;
  15505. /**
  15506. * Gets or sets the radius of the emission cone
  15507. */
  15508. radius: number;
  15509. /**
  15510. * Gets or sets the angle of the emission cone
  15511. */
  15512. angle: number;
  15513. private _buildHeight;
  15514. /**
  15515. * Creates a new instance ConeParticleEmitter
  15516. * @param radius the radius of the emission cone (1 by default)
  15517. * @param angle the cone base angle (PI by default)
  15518. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15519. */
  15520. constructor(radius?: number, angle?: number,
  15521. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15522. directionRandomizer?: number);
  15523. /**
  15524. * Called by the particle System when the direction is computed for the created particle.
  15525. * @param worldMatrix is the world matrix of the particle system
  15526. * @param directionToUpdate is the direction vector to update with the result
  15527. * @param particle is the particle we are computed the direction for
  15528. */
  15529. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15530. /**
  15531. * Called by the particle System when the position is computed for the created particle.
  15532. * @param worldMatrix is the world matrix of the particle system
  15533. * @param positionToUpdate is the position vector to update with the result
  15534. * @param particle is the particle we are computed the position for
  15535. */
  15536. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15537. /**
  15538. * Clones the current emitter and returns a copy of it
  15539. * @returns the new emitter
  15540. */
  15541. clone(): ConeParticleEmitter;
  15542. /**
  15543. * Called by the GPUParticleSystem to setup the update shader
  15544. * @param effect defines the update shader
  15545. */
  15546. applyToShader(effect: Effect): void;
  15547. /**
  15548. * Returns a string to use to update the GPU particles update shader
  15549. * @returns a string containng the defines string
  15550. */
  15551. getEffectDefines(): string;
  15552. /**
  15553. * Returns the string "ConeParticleEmitter"
  15554. * @returns a string containing the class name
  15555. */
  15556. getClassName(): string;
  15557. /**
  15558. * Serializes the particle system to a JSON object.
  15559. * @returns the JSON object
  15560. */
  15561. serialize(): any;
  15562. /**
  15563. * Parse properties from a JSON object
  15564. * @param serializationObject defines the JSON object
  15565. */
  15566. parse(serializationObject: any): void;
  15567. }
  15568. }
  15569. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  15570. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15571. import { Effect } from "babylonjs/Materials/effect";
  15572. import { Particle } from "babylonjs/Particles/particle";
  15573. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15574. /**
  15575. * Particle emitter emitting particles from the inside of a cylinder.
  15576. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15577. */
  15578. export class CylinderParticleEmitter implements IParticleEmitterType {
  15579. /**
  15580. * The radius of the emission cylinder.
  15581. */
  15582. radius: number;
  15583. /**
  15584. * The height of the emission cylinder.
  15585. */
  15586. height: number;
  15587. /**
  15588. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15589. */
  15590. radiusRange: number;
  15591. /**
  15592. * How much to randomize the particle direction [0-1].
  15593. */
  15594. directionRandomizer: number;
  15595. /**
  15596. * Creates a new instance CylinderParticleEmitter
  15597. * @param radius the radius of the emission cylinder (1 by default)
  15598. * @param height the height of the emission cylinder (1 by default)
  15599. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15600. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15601. */
  15602. constructor(
  15603. /**
  15604. * The radius of the emission cylinder.
  15605. */
  15606. radius?: number,
  15607. /**
  15608. * The height of the emission cylinder.
  15609. */
  15610. height?: number,
  15611. /**
  15612. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15613. */
  15614. radiusRange?: number,
  15615. /**
  15616. * How much to randomize the particle direction [0-1].
  15617. */
  15618. directionRandomizer?: number);
  15619. /**
  15620. * Called by the particle System when the direction is computed for the created particle.
  15621. * @param worldMatrix is the world matrix of the particle system
  15622. * @param directionToUpdate is the direction vector to update with the result
  15623. * @param particle is the particle we are computed the direction for
  15624. */
  15625. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15626. /**
  15627. * Called by the particle System when the position is computed for the created particle.
  15628. * @param worldMatrix is the world matrix of the particle system
  15629. * @param positionToUpdate is the position vector to update with the result
  15630. * @param particle is the particle we are computed the position for
  15631. */
  15632. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15633. /**
  15634. * Clones the current emitter and returns a copy of it
  15635. * @returns the new emitter
  15636. */
  15637. clone(): CylinderParticleEmitter;
  15638. /**
  15639. * Called by the GPUParticleSystem to setup the update shader
  15640. * @param effect defines the update shader
  15641. */
  15642. applyToShader(effect: Effect): void;
  15643. /**
  15644. * Returns a string to use to update the GPU particles update shader
  15645. * @returns a string containng the defines string
  15646. */
  15647. getEffectDefines(): string;
  15648. /**
  15649. * Returns the string "CylinderParticleEmitter"
  15650. * @returns a string containing the class name
  15651. */
  15652. getClassName(): string;
  15653. /**
  15654. * Serializes the particle system to a JSON object.
  15655. * @returns the JSON object
  15656. */
  15657. serialize(): any;
  15658. /**
  15659. * Parse properties from a JSON object
  15660. * @param serializationObject defines the JSON object
  15661. */
  15662. parse(serializationObject: any): void;
  15663. }
  15664. /**
  15665. * Particle emitter emitting particles from the inside of a cylinder.
  15666. * It emits the particles randomly between two vectors.
  15667. */
  15668. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15669. /**
  15670. * The min limit of the emission direction.
  15671. */
  15672. direction1: Vector3;
  15673. /**
  15674. * The max limit of the emission direction.
  15675. */
  15676. direction2: Vector3;
  15677. /**
  15678. * Creates a new instance CylinderDirectedParticleEmitter
  15679. * @param radius the radius of the emission cylinder (1 by default)
  15680. * @param height the height of the emission cylinder (1 by default)
  15681. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15682. * @param direction1 the min limit of the emission direction (up vector by default)
  15683. * @param direction2 the max limit of the emission direction (up vector by default)
  15684. */
  15685. constructor(radius?: number, height?: number, radiusRange?: number,
  15686. /**
  15687. * The min limit of the emission direction.
  15688. */
  15689. direction1?: Vector3,
  15690. /**
  15691. * The max limit of the emission direction.
  15692. */
  15693. direction2?: Vector3);
  15694. /**
  15695. * Called by the particle System when the direction is computed for the created particle.
  15696. * @param worldMatrix is the world matrix of the particle system
  15697. * @param directionToUpdate is the direction vector to update with the result
  15698. * @param particle is the particle we are computed the direction for
  15699. */
  15700. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15701. /**
  15702. * Clones the current emitter and returns a copy of it
  15703. * @returns the new emitter
  15704. */
  15705. clone(): CylinderDirectedParticleEmitter;
  15706. /**
  15707. * Called by the GPUParticleSystem to setup the update shader
  15708. * @param effect defines the update shader
  15709. */
  15710. applyToShader(effect: Effect): void;
  15711. /**
  15712. * Returns a string to use to update the GPU particles update shader
  15713. * @returns a string containng the defines string
  15714. */
  15715. getEffectDefines(): string;
  15716. /**
  15717. * Returns the string "CylinderDirectedParticleEmitter"
  15718. * @returns a string containing the class name
  15719. */
  15720. getClassName(): string;
  15721. /**
  15722. * Serializes the particle system to a JSON object.
  15723. * @returns the JSON object
  15724. */
  15725. serialize(): any;
  15726. /**
  15727. * Parse properties from a JSON object
  15728. * @param serializationObject defines the JSON object
  15729. */
  15730. parse(serializationObject: any): void;
  15731. }
  15732. }
  15733. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  15734. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15735. import { Effect } from "babylonjs/Materials/effect";
  15736. import { Particle } from "babylonjs/Particles/particle";
  15737. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15738. /**
  15739. * Particle emitter emitting particles from the inside of a hemisphere.
  15740. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15741. */
  15742. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15743. /**
  15744. * The radius of the emission hemisphere.
  15745. */
  15746. radius: number;
  15747. /**
  15748. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15749. */
  15750. radiusRange: number;
  15751. /**
  15752. * How much to randomize the particle direction [0-1].
  15753. */
  15754. directionRandomizer: number;
  15755. /**
  15756. * Creates a new instance HemisphericParticleEmitter
  15757. * @param radius the radius of the emission hemisphere (1 by default)
  15758. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15759. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15760. */
  15761. constructor(
  15762. /**
  15763. * The radius of the emission hemisphere.
  15764. */
  15765. radius?: number,
  15766. /**
  15767. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15768. */
  15769. radiusRange?: number,
  15770. /**
  15771. * How much to randomize the particle direction [0-1].
  15772. */
  15773. directionRandomizer?: number);
  15774. /**
  15775. * Called by the particle System when the direction is computed for the created particle.
  15776. * @param worldMatrix is the world matrix of the particle system
  15777. * @param directionToUpdate is the direction vector to update with the result
  15778. * @param particle is the particle we are computed the direction for
  15779. */
  15780. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15781. /**
  15782. * Called by the particle System when the position is computed for the created particle.
  15783. * @param worldMatrix is the world matrix of the particle system
  15784. * @param positionToUpdate is the position vector to update with the result
  15785. * @param particle is the particle we are computed the position for
  15786. */
  15787. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15788. /**
  15789. * Clones the current emitter and returns a copy of it
  15790. * @returns the new emitter
  15791. */
  15792. clone(): HemisphericParticleEmitter;
  15793. /**
  15794. * Called by the GPUParticleSystem to setup the update shader
  15795. * @param effect defines the update shader
  15796. */
  15797. applyToShader(effect: Effect): void;
  15798. /**
  15799. * Returns a string to use to update the GPU particles update shader
  15800. * @returns a string containng the defines string
  15801. */
  15802. getEffectDefines(): string;
  15803. /**
  15804. * Returns the string "HemisphericParticleEmitter"
  15805. * @returns a string containing the class name
  15806. */
  15807. getClassName(): string;
  15808. /**
  15809. * Serializes the particle system to a JSON object.
  15810. * @returns the JSON object
  15811. */
  15812. serialize(): any;
  15813. /**
  15814. * Parse properties from a JSON object
  15815. * @param serializationObject defines the JSON object
  15816. */
  15817. parse(serializationObject: any): void;
  15818. }
  15819. }
  15820. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  15821. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15822. import { Effect } from "babylonjs/Materials/effect";
  15823. import { Particle } from "babylonjs/Particles/particle";
  15824. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15825. /**
  15826. * Particle emitter emitting particles from a point.
  15827. * It emits the particles randomly between 2 given directions.
  15828. */
  15829. export class PointParticleEmitter implements IParticleEmitterType {
  15830. /**
  15831. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15832. */
  15833. direction1: Vector3;
  15834. /**
  15835. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15836. */
  15837. direction2: Vector3;
  15838. /**
  15839. * Creates a new instance PointParticleEmitter
  15840. */
  15841. constructor();
  15842. /**
  15843. * Called by the particle System when the direction is computed for the created particle.
  15844. * @param worldMatrix is the world matrix of the particle system
  15845. * @param directionToUpdate is the direction vector to update with the result
  15846. * @param particle is the particle we are computed the direction for
  15847. */
  15848. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15849. /**
  15850. * Called by the particle System when the position is computed for the created particle.
  15851. * @param worldMatrix is the world matrix of the particle system
  15852. * @param positionToUpdate is the position vector to update with the result
  15853. * @param particle is the particle we are computed the position for
  15854. */
  15855. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15856. /**
  15857. * Clones the current emitter and returns a copy of it
  15858. * @returns the new emitter
  15859. */
  15860. clone(): PointParticleEmitter;
  15861. /**
  15862. * Called by the GPUParticleSystem to setup the update shader
  15863. * @param effect defines the update shader
  15864. */
  15865. applyToShader(effect: Effect): void;
  15866. /**
  15867. * Returns a string to use to update the GPU particles update shader
  15868. * @returns a string containng the defines string
  15869. */
  15870. getEffectDefines(): string;
  15871. /**
  15872. * Returns the string "PointParticleEmitter"
  15873. * @returns a string containing the class name
  15874. */
  15875. getClassName(): string;
  15876. /**
  15877. * Serializes the particle system to a JSON object.
  15878. * @returns the JSON object
  15879. */
  15880. serialize(): any;
  15881. /**
  15882. * Parse properties from a JSON object
  15883. * @param serializationObject defines the JSON object
  15884. */
  15885. parse(serializationObject: any): void;
  15886. }
  15887. }
  15888. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  15889. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15890. import { Effect } from "babylonjs/Materials/effect";
  15891. import { Particle } from "babylonjs/Particles/particle";
  15892. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15893. /**
  15894. * Particle emitter emitting particles from the inside of a sphere.
  15895. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15896. */
  15897. export class SphereParticleEmitter implements IParticleEmitterType {
  15898. /**
  15899. * The radius of the emission sphere.
  15900. */
  15901. radius: number;
  15902. /**
  15903. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15904. */
  15905. radiusRange: number;
  15906. /**
  15907. * How much to randomize the particle direction [0-1].
  15908. */
  15909. directionRandomizer: number;
  15910. /**
  15911. * Creates a new instance SphereParticleEmitter
  15912. * @param radius the radius of the emission sphere (1 by default)
  15913. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15914. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15915. */
  15916. constructor(
  15917. /**
  15918. * The radius of the emission sphere.
  15919. */
  15920. radius?: number,
  15921. /**
  15922. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15923. */
  15924. radiusRange?: number,
  15925. /**
  15926. * How much to randomize the particle direction [0-1].
  15927. */
  15928. directionRandomizer?: number);
  15929. /**
  15930. * Called by the particle System when the direction is computed for the created particle.
  15931. * @param worldMatrix is the world matrix of the particle system
  15932. * @param directionToUpdate is the direction vector to update with the result
  15933. * @param particle is the particle we are computed the direction for
  15934. */
  15935. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15936. /**
  15937. * Called by the particle System when the position is computed for the created particle.
  15938. * @param worldMatrix is the world matrix of the particle system
  15939. * @param positionToUpdate is the position vector to update with the result
  15940. * @param particle is the particle we are computed the position for
  15941. */
  15942. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15943. /**
  15944. * Clones the current emitter and returns a copy of it
  15945. * @returns the new emitter
  15946. */
  15947. clone(): SphereParticleEmitter;
  15948. /**
  15949. * Called by the GPUParticleSystem to setup the update shader
  15950. * @param effect defines the update shader
  15951. */
  15952. applyToShader(effect: Effect): void;
  15953. /**
  15954. * Returns a string to use to update the GPU particles update shader
  15955. * @returns a string containng the defines string
  15956. */
  15957. getEffectDefines(): string;
  15958. /**
  15959. * Returns the string "SphereParticleEmitter"
  15960. * @returns a string containing the class name
  15961. */
  15962. getClassName(): string;
  15963. /**
  15964. * Serializes the particle system to a JSON object.
  15965. * @returns the JSON object
  15966. */
  15967. serialize(): any;
  15968. /**
  15969. * Parse properties from a JSON object
  15970. * @param serializationObject defines the JSON object
  15971. */
  15972. parse(serializationObject: any): void;
  15973. }
  15974. /**
  15975. * Particle emitter emitting particles from the inside of a sphere.
  15976. * It emits the particles randomly between two vectors.
  15977. */
  15978. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15979. /**
  15980. * The min limit of the emission direction.
  15981. */
  15982. direction1: Vector3;
  15983. /**
  15984. * The max limit of the emission direction.
  15985. */
  15986. direction2: Vector3;
  15987. /**
  15988. * Creates a new instance SphereDirectedParticleEmitter
  15989. * @param radius the radius of the emission sphere (1 by default)
  15990. * @param direction1 the min limit of the emission direction (up vector by default)
  15991. * @param direction2 the max limit of the emission direction (up vector by default)
  15992. */
  15993. constructor(radius?: number,
  15994. /**
  15995. * The min limit of the emission direction.
  15996. */
  15997. direction1?: Vector3,
  15998. /**
  15999. * The max limit of the emission direction.
  16000. */
  16001. direction2?: Vector3);
  16002. /**
  16003. * Called by the particle System when the direction is computed for the created particle.
  16004. * @param worldMatrix is the world matrix of the particle system
  16005. * @param directionToUpdate is the direction vector to update with the result
  16006. * @param particle is the particle we are computed the direction for
  16007. */
  16008. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16009. /**
  16010. * Clones the current emitter and returns a copy of it
  16011. * @returns the new emitter
  16012. */
  16013. clone(): SphereDirectedParticleEmitter;
  16014. /**
  16015. * Called by the GPUParticleSystem to setup the update shader
  16016. * @param effect defines the update shader
  16017. */
  16018. applyToShader(effect: Effect): void;
  16019. /**
  16020. * Returns a string to use to update the GPU particles update shader
  16021. * @returns a string containng the defines string
  16022. */
  16023. getEffectDefines(): string;
  16024. /**
  16025. * Returns the string "SphereDirectedParticleEmitter"
  16026. * @returns a string containing the class name
  16027. */
  16028. getClassName(): string;
  16029. /**
  16030. * Serializes the particle system to a JSON object.
  16031. * @returns the JSON object
  16032. */
  16033. serialize(): any;
  16034. /**
  16035. * Parse properties from a JSON object
  16036. * @param serializationObject defines the JSON object
  16037. */
  16038. parse(serializationObject: any): void;
  16039. }
  16040. }
  16041. declare module "babylonjs/Particles/EmitterTypes/index" {
  16042. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16043. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16044. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16045. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16046. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16047. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16048. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16049. }
  16050. declare module "babylonjs/Particles/IParticleSystem" {
  16051. import { Nullable } from "babylonjs/types";
  16052. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  16053. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16054. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16055. import { Texture } from "babylonjs/Materials/Textures/texture";
  16056. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16057. import { Scene } from "babylonjs/scene";
  16058. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  16059. import { Animation } from "babylonjs/Animations/animation";
  16060. /**
  16061. * Interface representing a particle system in Babylon.js.
  16062. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16063. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16064. */
  16065. export interface IParticleSystem {
  16066. /**
  16067. * List of animations used by the particle system.
  16068. */
  16069. animations: Animation[];
  16070. /**
  16071. * The id of the Particle system.
  16072. */
  16073. id: string;
  16074. /**
  16075. * The name of the Particle system.
  16076. */
  16077. name: string;
  16078. /**
  16079. * The emitter represents the Mesh or position we are attaching the particle system to.
  16080. */
  16081. emitter: Nullable<AbstractMesh | Vector3>;
  16082. /**
  16083. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16084. */
  16085. isBillboardBased: boolean;
  16086. /**
  16087. * The rendering group used by the Particle system to chose when to render.
  16088. */
  16089. renderingGroupId: number;
  16090. /**
  16091. * The layer mask we are rendering the particles through.
  16092. */
  16093. layerMask: number;
  16094. /**
  16095. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16096. */
  16097. updateSpeed: number;
  16098. /**
  16099. * The amount of time the particle system is running (depends of the overall update speed).
  16100. */
  16101. targetStopDuration: number;
  16102. /**
  16103. * The texture used to render each particle. (this can be a spritesheet)
  16104. */
  16105. particleTexture: Nullable<Texture>;
  16106. /**
  16107. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16108. */
  16109. blendMode: number;
  16110. /**
  16111. * Minimum life time of emitting particles.
  16112. */
  16113. minLifeTime: number;
  16114. /**
  16115. * Maximum life time of emitting particles.
  16116. */
  16117. maxLifeTime: number;
  16118. /**
  16119. * Minimum Size of emitting particles.
  16120. */
  16121. minSize: number;
  16122. /**
  16123. * Maximum Size of emitting particles.
  16124. */
  16125. maxSize: number;
  16126. /**
  16127. * Minimum scale of emitting particles on X axis.
  16128. */
  16129. minScaleX: number;
  16130. /**
  16131. * Maximum scale of emitting particles on X axis.
  16132. */
  16133. maxScaleX: number;
  16134. /**
  16135. * Minimum scale of emitting particles on Y axis.
  16136. */
  16137. minScaleY: number;
  16138. /**
  16139. * Maximum scale of emitting particles on Y axis.
  16140. */
  16141. maxScaleY: number;
  16142. /**
  16143. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16144. */
  16145. color1: Color4;
  16146. /**
  16147. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16148. */
  16149. color2: Color4;
  16150. /**
  16151. * Color the particle will have at the end of its lifetime.
  16152. */
  16153. colorDead: Color4;
  16154. /**
  16155. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16156. */
  16157. emitRate: number;
  16158. /**
  16159. * You can use gravity if you want to give an orientation to your particles.
  16160. */
  16161. gravity: Vector3;
  16162. /**
  16163. * Minimum power of emitting particles.
  16164. */
  16165. minEmitPower: number;
  16166. /**
  16167. * Maximum power of emitting particles.
  16168. */
  16169. maxEmitPower: number;
  16170. /**
  16171. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16172. */
  16173. minAngularSpeed: number;
  16174. /**
  16175. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16176. */
  16177. maxAngularSpeed: number;
  16178. /**
  16179. * Gets or sets the minimal initial rotation in radians.
  16180. */
  16181. minInitialRotation: number;
  16182. /**
  16183. * Gets or sets the maximal initial rotation in radians.
  16184. */
  16185. maxInitialRotation: number;
  16186. /**
  16187. * The particle emitter type defines the emitter used by the particle system.
  16188. * It can be for example box, sphere, or cone...
  16189. */
  16190. particleEmitterType: Nullable<IParticleEmitterType>;
  16191. /**
  16192. * Defines the delay in milliseconds before starting the system (0 by default)
  16193. */
  16194. startDelay: number;
  16195. /**
  16196. * 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
  16197. */
  16198. preWarmCycles: number;
  16199. /**
  16200. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16201. */
  16202. preWarmStepOffset: number;
  16203. /**
  16204. * 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)
  16205. */
  16206. spriteCellChangeSpeed: number;
  16207. /**
  16208. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16209. */
  16210. startSpriteCellID: number;
  16211. /**
  16212. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16213. */
  16214. endSpriteCellID: number;
  16215. /**
  16216. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16217. */
  16218. spriteCellWidth: number;
  16219. /**
  16220. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16221. */
  16222. spriteCellHeight: number;
  16223. /**
  16224. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16225. */
  16226. spriteRandomStartCell: boolean;
  16227. /**
  16228. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16229. */
  16230. isAnimationSheetEnabled: boolean;
  16231. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16232. translationPivot: Vector2;
  16233. /**
  16234. * Gets or sets a texture used to add random noise to particle positions
  16235. */
  16236. noiseTexture: Nullable<BaseTexture>;
  16237. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16238. noiseStrength: Vector3;
  16239. /**
  16240. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16241. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16242. */
  16243. billboardMode: number;
  16244. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16245. limitVelocityDamping: number;
  16246. /**
  16247. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16248. */
  16249. beginAnimationOnStart: boolean;
  16250. /**
  16251. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16252. */
  16253. beginAnimationFrom: number;
  16254. /**
  16255. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16256. */
  16257. beginAnimationTo: number;
  16258. /**
  16259. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16260. */
  16261. beginAnimationLoop: boolean;
  16262. /**
  16263. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16264. */
  16265. disposeOnStop: boolean;
  16266. /**
  16267. * Gets the maximum number of particles active at the same time.
  16268. * @returns The max number of active particles.
  16269. */
  16270. getCapacity(): number;
  16271. /**
  16272. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16273. * @returns True if it has been started, otherwise false.
  16274. */
  16275. isStarted(): boolean;
  16276. /**
  16277. * Animates the particle system for this frame.
  16278. */
  16279. animate(): void;
  16280. /**
  16281. * Renders the particle system in its current state.
  16282. * @returns the current number of particles
  16283. */
  16284. render(): number;
  16285. /**
  16286. * Dispose the particle system and frees its associated resources.
  16287. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16288. */
  16289. dispose(disposeTexture?: boolean): void;
  16290. /**
  16291. * Clones the particle system.
  16292. * @param name The name of the cloned object
  16293. * @param newEmitter The new emitter to use
  16294. * @returns the cloned particle system
  16295. */
  16296. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16297. /**
  16298. * Serializes the particle system to a JSON object.
  16299. * @returns the JSON object
  16300. */
  16301. serialize(): any;
  16302. /**
  16303. * Rebuild the particle system
  16304. */
  16305. rebuild(): void;
  16306. /**
  16307. * Starts the particle system and begins to emit
  16308. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16309. */
  16310. start(delay?: number): void;
  16311. /**
  16312. * Stops the particle system.
  16313. */
  16314. stop(): void;
  16315. /**
  16316. * Remove all active particles
  16317. */
  16318. reset(): void;
  16319. /**
  16320. * Is this system ready to be used/rendered
  16321. * @return true if the system is ready
  16322. */
  16323. isReady(): boolean;
  16324. /**
  16325. * Adds a new color gradient
  16326. * @param gradient defines the gradient to use (between 0 and 1)
  16327. * @param color1 defines the color to affect to the specified gradient
  16328. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16329. * @returns the current particle system
  16330. */
  16331. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16332. /**
  16333. * Remove a specific color gradient
  16334. * @param gradient defines the gradient to remove
  16335. * @returns the current particle system
  16336. */
  16337. removeColorGradient(gradient: number): IParticleSystem;
  16338. /**
  16339. * Adds a new size gradient
  16340. * @param gradient defines the gradient to use (between 0 and 1)
  16341. * @param factor defines the size factor to affect to the specified gradient
  16342. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16343. * @returns the current particle system
  16344. */
  16345. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16346. /**
  16347. * Remove a specific size gradient
  16348. * @param gradient defines the gradient to remove
  16349. * @returns the current particle system
  16350. */
  16351. removeSizeGradient(gradient: number): IParticleSystem;
  16352. /**
  16353. * Gets the current list of color gradients.
  16354. * You must use addColorGradient and removeColorGradient to udpate this list
  16355. * @returns the list of color gradients
  16356. */
  16357. getColorGradients(): Nullable<Array<ColorGradient>>;
  16358. /**
  16359. * Gets the current list of size gradients.
  16360. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16361. * @returns the list of size gradients
  16362. */
  16363. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16364. /**
  16365. * Gets the current list of angular speed gradients.
  16366. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16367. * @returns the list of angular speed gradients
  16368. */
  16369. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16370. /**
  16371. * Adds a new angular speed gradient
  16372. * @param gradient defines the gradient to use (between 0 and 1)
  16373. * @param factor defines the angular speed to affect to the specified gradient
  16374. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16375. * @returns the current particle system
  16376. */
  16377. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16378. /**
  16379. * Remove a specific angular speed gradient
  16380. * @param gradient defines the gradient to remove
  16381. * @returns the current particle system
  16382. */
  16383. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16384. /**
  16385. * Gets the current list of velocity gradients.
  16386. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16387. * @returns the list of velocity gradients
  16388. */
  16389. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16390. /**
  16391. * Adds a new velocity gradient
  16392. * @param gradient defines the gradient to use (between 0 and 1)
  16393. * @param factor defines the velocity to affect to the specified gradient
  16394. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16395. * @returns the current particle system
  16396. */
  16397. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16398. /**
  16399. * Remove a specific velocity gradient
  16400. * @param gradient defines the gradient to remove
  16401. * @returns the current particle system
  16402. */
  16403. removeVelocityGradient(gradient: number): IParticleSystem;
  16404. /**
  16405. * Gets the current list of limit velocity gradients.
  16406. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16407. * @returns the list of limit velocity gradients
  16408. */
  16409. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16410. /**
  16411. * Adds a new limit velocity gradient
  16412. * @param gradient defines the gradient to use (between 0 and 1)
  16413. * @param factor defines the limit velocity to affect to the specified gradient
  16414. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16415. * @returns the current particle system
  16416. */
  16417. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16418. /**
  16419. * Remove a specific limit velocity gradient
  16420. * @param gradient defines the gradient to remove
  16421. * @returns the current particle system
  16422. */
  16423. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16424. /**
  16425. * Adds a new drag gradient
  16426. * @param gradient defines the gradient to use (between 0 and 1)
  16427. * @param factor defines the drag to affect to the specified gradient
  16428. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16429. * @returns the current particle system
  16430. */
  16431. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16432. /**
  16433. * Remove a specific drag gradient
  16434. * @param gradient defines the gradient to remove
  16435. * @returns the current particle system
  16436. */
  16437. removeDragGradient(gradient: number): IParticleSystem;
  16438. /**
  16439. * Gets the current list of drag gradients.
  16440. * You must use addDragGradient and removeDragGradient to udpate this list
  16441. * @returns the list of drag gradients
  16442. */
  16443. getDragGradients(): Nullable<Array<FactorGradient>>;
  16444. /**
  16445. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16446. * @param gradient defines the gradient to use (between 0 and 1)
  16447. * @param factor defines the emit rate to affect to the specified gradient
  16448. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16449. * @returns the current particle system
  16450. */
  16451. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16452. /**
  16453. * Remove a specific emit rate gradient
  16454. * @param gradient defines the gradient to remove
  16455. * @returns the current particle system
  16456. */
  16457. removeEmitRateGradient(gradient: number): IParticleSystem;
  16458. /**
  16459. * Gets the current list of emit rate gradients.
  16460. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16461. * @returns the list of emit rate gradients
  16462. */
  16463. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16464. /**
  16465. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16466. * @param gradient defines the gradient to use (between 0 and 1)
  16467. * @param factor defines the start size to affect to the specified gradient
  16468. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16469. * @returns the current particle system
  16470. */
  16471. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16472. /**
  16473. * Remove a specific start size gradient
  16474. * @param gradient defines the gradient to remove
  16475. * @returns the current particle system
  16476. */
  16477. removeStartSizeGradient(gradient: number): IParticleSystem;
  16478. /**
  16479. * Gets the current list of start size gradients.
  16480. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16481. * @returns the list of start size gradients
  16482. */
  16483. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16484. /**
  16485. * Adds a new life time gradient
  16486. * @param gradient defines the gradient to use (between 0 and 1)
  16487. * @param factor defines the life time factor to affect to the specified gradient
  16488. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16489. * @returns the current particle system
  16490. */
  16491. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16492. /**
  16493. * Remove a specific life time gradient
  16494. * @param gradient defines the gradient to remove
  16495. * @returns the current particle system
  16496. */
  16497. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16498. /**
  16499. * Gets the current list of life time gradients.
  16500. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16501. * @returns the list of life time gradients
  16502. */
  16503. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16504. /**
  16505. * Gets the current list of color gradients.
  16506. * You must use addColorGradient and removeColorGradient to udpate this list
  16507. * @returns the list of color gradients
  16508. */
  16509. getColorGradients(): Nullable<Array<ColorGradient>>;
  16510. /**
  16511. * Adds a new ramp gradient used to remap particle colors
  16512. * @param gradient defines the gradient to use (between 0 and 1)
  16513. * @param color defines the color to affect to the specified gradient
  16514. * @returns the current particle system
  16515. */
  16516. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16517. /**
  16518. * Gets the current list of ramp gradients.
  16519. * You must use addRampGradient and removeRampGradient to udpate this list
  16520. * @returns the list of ramp gradients
  16521. */
  16522. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16523. /** Gets or sets a boolean indicating that ramp gradients must be used
  16524. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16525. */
  16526. useRampGradients: boolean;
  16527. /**
  16528. * Adds a new color remap gradient
  16529. * @param gradient defines the gradient to use (between 0 and 1)
  16530. * @param min defines the color remap minimal range
  16531. * @param max defines the color remap maximal range
  16532. * @returns the current particle system
  16533. */
  16534. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16535. /**
  16536. * Gets the current list of color remap gradients.
  16537. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16538. * @returns the list of color remap gradients
  16539. */
  16540. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16541. /**
  16542. * Adds a new alpha remap gradient
  16543. * @param gradient defines the gradient to use (between 0 and 1)
  16544. * @param min defines the alpha remap minimal range
  16545. * @param max defines the alpha remap maximal range
  16546. * @returns the current particle system
  16547. */
  16548. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16549. /**
  16550. * Gets the current list of alpha remap gradients.
  16551. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16552. * @returns the list of alpha remap gradients
  16553. */
  16554. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16555. /**
  16556. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16557. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16558. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16559. * @returns the emitter
  16560. */
  16561. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16562. /**
  16563. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16564. * @param radius The radius of the hemisphere to emit from
  16565. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16566. * @returns the emitter
  16567. */
  16568. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16569. /**
  16570. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16571. * @param radius The radius of the sphere to emit from
  16572. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16573. * @returns the emitter
  16574. */
  16575. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16576. /**
  16577. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16578. * @param radius The radius of the sphere to emit from
  16579. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16580. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16581. * @returns the emitter
  16582. */
  16583. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16584. /**
  16585. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16586. * @param radius The radius of the emission cylinder
  16587. * @param height The height of the emission cylinder
  16588. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16589. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16590. * @returns the emitter
  16591. */
  16592. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16593. /**
  16594. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16595. * @param radius The radius of the cylinder to emit from
  16596. * @param height The height of the emission cylinder
  16597. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16598. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16599. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16600. * @returns the emitter
  16601. */
  16602. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16603. /**
  16604. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16605. * @param radius The radius of the cone to emit from
  16606. * @param angle The base angle of the cone
  16607. * @returns the emitter
  16608. */
  16609. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16610. /**
  16611. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16612. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16613. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16614. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16615. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16616. * @returns the emitter
  16617. */
  16618. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16619. /**
  16620. * Get hosting scene
  16621. * @returns the scene
  16622. */
  16623. getScene(): Scene;
  16624. }
  16625. }
  16626. declare module "babylonjs/Meshes/instancedMesh" {
  16627. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16628. import { Vector3 } from "babylonjs/Maths/math";
  16629. import { Camera } from "babylonjs/Cameras/camera";
  16630. import { Node } from "babylonjs/node";
  16631. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16632. import { Mesh } from "babylonjs/Meshes/mesh";
  16633. import { Material } from "babylonjs/Materials/material";
  16634. import { Skeleton } from "babylonjs/Bones/skeleton";
  16635. /**
  16636. * Creates an instance based on a source mesh.
  16637. */
  16638. export class InstancedMesh extends AbstractMesh {
  16639. private _sourceMesh;
  16640. private _currentLOD;
  16641. /** @hidden */
  16642. _indexInSourceMeshInstanceArray: number;
  16643. constructor(name: string, source: Mesh);
  16644. /**
  16645. * Returns the string "InstancedMesh".
  16646. */
  16647. getClassName(): string;
  16648. /**
  16649. * If the source mesh receives shadows
  16650. */
  16651. readonly receiveShadows: boolean;
  16652. /**
  16653. * The material of the source mesh
  16654. */
  16655. readonly material: Nullable<Material>;
  16656. /**
  16657. * Visibility of the source mesh
  16658. */
  16659. readonly visibility: number;
  16660. /**
  16661. * Skeleton of the source mesh
  16662. */
  16663. readonly skeleton: Nullable<Skeleton>;
  16664. /**
  16665. * Rendering ground id of the source mesh
  16666. */
  16667. renderingGroupId: number;
  16668. /**
  16669. * Returns the total number of vertices (integer).
  16670. */
  16671. getTotalVertices(): number;
  16672. /**
  16673. * Returns a positive integer : the total number of indices in this mesh geometry.
  16674. * @returns the numner of indices or zero if the mesh has no geometry.
  16675. */
  16676. getTotalIndices(): number;
  16677. /**
  16678. * The source mesh of the instance
  16679. */
  16680. readonly sourceMesh: Mesh;
  16681. /**
  16682. * Is this node ready to be used/rendered
  16683. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16684. * @return {boolean} is it ready
  16685. */
  16686. isReady(completeCheck?: boolean): boolean;
  16687. /**
  16688. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16689. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16690. * @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.
  16691. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16692. */
  16693. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16694. /**
  16695. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16696. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16697. * The `data` are either a numeric array either a Float32Array.
  16698. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16699. * 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).
  16700. * Note that a new underlying VertexBuffer object is created each call.
  16701. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16702. *
  16703. * Possible `kind` values :
  16704. * - VertexBuffer.PositionKind
  16705. * - VertexBuffer.UVKind
  16706. * - VertexBuffer.UV2Kind
  16707. * - VertexBuffer.UV3Kind
  16708. * - VertexBuffer.UV4Kind
  16709. * - VertexBuffer.UV5Kind
  16710. * - VertexBuffer.UV6Kind
  16711. * - VertexBuffer.ColorKind
  16712. * - VertexBuffer.MatricesIndicesKind
  16713. * - VertexBuffer.MatricesIndicesExtraKind
  16714. * - VertexBuffer.MatricesWeightsKind
  16715. * - VertexBuffer.MatricesWeightsExtraKind
  16716. *
  16717. * Returns the Mesh.
  16718. */
  16719. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16720. /**
  16721. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16722. * If the mesh has no geometry, it is simply returned as it is.
  16723. * The `data` are either a numeric array either a Float32Array.
  16724. * No new underlying VertexBuffer object is created.
  16725. * 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.
  16726. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16727. *
  16728. * Possible `kind` values :
  16729. * - VertexBuffer.PositionKind
  16730. * - VertexBuffer.UVKind
  16731. * - VertexBuffer.UV2Kind
  16732. * - VertexBuffer.UV3Kind
  16733. * - VertexBuffer.UV4Kind
  16734. * - VertexBuffer.UV5Kind
  16735. * - VertexBuffer.UV6Kind
  16736. * - VertexBuffer.ColorKind
  16737. * - VertexBuffer.MatricesIndicesKind
  16738. * - VertexBuffer.MatricesIndicesExtraKind
  16739. * - VertexBuffer.MatricesWeightsKind
  16740. * - VertexBuffer.MatricesWeightsExtraKind
  16741. *
  16742. * Returns the Mesh.
  16743. */
  16744. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16745. /**
  16746. * Sets the mesh indices.
  16747. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16748. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16749. * This method creates a new index buffer each call.
  16750. * Returns the Mesh.
  16751. */
  16752. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16753. /**
  16754. * Boolean : True if the mesh owns the requested kind of data.
  16755. */
  16756. isVerticesDataPresent(kind: string): boolean;
  16757. /**
  16758. * Returns an array of indices (IndicesArray).
  16759. */
  16760. getIndices(): Nullable<IndicesArray>;
  16761. readonly _positions: Nullable<Vector3[]>;
  16762. /**
  16763. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16764. * This means the mesh underlying bounding box and sphere are recomputed.
  16765. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16766. * @returns the current mesh
  16767. */
  16768. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16769. /** @hidden */
  16770. _preActivate(): InstancedMesh;
  16771. /** @hidden */
  16772. _activate(renderId: number): InstancedMesh;
  16773. /**
  16774. * Returns the current associated LOD AbstractMesh.
  16775. */
  16776. getLOD(camera: Camera): AbstractMesh;
  16777. /** @hidden */
  16778. _syncSubMeshes(): InstancedMesh;
  16779. /** @hidden */
  16780. _generatePointsArray(): boolean;
  16781. /**
  16782. * Creates a new InstancedMesh from the current mesh.
  16783. * - name (string) : the cloned mesh name
  16784. * - newParent (optional Node) : the optional Node to parent the clone to.
  16785. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16786. *
  16787. * Returns the clone.
  16788. */
  16789. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16790. /**
  16791. * Disposes the InstancedMesh.
  16792. * Returns nothing.
  16793. */
  16794. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16795. }
  16796. }
  16797. declare module "babylonjs/Materials/shaderMaterial" {
  16798. import { Scene } from "babylonjs/scene";
  16799. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  16800. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16801. import { Mesh } from "babylonjs/Meshes/mesh";
  16802. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16803. import { Texture } from "babylonjs/Materials/Textures/texture";
  16804. import { Material } from "babylonjs/Materials/material";
  16805. /**
  16806. * Defines the options associated with the creation of a shader material.
  16807. */
  16808. export interface IShaderMaterialOptions {
  16809. /**
  16810. * Does the material work in alpha blend mode
  16811. */
  16812. needAlphaBlending: boolean;
  16813. /**
  16814. * Does the material work in alpha test mode
  16815. */
  16816. needAlphaTesting: boolean;
  16817. /**
  16818. * The list of attribute names used in the shader
  16819. */
  16820. attributes: string[];
  16821. /**
  16822. * The list of unifrom names used in the shader
  16823. */
  16824. uniforms: string[];
  16825. /**
  16826. * The list of UBO names used in the shader
  16827. */
  16828. uniformBuffers: string[];
  16829. /**
  16830. * The list of sampler names used in the shader
  16831. */
  16832. samplers: string[];
  16833. /**
  16834. * The list of defines used in the shader
  16835. */
  16836. defines: string[];
  16837. }
  16838. /**
  16839. * 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.
  16840. *
  16841. * This returned material effects how the mesh will look based on the code in the shaders.
  16842. *
  16843. * @see http://doc.babylonjs.com/how_to/shader_material
  16844. */
  16845. export class ShaderMaterial extends Material {
  16846. private _shaderPath;
  16847. private _options;
  16848. private _textures;
  16849. private _textureArrays;
  16850. private _floats;
  16851. private _ints;
  16852. private _floatsArrays;
  16853. private _colors3;
  16854. private _colors3Arrays;
  16855. private _colors4;
  16856. private _vectors2;
  16857. private _vectors3;
  16858. private _vectors4;
  16859. private _matrices;
  16860. private _matrices3x3;
  16861. private _matrices2x2;
  16862. private _vectors2Arrays;
  16863. private _vectors3Arrays;
  16864. private _cachedWorldViewMatrix;
  16865. private _renderId;
  16866. /**
  16867. * Instantiate a new shader material.
  16868. * 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.
  16869. * This returned material effects how the mesh will look based on the code in the shaders.
  16870. * @see http://doc.babylonjs.com/how_to/shader_material
  16871. * @param name Define the name of the material in the scene
  16872. * @param scene Define the scene the material belongs to
  16873. * @param shaderPath Defines the route to the shader code in one of three ways:
  16874. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16875. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16876. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16877. * @param options Define the options used to create the shader
  16878. */
  16879. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16880. /**
  16881. * Gets the options used to compile the shader.
  16882. * They can be modified to trigger a new compilation
  16883. */
  16884. readonly options: IShaderMaterialOptions;
  16885. /**
  16886. * Gets the current class name of the material e.g. "ShaderMaterial"
  16887. * Mainly use in serialization.
  16888. * @returns the class name
  16889. */
  16890. getClassName(): string;
  16891. /**
  16892. * Specifies if the material will require alpha blending
  16893. * @returns a boolean specifying if alpha blending is needed
  16894. */
  16895. needAlphaBlending(): boolean;
  16896. /**
  16897. * Specifies if this material should be rendered in alpha test mode
  16898. * @returns a boolean specifying if an alpha test is needed.
  16899. */
  16900. needAlphaTesting(): boolean;
  16901. private _checkUniform;
  16902. /**
  16903. * Set a texture in the shader.
  16904. * @param name Define the name of the uniform samplers as defined in the shader
  16905. * @param texture Define the texture to bind to this sampler
  16906. * @return the material itself allowing "fluent" like uniform updates
  16907. */
  16908. setTexture(name: string, texture: Texture): ShaderMaterial;
  16909. /**
  16910. * Set a texture array in the shader.
  16911. * @param name Define the name of the uniform sampler array as defined in the shader
  16912. * @param textures Define the list of textures to bind to this sampler
  16913. * @return the material itself allowing "fluent" like uniform updates
  16914. */
  16915. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16916. /**
  16917. * Set a float in the shader.
  16918. * @param name Define the name of the uniform as defined in the shader
  16919. * @param value Define the value to give to the uniform
  16920. * @return the material itself allowing "fluent" like uniform updates
  16921. */
  16922. setFloat(name: string, value: number): ShaderMaterial;
  16923. /**
  16924. * Set a int in the shader.
  16925. * @param name Define the name of the uniform as defined in the shader
  16926. * @param value Define the value to give to the uniform
  16927. * @return the material itself allowing "fluent" like uniform updates
  16928. */
  16929. setInt(name: string, value: number): ShaderMaterial;
  16930. /**
  16931. * Set an array of floats in the shader.
  16932. * @param name Define the name of the uniform as defined in the shader
  16933. * @param value Define the value to give to the uniform
  16934. * @return the material itself allowing "fluent" like uniform updates
  16935. */
  16936. setFloats(name: string, value: number[]): ShaderMaterial;
  16937. /**
  16938. * Set a vec3 in the shader from a Color3.
  16939. * @param name Define the name of the uniform as defined in the shader
  16940. * @param value Define the value to give to the uniform
  16941. * @return the material itself allowing "fluent" like uniform updates
  16942. */
  16943. setColor3(name: string, value: Color3): ShaderMaterial;
  16944. /**
  16945. * Set a vec3 array in the shader from a Color3 array.
  16946. * @param name Define the name of the uniform as defined in the shader
  16947. * @param value Define the value to give to the uniform
  16948. * @return the material itself allowing "fluent" like uniform updates
  16949. */
  16950. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16951. /**
  16952. * Set a vec4 in the shader from a Color4.
  16953. * @param name Define the name of the uniform as defined in the shader
  16954. * @param value Define the value to give to the uniform
  16955. * @return the material itself allowing "fluent" like uniform updates
  16956. */
  16957. setColor4(name: string, value: Color4): ShaderMaterial;
  16958. /**
  16959. * Set a vec2 in the shader from a Vector2.
  16960. * @param name Define the name of the uniform as defined in the shader
  16961. * @param value Define the value to give to the uniform
  16962. * @return the material itself allowing "fluent" like uniform updates
  16963. */
  16964. setVector2(name: string, value: Vector2): ShaderMaterial;
  16965. /**
  16966. * Set a vec3 in the shader from a Vector3.
  16967. * @param name Define the name of the uniform as defined in the shader
  16968. * @param value Define the value to give to the uniform
  16969. * @return the material itself allowing "fluent" like uniform updates
  16970. */
  16971. setVector3(name: string, value: Vector3): ShaderMaterial;
  16972. /**
  16973. * Set a vec4 in the shader from a Vector4.
  16974. * @param name Define the name of the uniform as defined in the shader
  16975. * @param value Define the value to give to the uniform
  16976. * @return the material itself allowing "fluent" like uniform updates
  16977. */
  16978. setVector4(name: string, value: Vector4): ShaderMaterial;
  16979. /**
  16980. * Set a mat4 in the shader from a Matrix.
  16981. * @param name Define the name of the uniform as defined in the shader
  16982. * @param value Define the value to give to the uniform
  16983. * @return the material itself allowing "fluent" like uniform updates
  16984. */
  16985. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16986. /**
  16987. * Set a mat3 in the shader from a Float32Array.
  16988. * @param name Define the name of the uniform as defined in the shader
  16989. * @param value Define the value to give to the uniform
  16990. * @return the material itself allowing "fluent" like uniform updates
  16991. */
  16992. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16993. /**
  16994. * Set a mat2 in the shader from a Float32Array.
  16995. * @param name Define the name of the uniform as defined in the shader
  16996. * @param value Define the value to give to the uniform
  16997. * @return the material itself allowing "fluent" like uniform updates
  16998. */
  16999. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17000. /**
  17001. * Set a vec2 array in the shader from a number array.
  17002. * @param name Define the name of the uniform as defined in the shader
  17003. * @param value Define the value to give to the uniform
  17004. * @return the material itself allowing "fluent" like uniform updates
  17005. */
  17006. setArray2(name: string, value: number[]): ShaderMaterial;
  17007. /**
  17008. * Set a vec3 array in the shader from a number array.
  17009. * @param name Define the name of the uniform as defined in the shader
  17010. * @param value Define the value to give to the uniform
  17011. * @return the material itself allowing "fluent" like uniform updates
  17012. */
  17013. setArray3(name: string, value: number[]): ShaderMaterial;
  17014. private _checkCache;
  17015. /**
  17016. * Checks if the material is ready to render the requested mesh
  17017. * @param mesh Define the mesh to render
  17018. * @param useInstances Define whether or not the material is used with instances
  17019. * @returns true if ready, otherwise false
  17020. */
  17021. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17022. /**
  17023. * Binds the world matrix to the material
  17024. * @param world defines the world transformation matrix
  17025. */
  17026. bindOnlyWorldMatrix(world: Matrix): void;
  17027. /**
  17028. * Binds the material to the mesh
  17029. * @param world defines the world transformation matrix
  17030. * @param mesh defines the mesh to bind the material to
  17031. */
  17032. bind(world: Matrix, mesh?: Mesh): void;
  17033. /**
  17034. * Gets the active textures from the material
  17035. * @returns an array of textures
  17036. */
  17037. getActiveTextures(): BaseTexture[];
  17038. /**
  17039. * Specifies if the material uses a texture
  17040. * @param texture defines the texture to check against the material
  17041. * @returns a boolean specifying if the material uses the texture
  17042. */
  17043. hasTexture(texture: BaseTexture): boolean;
  17044. /**
  17045. * Makes a duplicate of the material, and gives it a new name
  17046. * @param name defines the new name for the duplicated material
  17047. * @returns the cloned material
  17048. */
  17049. clone(name: string): ShaderMaterial;
  17050. /**
  17051. * Disposes the material
  17052. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17053. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17054. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17055. */
  17056. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17057. /**
  17058. * Serializes this material in a JSON representation
  17059. * @returns the serialized material object
  17060. */
  17061. serialize(): any;
  17062. /**
  17063. * Creates a shader material from parsed shader material data
  17064. * @param source defines the JSON represnetation of the material
  17065. * @param scene defines the hosting scene
  17066. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17067. * @returns a new material
  17068. */
  17069. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17070. }
  17071. }
  17072. declare module "babylonjs/Shaders/color.fragment" {
  17073. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17074. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17075. /** @hidden */
  17076. export var colorPixelShader: {
  17077. name: string;
  17078. shader: string;
  17079. };
  17080. }
  17081. declare module "babylonjs/Shaders/color.vertex" {
  17082. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17083. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17084. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17085. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17086. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17087. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17088. /** @hidden */
  17089. export var colorVertexShader: {
  17090. name: string;
  17091. shader: string;
  17092. };
  17093. }
  17094. declare module "babylonjs/Meshes/linesMesh" {
  17095. import { Nullable } from "babylonjs/types";
  17096. import { Scene } from "babylonjs/scene";
  17097. import { Color3 } from "babylonjs/Maths/math";
  17098. import { Node } from "babylonjs/node";
  17099. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17100. import { Mesh } from "babylonjs/Meshes/mesh";
  17101. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17102. import { Effect } from "babylonjs/Materials/effect";
  17103. import { Material } from "babylonjs/Materials/material";
  17104. import "babylonjs/Shaders/color.fragment";
  17105. import "babylonjs/Shaders/color.vertex";
  17106. /**
  17107. * Line mesh
  17108. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17109. */
  17110. export class LinesMesh extends Mesh {
  17111. /**
  17112. * If vertex color should be applied to the mesh
  17113. */
  17114. useVertexColor?: boolean | undefined;
  17115. /**
  17116. * If vertex alpha should be applied to the mesh
  17117. */
  17118. useVertexAlpha?: boolean | undefined;
  17119. /**
  17120. * Color of the line (Default: White)
  17121. */
  17122. color: Color3;
  17123. /**
  17124. * Alpha of the line (Default: 1)
  17125. */
  17126. alpha: number;
  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. * Default value is 0.1
  17131. */
  17132. intersectionThreshold: number;
  17133. private _colorShader;
  17134. /**
  17135. * Creates a new LinesMesh
  17136. * @param name defines the name
  17137. * @param scene defines the hosting scene
  17138. * @param parent defines the parent mesh if any
  17139. * @param source defines the optional source LinesMesh used to clone data from
  17140. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17141. * When false, achieved by calling a clone(), also passing False.
  17142. * This will make creation of children, recursive.
  17143. * @param useVertexColor defines if this LinesMesh supports vertex color
  17144. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17145. */
  17146. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17147. /**
  17148. * If vertex color should be applied to the mesh
  17149. */
  17150. useVertexColor?: boolean | undefined,
  17151. /**
  17152. * If vertex alpha should be applied to the mesh
  17153. */
  17154. useVertexAlpha?: boolean | undefined);
  17155. private _addClipPlaneDefine;
  17156. private _removeClipPlaneDefine;
  17157. isReady(): boolean;
  17158. /**
  17159. * Returns the string "LineMesh"
  17160. */
  17161. getClassName(): string;
  17162. /**
  17163. * @hidden
  17164. */
  17165. /**
  17166. * @hidden
  17167. */
  17168. material: Material;
  17169. /**
  17170. * @hidden
  17171. */
  17172. readonly checkCollisions: boolean;
  17173. /** @hidden */
  17174. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17175. /** @hidden */
  17176. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17177. /**
  17178. * Disposes of the line mesh
  17179. * @param doNotRecurse If children should be disposed
  17180. */
  17181. dispose(doNotRecurse?: boolean): void;
  17182. /**
  17183. * Returns a new LineMesh object cloned from the current one.
  17184. */
  17185. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17186. /**
  17187. * Creates a new InstancedLinesMesh object from the mesh model.
  17188. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17189. * @param name defines the name of the new instance
  17190. * @returns a new InstancedLinesMesh
  17191. */
  17192. createInstance(name: string): InstancedLinesMesh;
  17193. }
  17194. /**
  17195. * Creates an instance based on a source LinesMesh
  17196. */
  17197. export class InstancedLinesMesh extends InstancedMesh {
  17198. /**
  17199. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17200. * This margin is expressed in world space coordinates, so its value may vary.
  17201. * Initilized with the intersectionThreshold value of the source LinesMesh
  17202. */
  17203. intersectionThreshold: number;
  17204. constructor(name: string, source: LinesMesh);
  17205. /**
  17206. * Returns the string "InstancedLinesMesh".
  17207. */
  17208. getClassName(): string;
  17209. }
  17210. }
  17211. declare module "babylonjs/Shaders/line.fragment" {
  17212. /** @hidden */
  17213. export var linePixelShader: {
  17214. name: string;
  17215. shader: string;
  17216. };
  17217. }
  17218. declare module "babylonjs/Shaders/line.vertex" {
  17219. /** @hidden */
  17220. export var lineVertexShader: {
  17221. name: string;
  17222. shader: string;
  17223. };
  17224. }
  17225. declare module "babylonjs/Rendering/edgesRenderer" {
  17226. import { Nullable } from "babylonjs/types";
  17227. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17228. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17229. import { Vector3 } from "babylonjs/Maths/math";
  17230. import { IDisposable } from "babylonjs/scene";
  17231. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17232. import "babylonjs/Shaders/line.fragment";
  17233. import "babylonjs/Shaders/line.vertex";
  17234. module "babylonjs/Meshes/abstractMesh" {
  17235. interface AbstractMesh {
  17236. /**
  17237. * Disables the mesh edge rendering mode
  17238. * @returns the currentAbstractMesh
  17239. */
  17240. disableEdgesRendering(): AbstractMesh;
  17241. /**
  17242. * Enables the edge rendering mode on the mesh.
  17243. * This mode makes the mesh edges visible
  17244. * @param epsilon defines the maximal distance between two angles to detect a face
  17245. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17246. * @returns the currentAbstractMesh
  17247. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17248. */
  17249. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17250. /**
  17251. * Gets the edgesRenderer associated with the mesh
  17252. */
  17253. edgesRenderer: Nullable<EdgesRenderer>;
  17254. }
  17255. }
  17256. module "babylonjs/Meshes/linesMesh" {
  17257. interface LinesMesh {
  17258. /**
  17259. * Enables the edge rendering mode on the mesh.
  17260. * This mode makes the mesh edges visible
  17261. * @param epsilon defines the maximal distance between two angles to detect a face
  17262. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17263. * @returns the currentAbstractMesh
  17264. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17265. */
  17266. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17267. }
  17268. }
  17269. module "babylonjs/Meshes/linesMesh" {
  17270. interface InstancedLinesMesh {
  17271. /**
  17272. * Enables the edge rendering mode on the mesh.
  17273. * This mode makes the mesh edges visible
  17274. * @param epsilon defines the maximal distance between two angles to detect a face
  17275. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17276. * @returns the current InstancedLinesMesh
  17277. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17278. */
  17279. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17280. }
  17281. }
  17282. /**
  17283. * Defines the minimum contract an Edges renderer should follow.
  17284. */
  17285. export interface IEdgesRenderer extends IDisposable {
  17286. /**
  17287. * Gets or sets a boolean indicating if the edgesRenderer is active
  17288. */
  17289. isEnabled: boolean;
  17290. /**
  17291. * Renders the edges of the attached mesh,
  17292. */
  17293. render(): void;
  17294. /**
  17295. * Checks wether or not the edges renderer is ready to render.
  17296. * @return true if ready, otherwise false.
  17297. */
  17298. isReady(): boolean;
  17299. }
  17300. /**
  17301. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17302. */
  17303. export class EdgesRenderer implements IEdgesRenderer {
  17304. /**
  17305. * Define the size of the edges with an orthographic camera
  17306. */
  17307. edgesWidthScalerForOrthographic: number;
  17308. /**
  17309. * Define the size of the edges with a perspective camera
  17310. */
  17311. edgesWidthScalerForPerspective: number;
  17312. protected _source: AbstractMesh;
  17313. protected _linesPositions: number[];
  17314. protected _linesNormals: number[];
  17315. protected _linesIndices: number[];
  17316. protected _epsilon: number;
  17317. protected _indicesCount: number;
  17318. protected _lineShader: ShaderMaterial;
  17319. protected _ib: WebGLBuffer;
  17320. protected _buffers: {
  17321. [key: string]: Nullable<VertexBuffer>;
  17322. };
  17323. protected _checkVerticesInsteadOfIndices: boolean;
  17324. private _meshRebuildObserver;
  17325. private _meshDisposeObserver;
  17326. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17327. isEnabled: boolean;
  17328. /**
  17329. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17330. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17331. * @param source Mesh used to create edges
  17332. * @param epsilon sum of angles in adjacency to check for edge
  17333. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17334. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17335. */
  17336. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17337. protected _prepareRessources(): void;
  17338. /** @hidden */
  17339. _rebuild(): void;
  17340. /**
  17341. * Releases the required resources for the edges renderer
  17342. */
  17343. dispose(): void;
  17344. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17345. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17346. /**
  17347. * Checks if the pair of p0 and p1 is en edge
  17348. * @param faceIndex
  17349. * @param edge
  17350. * @param faceNormals
  17351. * @param p0
  17352. * @param p1
  17353. * @private
  17354. */
  17355. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17356. /**
  17357. * push line into the position, normal and index buffer
  17358. * @protected
  17359. */
  17360. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17361. /**
  17362. * Generates lines edges from adjacencjes
  17363. * @private
  17364. */
  17365. _generateEdgesLines(): void;
  17366. /**
  17367. * Checks wether or not the edges renderer is ready to render.
  17368. * @return true if ready, otherwise false.
  17369. */
  17370. isReady(): boolean;
  17371. /**
  17372. * Renders the edges of the attached mesh,
  17373. */
  17374. render(): void;
  17375. }
  17376. /**
  17377. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17378. */
  17379. export class LineEdgesRenderer extends EdgesRenderer {
  17380. /**
  17381. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17382. * @param source LineMesh used to generate edges
  17383. * @param epsilon not important (specified angle for edge detection)
  17384. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17385. */
  17386. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17387. /**
  17388. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17389. */
  17390. _generateEdgesLines(): void;
  17391. }
  17392. }
  17393. declare module "babylonjs/Rendering/renderingGroup" {
  17394. import { SmartArray } from "babylonjs/Misc/smartArray";
  17395. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17396. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17397. import { Nullable } from "babylonjs/types";
  17398. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17399. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17400. import { Material } from "babylonjs/Materials/material";
  17401. import { Scene } from "babylonjs/scene";
  17402. /**
  17403. * This represents the object necessary to create a rendering group.
  17404. * This is exclusively used and created by the rendering manager.
  17405. * To modify the behavior, you use the available helpers in your scene or meshes.
  17406. * @hidden
  17407. */
  17408. export class RenderingGroup {
  17409. index: number;
  17410. private _scene;
  17411. private _opaqueSubMeshes;
  17412. private _transparentSubMeshes;
  17413. private _alphaTestSubMeshes;
  17414. private _depthOnlySubMeshes;
  17415. private _particleSystems;
  17416. private _spriteManagers;
  17417. private _opaqueSortCompareFn;
  17418. private _alphaTestSortCompareFn;
  17419. private _transparentSortCompareFn;
  17420. private _renderOpaque;
  17421. private _renderAlphaTest;
  17422. private _renderTransparent;
  17423. private _edgesRenderers;
  17424. onBeforeTransparentRendering: () => void;
  17425. /**
  17426. * Set the opaque sort comparison function.
  17427. * If null the sub meshes will be render in the order they were created
  17428. */
  17429. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17430. /**
  17431. * Set the alpha test sort comparison function.
  17432. * If null the sub meshes will be render in the order they were created
  17433. */
  17434. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17435. /**
  17436. * Set the transparent sort comparison function.
  17437. * If null the sub meshes will be render in the order they were created
  17438. */
  17439. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17440. /**
  17441. * Creates a new rendering group.
  17442. * @param index The rendering group index
  17443. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17444. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17445. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17446. */
  17447. 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>);
  17448. /**
  17449. * Render all the sub meshes contained in the group.
  17450. * @param customRenderFunction Used to override the default render behaviour of the group.
  17451. * @returns true if rendered some submeshes.
  17452. */
  17453. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17454. /**
  17455. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17456. * @param subMeshes The submeshes to render
  17457. */
  17458. private renderOpaqueSorted;
  17459. /**
  17460. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17461. * @param subMeshes The submeshes to render
  17462. */
  17463. private renderAlphaTestSorted;
  17464. /**
  17465. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17466. * @param subMeshes The submeshes to render
  17467. */
  17468. private renderTransparentSorted;
  17469. /**
  17470. * Renders the submeshes in a specified order.
  17471. * @param subMeshes The submeshes to sort before render
  17472. * @param sortCompareFn The comparison function use to sort
  17473. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17474. * @param transparent Specifies to activate blending if true
  17475. */
  17476. private static renderSorted;
  17477. /**
  17478. * Renders the submeshes in the order they were dispatched (no sort applied).
  17479. * @param subMeshes The submeshes to render
  17480. */
  17481. private static renderUnsorted;
  17482. /**
  17483. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17484. * are rendered back to front if in the same alpha index.
  17485. *
  17486. * @param a The first submesh
  17487. * @param b The second submesh
  17488. * @returns The result of the comparison
  17489. */
  17490. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17491. /**
  17492. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17493. * are rendered back to front.
  17494. *
  17495. * @param a The first submesh
  17496. * @param b The second submesh
  17497. * @returns The result of the comparison
  17498. */
  17499. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17500. /**
  17501. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17502. * are rendered front to back (prevent overdraw).
  17503. *
  17504. * @param a The first submesh
  17505. * @param b The second submesh
  17506. * @returns The result of the comparison
  17507. */
  17508. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17509. /**
  17510. * Resets the different lists of submeshes to prepare a new frame.
  17511. */
  17512. prepare(): void;
  17513. dispose(): void;
  17514. /**
  17515. * Inserts the submesh in its correct queue depending on its material.
  17516. * @param subMesh The submesh to dispatch
  17517. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17518. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17519. */
  17520. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17521. dispatchSprites(spriteManager: ISpriteManager): void;
  17522. dispatchParticles(particleSystem: IParticleSystem): void;
  17523. private _renderParticles;
  17524. private _renderSprites;
  17525. }
  17526. }
  17527. declare module "babylonjs/Rendering/renderingManager" {
  17528. import { Nullable } from "babylonjs/types";
  17529. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17530. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17531. import { SmartArray } from "babylonjs/Misc/smartArray";
  17532. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17533. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17534. import { Material } from "babylonjs/Materials/material";
  17535. import { Scene } from "babylonjs/scene";
  17536. import { Camera } from "babylonjs/Cameras/camera";
  17537. /**
  17538. * Interface describing the different options available in the rendering manager
  17539. * regarding Auto Clear between groups.
  17540. */
  17541. export interface IRenderingManagerAutoClearSetup {
  17542. /**
  17543. * Defines whether or not autoclear is enable.
  17544. */
  17545. autoClear: boolean;
  17546. /**
  17547. * Defines whether or not to autoclear the depth buffer.
  17548. */
  17549. depth: boolean;
  17550. /**
  17551. * Defines whether or not to autoclear the stencil buffer.
  17552. */
  17553. stencil: boolean;
  17554. }
  17555. /**
  17556. * This class is used by the onRenderingGroupObservable
  17557. */
  17558. export class RenderingGroupInfo {
  17559. /**
  17560. * The Scene that being rendered
  17561. */
  17562. scene: Scene;
  17563. /**
  17564. * The camera currently used for the rendering pass
  17565. */
  17566. camera: Nullable<Camera>;
  17567. /**
  17568. * The ID of the renderingGroup being processed
  17569. */
  17570. renderingGroupId: number;
  17571. }
  17572. /**
  17573. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17574. * It is enable to manage the different groups as well as the different necessary sort functions.
  17575. * This should not be used directly aside of the few static configurations
  17576. */
  17577. export class RenderingManager {
  17578. /**
  17579. * The max id used for rendering groups (not included)
  17580. */
  17581. static MAX_RENDERINGGROUPS: number;
  17582. /**
  17583. * The min id used for rendering groups (included)
  17584. */
  17585. static MIN_RENDERINGGROUPS: number;
  17586. /**
  17587. * Used to globally prevent autoclearing scenes.
  17588. */
  17589. static AUTOCLEAR: boolean;
  17590. /**
  17591. * @hidden
  17592. */
  17593. _useSceneAutoClearSetup: boolean;
  17594. private _scene;
  17595. private _renderingGroups;
  17596. private _depthStencilBufferAlreadyCleaned;
  17597. private _autoClearDepthStencil;
  17598. private _customOpaqueSortCompareFn;
  17599. private _customAlphaTestSortCompareFn;
  17600. private _customTransparentSortCompareFn;
  17601. private _renderingGroupInfo;
  17602. /**
  17603. * Instantiates a new rendering group for a particular scene
  17604. * @param scene Defines the scene the groups belongs to
  17605. */
  17606. constructor(scene: Scene);
  17607. private _clearDepthStencilBuffer;
  17608. /**
  17609. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17610. * @hidden
  17611. */
  17612. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17613. /**
  17614. * Resets the different information of the group to prepare a new frame
  17615. * @hidden
  17616. */
  17617. reset(): void;
  17618. /**
  17619. * Dispose and release the group and its associated resources.
  17620. * @hidden
  17621. */
  17622. dispose(): void;
  17623. /**
  17624. * Clear the info related to rendering groups preventing retention points during dispose.
  17625. */
  17626. freeRenderingGroups(): void;
  17627. private _prepareRenderingGroup;
  17628. /**
  17629. * Add a sprite manager to the rendering manager in order to render it this frame.
  17630. * @param spriteManager Define the sprite manager to render
  17631. */
  17632. dispatchSprites(spriteManager: ISpriteManager): void;
  17633. /**
  17634. * Add a particle system to the rendering manager in order to render it this frame.
  17635. * @param particleSystem Define the particle system to render
  17636. */
  17637. dispatchParticles(particleSystem: IParticleSystem): void;
  17638. /**
  17639. * Add a submesh to the manager in order to render it this frame
  17640. * @param subMesh The submesh to dispatch
  17641. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17642. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17643. */
  17644. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17645. /**
  17646. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17647. * This allowed control for front to back rendering or reversly depending of the special needs.
  17648. *
  17649. * @param renderingGroupId The rendering group id corresponding to its index
  17650. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17651. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17652. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17653. */
  17654. 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;
  17655. /**
  17656. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17657. *
  17658. * @param renderingGroupId The rendering group id corresponding to its index
  17659. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17660. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17661. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17662. */
  17663. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17664. /**
  17665. * Gets the current auto clear configuration for one rendering group of the rendering
  17666. * manager.
  17667. * @param index the rendering group index to get the information for
  17668. * @returns The auto clear setup for the requested rendering group
  17669. */
  17670. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17671. }
  17672. }
  17673. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  17674. import { Observable } from "babylonjs/Misc/observable";
  17675. import { SmartArray } from "babylonjs/Misc/smartArray";
  17676. import { Nullable } from "babylonjs/types";
  17677. import { Camera } from "babylonjs/Cameras/camera";
  17678. import { Scene } from "babylonjs/scene";
  17679. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  17680. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  17681. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17682. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17683. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17684. import { Texture } from "babylonjs/Materials/Textures/texture";
  17685. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17686. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  17687. import { Engine } from "babylonjs/Engines/engine";
  17688. /**
  17689. * This Helps creating a texture that will be created from a camera in your scene.
  17690. * It is basically a dynamic texture that could be used to create special effects for instance.
  17691. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17692. */
  17693. export class RenderTargetTexture extends Texture {
  17694. isCube: boolean;
  17695. /**
  17696. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17697. */
  17698. static readonly REFRESHRATE_RENDER_ONCE: number;
  17699. /**
  17700. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17701. */
  17702. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17703. /**
  17704. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17705. * the central point of your effect and can save a lot of performances.
  17706. */
  17707. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17708. /**
  17709. * Use this predicate to dynamically define the list of mesh you want to render.
  17710. * If set, the renderList property will be overwritten.
  17711. */
  17712. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17713. private _renderList;
  17714. /**
  17715. * Use this list to define the list of mesh you want to render.
  17716. */
  17717. renderList: Nullable<Array<AbstractMesh>>;
  17718. private _hookArray;
  17719. /**
  17720. * Define if particles should be rendered in your texture.
  17721. */
  17722. renderParticles: boolean;
  17723. /**
  17724. * Define if sprites should be rendered in your texture.
  17725. */
  17726. renderSprites: boolean;
  17727. /**
  17728. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17729. */
  17730. coordinatesMode: number;
  17731. /**
  17732. * Define the camera used to render the texture.
  17733. */
  17734. activeCamera: Nullable<Camera>;
  17735. /**
  17736. * Override the render function of the texture with your own one.
  17737. */
  17738. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17739. /**
  17740. * Define if camera post processes should be use while rendering the texture.
  17741. */
  17742. useCameraPostProcesses: boolean;
  17743. /**
  17744. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17745. */
  17746. ignoreCameraViewport: boolean;
  17747. private _postProcessManager;
  17748. private _postProcesses;
  17749. private _resizeObserver;
  17750. /**
  17751. * An event triggered when the texture is unbind.
  17752. */
  17753. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17754. /**
  17755. * An event triggered when the texture is unbind.
  17756. */
  17757. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17758. private _onAfterUnbindObserver;
  17759. /**
  17760. * Set a after unbind callback in the texture.
  17761. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17762. */
  17763. onAfterUnbind: () => void;
  17764. /**
  17765. * An event triggered before rendering the texture
  17766. */
  17767. onBeforeRenderObservable: Observable<number>;
  17768. private _onBeforeRenderObserver;
  17769. /**
  17770. * Set a before render callback in the texture.
  17771. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17772. */
  17773. onBeforeRender: (faceIndex: number) => void;
  17774. /**
  17775. * An event triggered after rendering the texture
  17776. */
  17777. onAfterRenderObservable: Observable<number>;
  17778. private _onAfterRenderObserver;
  17779. /**
  17780. * Set a after render callback in the texture.
  17781. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17782. */
  17783. onAfterRender: (faceIndex: number) => void;
  17784. /**
  17785. * An event triggered after the texture clear
  17786. */
  17787. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  17788. private _onClearObserver;
  17789. /**
  17790. * Set a clear callback in the texture.
  17791. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17792. */
  17793. onClear: (Engine: Engine) => void;
  17794. /**
  17795. * Define the clear color of the Render Target if it should be different from the scene.
  17796. */
  17797. clearColor: Color4;
  17798. protected _size: number | {
  17799. width: number;
  17800. height: number;
  17801. };
  17802. protected _initialSizeParameter: number | {
  17803. width: number;
  17804. height: number;
  17805. } | {
  17806. ratio: number;
  17807. };
  17808. protected _sizeRatio: Nullable<number>;
  17809. /** @hidden */
  17810. _generateMipMaps: boolean;
  17811. protected _renderingManager: RenderingManager;
  17812. /** @hidden */
  17813. _waitingRenderList: string[];
  17814. protected _doNotChangeAspectRatio: boolean;
  17815. protected _currentRefreshId: number;
  17816. protected _refreshRate: number;
  17817. protected _textureMatrix: Matrix;
  17818. protected _samples: number;
  17819. protected _renderTargetOptions: RenderTargetCreationOptions;
  17820. /**
  17821. * Gets render target creation options that were used.
  17822. */
  17823. readonly renderTargetOptions: RenderTargetCreationOptions;
  17824. protected _engine: Engine;
  17825. protected _onRatioRescale(): void;
  17826. /**
  17827. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17828. * It must define where the camera used to render the texture is set
  17829. */
  17830. boundingBoxPosition: Vector3;
  17831. private _boundingBoxSize;
  17832. /**
  17833. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17834. * When defined, the cubemap will switch to local mode
  17835. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17836. * @example https://www.babylonjs-playground.com/#RNASML
  17837. */
  17838. boundingBoxSize: Vector3;
  17839. /**
  17840. * In case the RTT has been created with a depth texture, get the associated
  17841. * depth texture.
  17842. * Otherwise, return null.
  17843. */
  17844. depthStencilTexture: Nullable<InternalTexture>;
  17845. /**
  17846. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17847. * or used a shadow, depth texture...
  17848. * @param name The friendly name of the texture
  17849. * @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)
  17850. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17851. * @param generateMipMaps True if mip maps need to be generated after render.
  17852. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17853. * @param type The type of the buffer in the RTT (int, half float, float...)
  17854. * @param isCube True if a cube texture needs to be created
  17855. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17856. * @param generateDepthBuffer True to generate a depth buffer
  17857. * @param generateStencilBuffer True to generate a stencil buffer
  17858. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17859. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17860. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17861. */
  17862. constructor(name: string, size: number | {
  17863. width: number;
  17864. height: number;
  17865. } | {
  17866. ratio: number;
  17867. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17868. /**
  17869. * Creates a depth stencil texture.
  17870. * This is only available in WebGL 2 or with the depth texture extension available.
  17871. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17872. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17873. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17874. */
  17875. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17876. private _processSizeParameter;
  17877. /**
  17878. * Define the number of samples to use in case of MSAA.
  17879. * It defaults to one meaning no MSAA has been enabled.
  17880. */
  17881. samples: number;
  17882. /**
  17883. * Resets the refresh counter of the texture and start bak from scratch.
  17884. * Could be useful to regenerate the texture if it is setup to render only once.
  17885. */
  17886. resetRefreshCounter(): void;
  17887. /**
  17888. * Define the refresh rate of the texture or the rendering frequency.
  17889. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17890. */
  17891. refreshRate: number;
  17892. /**
  17893. * Adds a post process to the render target rendering passes.
  17894. * @param postProcess define the post process to add
  17895. */
  17896. addPostProcess(postProcess: PostProcess): void;
  17897. /**
  17898. * Clear all the post processes attached to the render target
  17899. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17900. */
  17901. clearPostProcesses(dispose?: boolean): void;
  17902. /**
  17903. * Remove one of the post process from the list of attached post processes to the texture
  17904. * @param postProcess define the post process to remove from the list
  17905. */
  17906. removePostProcess(postProcess: PostProcess): void;
  17907. /** @hidden */
  17908. _shouldRender(): boolean;
  17909. /**
  17910. * Gets the actual render size of the texture.
  17911. * @returns the width of the render size
  17912. */
  17913. getRenderSize(): number;
  17914. /**
  17915. * Gets the actual render width of the texture.
  17916. * @returns the width of the render size
  17917. */
  17918. getRenderWidth(): number;
  17919. /**
  17920. * Gets the actual render height of the texture.
  17921. * @returns the height of the render size
  17922. */
  17923. getRenderHeight(): number;
  17924. /**
  17925. * Get if the texture can be rescaled or not.
  17926. */
  17927. readonly canRescale: boolean;
  17928. /**
  17929. * Resize the texture using a ratio.
  17930. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17931. */
  17932. scale(ratio: number): void;
  17933. /**
  17934. * Get the texture reflection matrix used to rotate/transform the reflection.
  17935. * @returns the reflection matrix
  17936. */
  17937. getReflectionTextureMatrix(): Matrix;
  17938. /**
  17939. * Resize the texture to a new desired size.
  17940. * Be carrefull as it will recreate all the data in the new texture.
  17941. * @param size Define the new size. It can be:
  17942. * - a number for squared texture,
  17943. * - an object containing { width: number, height: number }
  17944. * - or an object containing a ratio { ratio: number }
  17945. */
  17946. resize(size: number | {
  17947. width: number;
  17948. height: number;
  17949. } | {
  17950. ratio: number;
  17951. }): void;
  17952. /**
  17953. * Renders all the objects from the render list into the texture.
  17954. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17955. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17956. */
  17957. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17958. private _bestReflectionRenderTargetDimension;
  17959. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17960. private renderToTarget;
  17961. /**
  17962. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17963. * This allowed control for front to back rendering or reversly depending of the special needs.
  17964. *
  17965. * @param renderingGroupId The rendering group id corresponding to its index
  17966. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17967. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17968. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17969. */
  17970. 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;
  17971. /**
  17972. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17973. *
  17974. * @param renderingGroupId The rendering group id corresponding to its index
  17975. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17976. */
  17977. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17978. /**
  17979. * Clones the texture.
  17980. * @returns the cloned texture
  17981. */
  17982. clone(): RenderTargetTexture;
  17983. /**
  17984. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17985. * @returns The JSON representation of the texture
  17986. */
  17987. serialize(): any;
  17988. /**
  17989. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17990. */
  17991. disposeFramebufferObjects(): void;
  17992. /**
  17993. * Dispose the texture and release its associated resources.
  17994. */
  17995. dispose(): void;
  17996. /** @hidden */
  17997. _rebuild(): void;
  17998. /**
  17999. * Clear the info related to rendering groups preventing retention point in material dispose.
  18000. */
  18001. freeRenderingGroups(): void;
  18002. }
  18003. }
  18004. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18005. import { Scene } from "babylonjs/scene";
  18006. import { Plane } from "babylonjs/Maths/math";
  18007. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18008. /**
  18009. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18010. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18011. * You can then easily use it as a reflectionTexture on a flat surface.
  18012. * In case the surface is not a plane, please consider relying on reflection probes.
  18013. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18014. */
  18015. export class MirrorTexture extends RenderTargetTexture {
  18016. private scene;
  18017. /**
  18018. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18019. * 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.
  18020. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18021. */
  18022. mirrorPlane: Plane;
  18023. /**
  18024. * Define the blur ratio used to blur the reflection if needed.
  18025. */
  18026. blurRatio: number;
  18027. /**
  18028. * Define the adaptive blur kernel used to blur the reflection if needed.
  18029. * This will autocompute the closest best match for the `blurKernel`
  18030. */
  18031. adaptiveBlurKernel: number;
  18032. /**
  18033. * Define the blur kernel used to blur the reflection if needed.
  18034. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18035. */
  18036. blurKernel: number;
  18037. /**
  18038. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18039. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18040. */
  18041. blurKernelX: number;
  18042. /**
  18043. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18044. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18045. */
  18046. blurKernelY: number;
  18047. private _autoComputeBlurKernel;
  18048. protected _onRatioRescale(): void;
  18049. private _updateGammaSpace;
  18050. private _imageProcessingConfigChangeObserver;
  18051. private _transformMatrix;
  18052. private _mirrorMatrix;
  18053. private _savedViewMatrix;
  18054. private _blurX;
  18055. private _blurY;
  18056. private _adaptiveBlurKernel;
  18057. private _blurKernelX;
  18058. private _blurKernelY;
  18059. private _blurRatio;
  18060. /**
  18061. * Instantiates a Mirror Texture.
  18062. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18063. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18064. * You can then easily use it as a reflectionTexture on a flat surface.
  18065. * In case the surface is not a plane, please consider relying on reflection probes.
  18066. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18067. * @param name
  18068. * @param size
  18069. * @param scene
  18070. * @param generateMipMaps
  18071. * @param type
  18072. * @param samplingMode
  18073. * @param generateDepthBuffer
  18074. */
  18075. constructor(name: string, size: number | {
  18076. width: number;
  18077. height: number;
  18078. } | {
  18079. ratio: number;
  18080. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18081. private _preparePostProcesses;
  18082. /**
  18083. * Clone the mirror texture.
  18084. * @returns the cloned texture
  18085. */
  18086. clone(): MirrorTexture;
  18087. /**
  18088. * Serialize the texture to a JSON representation you could use in Parse later on
  18089. * @returns the serialized JSON representation
  18090. */
  18091. serialize(): any;
  18092. /**
  18093. * Dispose the texture and release its associated resources.
  18094. */
  18095. dispose(): void;
  18096. }
  18097. }
  18098. declare module "babylonjs/Materials/Textures/texture" {
  18099. import { Observable } from "babylonjs/Misc/observable";
  18100. import { Nullable } from "babylonjs/types";
  18101. import { Scene } from "babylonjs/scene";
  18102. import { Matrix } from "babylonjs/Maths/math";
  18103. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18104. /**
  18105. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18106. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18107. */
  18108. export class Texture extends BaseTexture {
  18109. /** @hidden */
  18110. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18111. /** @hidden */
  18112. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18113. /** @hidden */
  18114. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18115. /** nearest is mag = nearest and min = nearest and mip = linear */
  18116. static readonly NEAREST_SAMPLINGMODE: number;
  18117. /** nearest is mag = nearest and min = nearest and mip = linear */
  18118. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18119. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18120. static readonly BILINEAR_SAMPLINGMODE: number;
  18121. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18122. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18123. /** Trilinear is mag = linear and min = linear and mip = linear */
  18124. static readonly TRILINEAR_SAMPLINGMODE: number;
  18125. /** Trilinear is mag = linear and min = linear and mip = linear */
  18126. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18127. /** mag = nearest and min = nearest and mip = nearest */
  18128. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18129. /** mag = nearest and min = linear and mip = nearest */
  18130. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18131. /** mag = nearest and min = linear and mip = linear */
  18132. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18133. /** mag = nearest and min = linear and mip = none */
  18134. static readonly NEAREST_LINEAR: number;
  18135. /** mag = nearest and min = nearest and mip = none */
  18136. static readonly NEAREST_NEAREST: number;
  18137. /** mag = linear and min = nearest and mip = nearest */
  18138. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18139. /** mag = linear and min = nearest and mip = linear */
  18140. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18141. /** mag = linear and min = linear and mip = none */
  18142. static readonly LINEAR_LINEAR: number;
  18143. /** mag = linear and min = nearest and mip = none */
  18144. static readonly LINEAR_NEAREST: number;
  18145. /** Explicit coordinates mode */
  18146. static readonly EXPLICIT_MODE: number;
  18147. /** Spherical coordinates mode */
  18148. static readonly SPHERICAL_MODE: number;
  18149. /** Planar coordinates mode */
  18150. static readonly PLANAR_MODE: number;
  18151. /** Cubic coordinates mode */
  18152. static readonly CUBIC_MODE: number;
  18153. /** Projection coordinates mode */
  18154. static readonly PROJECTION_MODE: number;
  18155. /** Inverse Cubic coordinates mode */
  18156. static readonly SKYBOX_MODE: number;
  18157. /** Inverse Cubic coordinates mode */
  18158. static readonly INVCUBIC_MODE: number;
  18159. /** Equirectangular coordinates mode */
  18160. static readonly EQUIRECTANGULAR_MODE: number;
  18161. /** Equirectangular Fixed coordinates mode */
  18162. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18163. /** Equirectangular Fixed Mirrored coordinates mode */
  18164. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18165. /** Texture is not repeating outside of 0..1 UVs */
  18166. static readonly CLAMP_ADDRESSMODE: number;
  18167. /** Texture is repeating outside of 0..1 UVs */
  18168. static readonly WRAP_ADDRESSMODE: number;
  18169. /** Texture is repeating and mirrored */
  18170. static readonly MIRROR_ADDRESSMODE: number;
  18171. /**
  18172. * 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
  18173. */
  18174. static UseSerializedUrlIfAny: boolean;
  18175. /**
  18176. * Define the url of the texture.
  18177. */
  18178. url: Nullable<string>;
  18179. /**
  18180. * Define an offset on the texture to offset the u coordinates of the UVs
  18181. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18182. */
  18183. uOffset: number;
  18184. /**
  18185. * Define an offset on the texture to offset the v coordinates of the UVs
  18186. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18187. */
  18188. vOffset: number;
  18189. /**
  18190. * Define an offset on the texture to scale the u coordinates of the UVs
  18191. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18192. */
  18193. uScale: number;
  18194. /**
  18195. * Define an offset on the texture to scale the v coordinates of the UVs
  18196. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18197. */
  18198. vScale: number;
  18199. /**
  18200. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18201. * @see http://doc.babylonjs.com/how_to/more_materials
  18202. */
  18203. uAng: number;
  18204. /**
  18205. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18206. * @see http://doc.babylonjs.com/how_to/more_materials
  18207. */
  18208. vAng: number;
  18209. /**
  18210. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18211. * @see http://doc.babylonjs.com/how_to/more_materials
  18212. */
  18213. wAng: number;
  18214. /**
  18215. * Defines the center of rotation (U)
  18216. */
  18217. uRotationCenter: number;
  18218. /**
  18219. * Defines the center of rotation (V)
  18220. */
  18221. vRotationCenter: number;
  18222. /**
  18223. * Defines the center of rotation (W)
  18224. */
  18225. wRotationCenter: number;
  18226. /**
  18227. * Are mip maps generated for this texture or not.
  18228. */
  18229. readonly noMipmap: boolean;
  18230. private _noMipmap;
  18231. /** @hidden */
  18232. _invertY: boolean;
  18233. private _rowGenerationMatrix;
  18234. private _cachedTextureMatrix;
  18235. private _projectionModeMatrix;
  18236. private _t0;
  18237. private _t1;
  18238. private _t2;
  18239. private _cachedUOffset;
  18240. private _cachedVOffset;
  18241. private _cachedUScale;
  18242. private _cachedVScale;
  18243. private _cachedUAng;
  18244. private _cachedVAng;
  18245. private _cachedWAng;
  18246. private _cachedProjectionMatrixId;
  18247. private _cachedCoordinatesMode;
  18248. /** @hidden */
  18249. protected _initialSamplingMode: number;
  18250. /** @hidden */
  18251. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18252. private _deleteBuffer;
  18253. protected _format: Nullable<number>;
  18254. private _delayedOnLoad;
  18255. private _delayedOnError;
  18256. /**
  18257. * Observable triggered once the texture has been loaded.
  18258. */
  18259. onLoadObservable: Observable<Texture>;
  18260. protected _isBlocking: boolean;
  18261. /**
  18262. * Is the texture preventing material to render while loading.
  18263. * If false, a default texture will be used instead of the loading one during the preparation step.
  18264. */
  18265. isBlocking: boolean;
  18266. /**
  18267. * Get the current sampling mode associated with the texture.
  18268. */
  18269. readonly samplingMode: number;
  18270. /**
  18271. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18272. */
  18273. readonly invertY: boolean;
  18274. /**
  18275. * Instantiates a new texture.
  18276. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18277. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18278. * @param url define the url of the picture to load as a texture
  18279. * @param scene define the scene the texture will belong to
  18280. * @param noMipmap define if the texture will require mip maps or not
  18281. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18282. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18283. * @param onLoad define a callback triggered when the texture has been loaded
  18284. * @param onError define a callback triggered when an error occurred during the loading session
  18285. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18286. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18287. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18288. */
  18289. 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);
  18290. /**
  18291. * Update the url (and optional buffer) of this texture if url was null during construction.
  18292. * @param url the url of the texture
  18293. * @param buffer the buffer of the texture (defaults to null)
  18294. * @param onLoad callback called when the texture is loaded (defaults to null)
  18295. */
  18296. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18297. /**
  18298. * Finish the loading sequence of a texture flagged as delayed load.
  18299. * @hidden
  18300. */
  18301. delayLoad(): void;
  18302. private _prepareRowForTextureGeneration;
  18303. /**
  18304. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18305. * @returns the transform matrix of the texture.
  18306. */
  18307. getTextureMatrix(): Matrix;
  18308. /**
  18309. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18310. * @returns The reflection texture transform
  18311. */
  18312. getReflectionTextureMatrix(): Matrix;
  18313. /**
  18314. * Clones the texture.
  18315. * @returns the cloned texture
  18316. */
  18317. clone(): Texture;
  18318. /**
  18319. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18320. * @returns The JSON representation of the texture
  18321. */
  18322. serialize(): any;
  18323. /**
  18324. * Get the current class name of the texture useful for serialization or dynamic coding.
  18325. * @returns "Texture"
  18326. */
  18327. getClassName(): string;
  18328. /**
  18329. * Dispose the texture and release its associated resources.
  18330. */
  18331. dispose(): void;
  18332. /**
  18333. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18334. * @param parsedTexture Define the JSON representation of the texture
  18335. * @param scene Define the scene the parsed texture should be instantiated in
  18336. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18337. * @returns The parsed texture if successful
  18338. */
  18339. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18340. /**
  18341. * Creates a texture from its base 64 representation.
  18342. * @param data Define the base64 payload without the data: prefix
  18343. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18344. * @param scene Define the scene the texture should belong to
  18345. * @param noMipmap Forces the texture to not create mip map information if true
  18346. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18347. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18348. * @param onLoad define a callback triggered when the texture has been loaded
  18349. * @param onError define a callback triggered when an error occurred during the loading session
  18350. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18351. * @returns the created texture
  18352. */
  18353. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18354. /**
  18355. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18356. * @param data Define the base64 payload without the data: prefix
  18357. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18358. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18359. * @param scene Define the scene the texture should belong to
  18360. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18361. * @param noMipmap Forces the texture to not create mip map information if true
  18362. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18363. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18364. * @param onLoad define a callback triggered when the texture has been loaded
  18365. * @param onError define a callback triggered when an error occurred during the loading session
  18366. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18367. * @returns the created texture
  18368. */
  18369. 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;
  18370. }
  18371. }
  18372. declare module "babylonjs/Materials/Textures/rawTexture" {
  18373. import { Scene } from "babylonjs/scene";
  18374. import { Texture } from "babylonjs/Materials/Textures/texture";
  18375. /**
  18376. * Raw texture can help creating a texture directly from an array of data.
  18377. * This can be super useful if you either get the data from an uncompressed source or
  18378. * if you wish to create your texture pixel by pixel.
  18379. */
  18380. export class RawTexture extends Texture {
  18381. /**
  18382. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18383. */
  18384. format: number;
  18385. private _engine;
  18386. /**
  18387. * Instantiates a new RawTexture.
  18388. * Raw texture can help creating a texture directly from an array of data.
  18389. * This can be super useful if you either get the data from an uncompressed source or
  18390. * if you wish to create your texture pixel by pixel.
  18391. * @param data define the array of data to use to create the texture
  18392. * @param width define the width of the texture
  18393. * @param height define the height of the texture
  18394. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18395. * @param scene define the scene the texture belongs to
  18396. * @param generateMipMaps define whether mip maps should be generated or not
  18397. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18398. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18399. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18400. */
  18401. constructor(data: ArrayBufferView, width: number, height: number,
  18402. /**
  18403. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18404. */
  18405. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18406. /**
  18407. * Updates the texture underlying data.
  18408. * @param data Define the new data of the texture
  18409. */
  18410. update(data: ArrayBufferView): void;
  18411. /**
  18412. * Creates a luminance texture from some data.
  18413. * @param data Define the texture data
  18414. * @param width Define the width of the texture
  18415. * @param height Define the height of the texture
  18416. * @param scene Define the scene the texture belongs to
  18417. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18418. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18419. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18420. * @returns the luminance texture
  18421. */
  18422. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18423. /**
  18424. * Creates a luminance alpha texture from some data.
  18425. * @param data Define the texture data
  18426. * @param width Define the width of the texture
  18427. * @param height Define the height of the texture
  18428. * @param scene Define the scene the texture belongs to
  18429. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18430. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18431. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18432. * @returns the luminance alpha texture
  18433. */
  18434. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18435. /**
  18436. * Creates an alpha texture from some data.
  18437. * @param data Define the texture data
  18438. * @param width Define the width of the texture
  18439. * @param height Define the height of the texture
  18440. * @param scene Define the scene the texture belongs to
  18441. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18442. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18443. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18444. * @returns the alpha texture
  18445. */
  18446. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18447. /**
  18448. * Creates a RGB texture from some data.
  18449. * @param data Define the texture data
  18450. * @param width Define the width of the texture
  18451. * @param height Define the height of the texture
  18452. * @param scene Define the scene the texture belongs to
  18453. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18454. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18455. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18456. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18457. * @returns the RGB alpha texture
  18458. */
  18459. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18460. /**
  18461. * Creates a RGBA texture from some data.
  18462. * @param data Define the texture data
  18463. * @param width Define the width of the texture
  18464. * @param height Define the height of the texture
  18465. * @param scene Define the scene the texture belongs to
  18466. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18467. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18468. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18469. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18470. * @returns the RGBA texture
  18471. */
  18472. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18473. /**
  18474. * Creates a R texture from some data.
  18475. * @param data Define the texture data
  18476. * @param width Define the width of the texture
  18477. * @param height Define the height of the texture
  18478. * @param scene Define the scene the texture belongs to
  18479. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18480. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18481. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18482. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18483. * @returns the R texture
  18484. */
  18485. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18486. }
  18487. }
  18488. declare module "babylonjs/Animations/runtimeAnimation" {
  18489. import { Animation } from "babylonjs/Animations/animation";
  18490. import { Animatable } from "babylonjs/Animations/animatable";
  18491. import { Scene } from "babylonjs/scene";
  18492. /**
  18493. * Defines a runtime animation
  18494. */
  18495. export class RuntimeAnimation {
  18496. private _events;
  18497. /**
  18498. * The current frame of the runtime animation
  18499. */
  18500. private _currentFrame;
  18501. /**
  18502. * The animation used by the runtime animation
  18503. */
  18504. private _animation;
  18505. /**
  18506. * The target of the runtime animation
  18507. */
  18508. private _target;
  18509. /**
  18510. * The initiating animatable
  18511. */
  18512. private _host;
  18513. /**
  18514. * The original value of the runtime animation
  18515. */
  18516. private _originalValue;
  18517. /**
  18518. * The original blend value of the runtime animation
  18519. */
  18520. private _originalBlendValue;
  18521. /**
  18522. * The offsets cache of the runtime animation
  18523. */
  18524. private _offsetsCache;
  18525. /**
  18526. * The high limits cache of the runtime animation
  18527. */
  18528. private _highLimitsCache;
  18529. /**
  18530. * Specifies if the runtime animation has been stopped
  18531. */
  18532. private _stopped;
  18533. /**
  18534. * The blending factor of the runtime animation
  18535. */
  18536. private _blendingFactor;
  18537. /**
  18538. * The BabylonJS scene
  18539. */
  18540. private _scene;
  18541. /**
  18542. * The current value of the runtime animation
  18543. */
  18544. private _currentValue;
  18545. /** @hidden */
  18546. _workValue: any;
  18547. /**
  18548. * The active target of the runtime animation
  18549. */
  18550. private _activeTarget;
  18551. /**
  18552. * The target path of the runtime animation
  18553. */
  18554. private _targetPath;
  18555. /**
  18556. * The weight of the runtime animation
  18557. */
  18558. private _weight;
  18559. /**
  18560. * The ratio offset of the runtime animation
  18561. */
  18562. private _ratioOffset;
  18563. /**
  18564. * The previous delay of the runtime animation
  18565. */
  18566. private _previousDelay;
  18567. /**
  18568. * The previous ratio of the runtime animation
  18569. */
  18570. private _previousRatio;
  18571. /**
  18572. * Gets the current frame of the runtime animation
  18573. */
  18574. readonly currentFrame: number;
  18575. /**
  18576. * Gets the weight of the runtime animation
  18577. */
  18578. readonly weight: number;
  18579. /**
  18580. * Gets the current value of the runtime animation
  18581. */
  18582. readonly currentValue: any;
  18583. /**
  18584. * Gets the target path of the runtime animation
  18585. */
  18586. readonly targetPath: string;
  18587. /**
  18588. * Gets the actual target of the runtime animation
  18589. */
  18590. readonly target: any;
  18591. /**
  18592. * Create a new RuntimeAnimation object
  18593. * @param target defines the target of the animation
  18594. * @param animation defines the source animation object
  18595. * @param scene defines the hosting scene
  18596. * @param host defines the initiating Animatable
  18597. */
  18598. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18599. /**
  18600. * Gets the animation from the runtime animation
  18601. */
  18602. readonly animation: Animation;
  18603. /**
  18604. * Resets the runtime animation to the beginning
  18605. * @param restoreOriginal defines whether to restore the target property to the original value
  18606. */
  18607. reset(restoreOriginal?: boolean): void;
  18608. /**
  18609. * Specifies if the runtime animation is stopped
  18610. * @returns Boolean specifying if the runtime animation is stopped
  18611. */
  18612. isStopped(): boolean;
  18613. /**
  18614. * Disposes of the runtime animation
  18615. */
  18616. dispose(): void;
  18617. /**
  18618. * Interpolates the animation from the current frame
  18619. * @param currentFrame The frame to interpolate the animation to
  18620. * @param repeatCount The number of times that the animation should loop
  18621. * @param loopMode The type of looping mode to use
  18622. * @param offsetValue Animation offset value
  18623. * @param highLimitValue The high limit value
  18624. * @returns The interpolated value
  18625. */
  18626. private _interpolate;
  18627. /**
  18628. * Apply the interpolated value to the target
  18629. * @param currentValue defines the value computed by the animation
  18630. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18631. */
  18632. setValue(currentValue: any, weight?: number): void;
  18633. private _setValue;
  18634. /**
  18635. * Gets the loop pmode of the runtime animation
  18636. * @returns Loop Mode
  18637. */
  18638. private _getCorrectLoopMode;
  18639. /**
  18640. * Move the current animation to a given frame
  18641. * @param frame defines the frame to move to
  18642. */
  18643. goToFrame(frame: number): void;
  18644. /**
  18645. * @hidden Internal use only
  18646. */
  18647. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18648. /**
  18649. * Execute the current animation
  18650. * @param delay defines the delay to add to the current frame
  18651. * @param from defines the lower bound of the animation range
  18652. * @param to defines the upper bound of the animation range
  18653. * @param loop defines if the current animation must loop
  18654. * @param speedRatio defines the current speed ratio
  18655. * @param weight defines the weight of the animation (default is -1 so no weight)
  18656. * @param onLoop optional callback called when animation loops
  18657. * @returns a boolean indicating if the animation is running
  18658. */
  18659. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  18660. }
  18661. }
  18662. declare module "babylonjs/Animations/animatable" {
  18663. import { Animation } from "babylonjs/Animations/animation";
  18664. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  18665. import { Nullable } from "babylonjs/types";
  18666. import { Observable } from "babylonjs/Misc/observable";
  18667. import { Scene } from "babylonjs/scene";
  18668. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  18669. import { Node } from "babylonjs/node";
  18670. /**
  18671. * Class used to store an actual running animation
  18672. */
  18673. export class Animatable {
  18674. /** defines the target object */
  18675. target: any;
  18676. /** defines the starting frame number (default is 0) */
  18677. fromFrame: number;
  18678. /** defines the ending frame number (default is 100) */
  18679. toFrame: number;
  18680. /** defines if the animation must loop (default is false) */
  18681. loopAnimation: boolean;
  18682. /** defines a callback to call when animation ends if it is not looping */
  18683. onAnimationEnd?: (() => void) | null | undefined;
  18684. /** defines a callback to call when animation loops */
  18685. onAnimationLoop?: (() => void) | null | undefined;
  18686. private _localDelayOffset;
  18687. private _pausedDelay;
  18688. private _runtimeAnimations;
  18689. private _paused;
  18690. private _scene;
  18691. private _speedRatio;
  18692. private _weight;
  18693. private _syncRoot;
  18694. /**
  18695. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18696. * This will only apply for non looping animation (default is true)
  18697. */
  18698. disposeOnEnd: boolean;
  18699. /**
  18700. * Gets a boolean indicating if the animation has started
  18701. */
  18702. animationStarted: boolean;
  18703. /**
  18704. * Observer raised when the animation ends
  18705. */
  18706. onAnimationEndObservable: Observable<Animatable>;
  18707. /**
  18708. * Observer raised when the animation loops
  18709. */
  18710. onAnimationLoopObservable: Observable<Animatable>;
  18711. /**
  18712. * Gets the root Animatable used to synchronize and normalize animations
  18713. */
  18714. readonly syncRoot: Animatable;
  18715. /**
  18716. * Gets the current frame of the first RuntimeAnimation
  18717. * Used to synchronize Animatables
  18718. */
  18719. readonly masterFrame: number;
  18720. /**
  18721. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18722. */
  18723. weight: number;
  18724. /**
  18725. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18726. */
  18727. speedRatio: number;
  18728. /**
  18729. * Creates a new Animatable
  18730. * @param scene defines the hosting scene
  18731. * @param target defines the target object
  18732. * @param fromFrame defines the starting frame number (default is 0)
  18733. * @param toFrame defines the ending frame number (default is 100)
  18734. * @param loopAnimation defines if the animation must loop (default is false)
  18735. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18736. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18737. * @param animations defines a group of animation to add to the new Animatable
  18738. * @param onAnimationLoop defines a callback to call when animation loops
  18739. */
  18740. constructor(scene: Scene,
  18741. /** defines the target object */
  18742. target: any,
  18743. /** defines the starting frame number (default is 0) */
  18744. fromFrame?: number,
  18745. /** defines the ending frame number (default is 100) */
  18746. toFrame?: number,
  18747. /** defines if the animation must loop (default is false) */
  18748. loopAnimation?: boolean, speedRatio?: number,
  18749. /** defines a callback to call when animation ends if it is not looping */
  18750. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18751. /** defines a callback to call when animation loops */
  18752. onAnimationLoop?: (() => void) | null | undefined);
  18753. /**
  18754. * Synchronize and normalize current Animatable with a source Animatable
  18755. * This is useful when using animation weights and when animations are not of the same length
  18756. * @param root defines the root Animatable to synchronize with
  18757. * @returns the current Animatable
  18758. */
  18759. syncWith(root: Animatable): Animatable;
  18760. /**
  18761. * Gets the list of runtime animations
  18762. * @returns an array of RuntimeAnimation
  18763. */
  18764. getAnimations(): RuntimeAnimation[];
  18765. /**
  18766. * Adds more animations to the current animatable
  18767. * @param target defines the target of the animations
  18768. * @param animations defines the new animations to add
  18769. */
  18770. appendAnimations(target: any, animations: Animation[]): void;
  18771. /**
  18772. * Gets the source animation for a specific property
  18773. * @param property defines the propertyu to look for
  18774. * @returns null or the source animation for the given property
  18775. */
  18776. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18777. /**
  18778. * Gets the runtime animation for a specific property
  18779. * @param property defines the propertyu to look for
  18780. * @returns null or the runtime animation for the given property
  18781. */
  18782. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18783. /**
  18784. * Resets the animatable to its original state
  18785. */
  18786. reset(): void;
  18787. /**
  18788. * Allows the animatable to blend with current running animations
  18789. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18790. * @param blendingSpeed defines the blending speed to use
  18791. */
  18792. enableBlending(blendingSpeed: number): void;
  18793. /**
  18794. * Disable animation blending
  18795. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18796. */
  18797. disableBlending(): void;
  18798. /**
  18799. * Jump directly to a given frame
  18800. * @param frame defines the frame to jump to
  18801. */
  18802. goToFrame(frame: number): void;
  18803. /**
  18804. * Pause the animation
  18805. */
  18806. pause(): void;
  18807. /**
  18808. * Restart the animation
  18809. */
  18810. restart(): void;
  18811. private _raiseOnAnimationEnd;
  18812. /**
  18813. * Stop and delete the current animation
  18814. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18815. * @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)
  18816. */
  18817. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  18818. /**
  18819. * Wait asynchronously for the animation to end
  18820. * @returns a promise which will be fullfilled when the animation ends
  18821. */
  18822. waitAsync(): Promise<Animatable>;
  18823. /** @hidden */
  18824. _animate(delay: number): boolean;
  18825. }
  18826. module "babylonjs/scene" {
  18827. interface Scene {
  18828. /** @hidden */
  18829. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  18830. /** @hidden */
  18831. _processLateAnimationBindingsForMatrices(holder: {
  18832. totalWeight: number;
  18833. animations: RuntimeAnimation[];
  18834. originalValue: Matrix;
  18835. }): any;
  18836. /** @hidden */
  18837. _processLateAnimationBindingsForQuaternions(holder: {
  18838. totalWeight: number;
  18839. animations: RuntimeAnimation[];
  18840. originalValue: Quaternion;
  18841. }, refQuaternion: Quaternion): Quaternion;
  18842. /** @hidden */
  18843. _processLateAnimationBindings(): void;
  18844. /**
  18845. * Will start the animation sequence of a given target
  18846. * @param target defines the target
  18847. * @param from defines from which frame should animation start
  18848. * @param to defines until which frame should animation run.
  18849. * @param weight defines the weight to apply to the animation (1.0 by default)
  18850. * @param loop defines if the animation loops
  18851. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18852. * @param onAnimationEnd defines the function to be executed when the animation ends
  18853. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18854. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18855. * @param onAnimationLoop defines the callback to call when an animation loops
  18856. * @returns the animatable object created for this animation
  18857. */
  18858. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18859. /**
  18860. * Will start the animation sequence of a given target
  18861. * @param target defines the target
  18862. * @param from defines from which frame should animation start
  18863. * @param to defines until which frame should animation run.
  18864. * @param loop defines if the animation loops
  18865. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18866. * @param onAnimationEnd defines the function to be executed when the animation ends
  18867. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18868. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18869. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  18870. * @param onAnimationLoop defines the callback to call when an animation loops
  18871. * @returns the animatable object created for this animation
  18872. */
  18873. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18874. /**
  18875. * Will start the animation sequence of a given target and its hierarchy
  18876. * @param target defines the target
  18877. * @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.
  18878. * @param from defines from which frame should animation start
  18879. * @param to defines until which frame should animation run.
  18880. * @param loop defines if the animation loops
  18881. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18882. * @param onAnimationEnd defines the function to be executed when the animation ends
  18883. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18884. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18885. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18886. * @param onAnimationLoop defines the callback to call when an animation loops
  18887. * @returns the list of created animatables
  18888. */
  18889. 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[];
  18890. /**
  18891. * Begin a new animation on a given node
  18892. * @param target defines the target where the animation will take place
  18893. * @param animations defines the list of animations to start
  18894. * @param from defines the initial value
  18895. * @param to defines the final value
  18896. * @param loop defines if you want animation to loop (off by default)
  18897. * @param speedRatio defines the speed ratio to apply to all animations
  18898. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18899. * @param onAnimationLoop defines the callback to call when an animation loops
  18900. * @returns the list of created animatables
  18901. */
  18902. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  18903. /**
  18904. * Begin a new animation on a given node and its hierarchy
  18905. * @param target defines the root node where the animation will take place
  18906. * @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.
  18907. * @param animations defines the list of animations to start
  18908. * @param from defines the initial value
  18909. * @param to defines the final value
  18910. * @param loop defines if you want animation to loop (off by default)
  18911. * @param speedRatio defines the speed ratio to apply to all animations
  18912. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18913. * @param onAnimationLoop defines the callback to call when an animation loops
  18914. * @returns the list of animatables created for all nodes
  18915. */
  18916. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  18917. /**
  18918. * Gets the animatable associated with a specific target
  18919. * @param target defines the target of the animatable
  18920. * @returns the required animatable if found
  18921. */
  18922. getAnimatableByTarget(target: any): Nullable<Animatable>;
  18923. /**
  18924. * Gets all animatables associated with a given target
  18925. * @param target defines the target to look animatables for
  18926. * @returns an array of Animatables
  18927. */
  18928. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  18929. /**
  18930. * Will stop the animation of the given target
  18931. * @param target - the target
  18932. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  18933. * @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)
  18934. */
  18935. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  18936. /**
  18937. * Stops and removes all animations that have been applied to the scene
  18938. */
  18939. stopAllAnimations(): void;
  18940. }
  18941. }
  18942. module "babylonjs/Bones/bone" {
  18943. interface Bone {
  18944. /**
  18945. * Copy an animation range from another bone
  18946. * @param source defines the source bone
  18947. * @param rangeName defines the range name to copy
  18948. * @param frameOffset defines the frame offset
  18949. * @param rescaleAsRequired defines if rescaling must be applied if required
  18950. * @param skelDimensionsRatio defines the scaling ratio
  18951. * @returns true if operation was successful
  18952. */
  18953. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  18954. }
  18955. }
  18956. }
  18957. declare module "babylonjs/Bones/skeleton" {
  18958. import { Bone } from "babylonjs/Bones/bone";
  18959. import { IAnimatable } from "babylonjs/Misc/tools";
  18960. import { Observable } from "babylonjs/Misc/observable";
  18961. import { Vector3, Matrix } from "babylonjs/Maths/math";
  18962. import { Scene } from "babylonjs/scene";
  18963. import { Nullable } from "babylonjs/types";
  18964. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18965. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  18966. import { Animatable } from "babylonjs/Animations/animatable";
  18967. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  18968. import { Animation } from "babylonjs/Animations/animation";
  18969. import { AnimationRange } from "babylonjs/Animations/animationRange";
  18970. /**
  18971. * Class used to handle skinning animations
  18972. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18973. */
  18974. export class Skeleton implements IAnimatable {
  18975. /** defines the skeleton name */
  18976. name: string;
  18977. /** defines the skeleton Id */
  18978. id: string;
  18979. /**
  18980. * Defines the list of child bones
  18981. */
  18982. bones: Bone[];
  18983. /**
  18984. * Defines an estimate of the dimension of the skeleton at rest
  18985. */
  18986. dimensionsAtRest: Vector3;
  18987. /**
  18988. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  18989. */
  18990. needInitialSkinMatrix: boolean;
  18991. /**
  18992. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  18993. */
  18994. overrideMesh: Nullable<AbstractMesh>;
  18995. /**
  18996. * Gets the list of animations attached to this skeleton
  18997. */
  18998. animations: Array<Animation>;
  18999. private _scene;
  19000. private _isDirty;
  19001. private _transformMatrices;
  19002. private _transformMatrixTexture;
  19003. private _meshesWithPoseMatrix;
  19004. private _animatables;
  19005. private _identity;
  19006. private _synchronizedWithMesh;
  19007. private _ranges;
  19008. private _lastAbsoluteTransformsUpdateId;
  19009. private _canUseTextureForBones;
  19010. /** @hidden */
  19011. _numBonesWithLinkedTransformNode: number;
  19012. /**
  19013. * Specifies if the skeleton should be serialized
  19014. */
  19015. doNotSerialize: boolean;
  19016. private _useTextureToStoreBoneMatrices;
  19017. /**
  19018. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19019. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19020. */
  19021. useTextureToStoreBoneMatrices: boolean;
  19022. private _animationPropertiesOverride;
  19023. /**
  19024. * Gets or sets the animation properties override
  19025. */
  19026. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19027. /**
  19028. * An observable triggered before computing the skeleton's matrices
  19029. */
  19030. onBeforeComputeObservable: Observable<Skeleton>;
  19031. /**
  19032. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19033. */
  19034. readonly isUsingTextureForMatrices: boolean;
  19035. /**
  19036. * Creates a new skeleton
  19037. * @param name defines the skeleton name
  19038. * @param id defines the skeleton Id
  19039. * @param scene defines the hosting scene
  19040. */
  19041. constructor(
  19042. /** defines the skeleton name */
  19043. name: string,
  19044. /** defines the skeleton Id */
  19045. id: string, scene: Scene);
  19046. /**
  19047. * Gets the current object class name.
  19048. * @return the class name
  19049. */
  19050. getClassName(): string;
  19051. /**
  19052. * Returns an array containing the root bones
  19053. * @returns an array containing the root bones
  19054. */
  19055. getChildren(): Array<Bone>;
  19056. /**
  19057. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19058. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19059. * @returns a Float32Array containing matrices data
  19060. */
  19061. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19062. /**
  19063. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19064. * @returns a raw texture containing the data
  19065. */
  19066. getTransformMatrixTexture(): Nullable<RawTexture>;
  19067. /**
  19068. * Gets the current hosting scene
  19069. * @returns a scene object
  19070. */
  19071. getScene(): Scene;
  19072. /**
  19073. * Gets a string representing the current skeleton data
  19074. * @param fullDetails defines a boolean indicating if we want a verbose version
  19075. * @returns a string representing the current skeleton data
  19076. */
  19077. toString(fullDetails?: boolean): string;
  19078. /**
  19079. * Get bone's index searching by name
  19080. * @param name defines bone's name to search for
  19081. * @return the indice of the bone. Returns -1 if not found
  19082. */
  19083. getBoneIndexByName(name: string): number;
  19084. /**
  19085. * Creater a new animation range
  19086. * @param name defines the name of the range
  19087. * @param from defines the start key
  19088. * @param to defines the end key
  19089. */
  19090. createAnimationRange(name: string, from: number, to: number): void;
  19091. /**
  19092. * Delete a specific animation range
  19093. * @param name defines the name of the range
  19094. * @param deleteFrames defines if frames must be removed as well
  19095. */
  19096. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19097. /**
  19098. * Gets a specific animation range
  19099. * @param name defines the name of the range to look for
  19100. * @returns the requested animation range or null if not found
  19101. */
  19102. getAnimationRange(name: string): Nullable<AnimationRange>;
  19103. /**
  19104. * Gets the list of all animation ranges defined on this skeleton
  19105. * @returns an array
  19106. */
  19107. getAnimationRanges(): Nullable<AnimationRange>[];
  19108. /**
  19109. * Copy animation range from a source skeleton.
  19110. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19111. * @param source defines the source skeleton
  19112. * @param name defines the name of the range to copy
  19113. * @param rescaleAsRequired defines if rescaling must be applied if required
  19114. * @returns true if operation was successful
  19115. */
  19116. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19117. /**
  19118. * Forces the skeleton to go to rest pose
  19119. */
  19120. returnToRest(): void;
  19121. private _getHighestAnimationFrame;
  19122. /**
  19123. * Begin a specific animation range
  19124. * @param name defines the name of the range to start
  19125. * @param loop defines if looping must be turned on (false by default)
  19126. * @param speedRatio defines the speed ratio to apply (1 by default)
  19127. * @param onAnimationEnd defines a callback which will be called when animation will end
  19128. * @returns a new animatable
  19129. */
  19130. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19131. /** @hidden */
  19132. _markAsDirty(): void;
  19133. /** @hidden */
  19134. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19135. /** @hidden */
  19136. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19137. private _computeTransformMatrices;
  19138. /**
  19139. * Build all resources required to render a skeleton
  19140. */
  19141. prepare(): void;
  19142. /**
  19143. * Gets the list of animatables currently running for this skeleton
  19144. * @returns an array of animatables
  19145. */
  19146. getAnimatables(): IAnimatable[];
  19147. /**
  19148. * Clone the current skeleton
  19149. * @param name defines the name of the new skeleton
  19150. * @param id defines the id of the enw skeleton
  19151. * @returns the new skeleton
  19152. */
  19153. clone(name: string, id: string): Skeleton;
  19154. /**
  19155. * Enable animation blending for this skeleton
  19156. * @param blendingSpeed defines the blending speed to apply
  19157. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19158. */
  19159. enableBlending(blendingSpeed?: number): void;
  19160. /**
  19161. * Releases all resources associated with the current skeleton
  19162. */
  19163. dispose(): void;
  19164. /**
  19165. * Serialize the skeleton in a JSON object
  19166. * @returns a JSON object
  19167. */
  19168. serialize(): any;
  19169. /**
  19170. * Creates a new skeleton from serialized data
  19171. * @param parsedSkeleton defines the serialized data
  19172. * @param scene defines the hosting scene
  19173. * @returns a new skeleton
  19174. */
  19175. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19176. /**
  19177. * Compute all node absolute transforms
  19178. * @param forceUpdate defines if computation must be done even if cache is up to date
  19179. */
  19180. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19181. /**
  19182. * Gets the root pose matrix
  19183. * @returns a matrix
  19184. */
  19185. getPoseMatrix(): Nullable<Matrix>;
  19186. /**
  19187. * Sorts bones per internal index
  19188. */
  19189. sortBones(): void;
  19190. private _sortBones;
  19191. }
  19192. }
  19193. declare module "babylonjs/Morph/morphTarget" {
  19194. import { IAnimatable } from "babylonjs/Misc/tools";
  19195. import { Observable } from "babylonjs/Misc/observable";
  19196. import { Nullable, FloatArray } from "babylonjs/types";
  19197. import { Scene } from "babylonjs/scene";
  19198. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19199. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19200. /**
  19201. * Defines a target to use with MorphTargetManager
  19202. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19203. */
  19204. export class MorphTarget implements IAnimatable {
  19205. /** defines the name of the target */
  19206. name: string;
  19207. /**
  19208. * Gets or sets the list of animations
  19209. */
  19210. animations: import("babylonjs/Animations/animation").Animation[];
  19211. private _scene;
  19212. private _positions;
  19213. private _normals;
  19214. private _tangents;
  19215. private _influence;
  19216. /**
  19217. * Observable raised when the influence changes
  19218. */
  19219. onInfluenceChanged: Observable<boolean>;
  19220. /** @hidden */
  19221. _onDataLayoutChanged: Observable<void>;
  19222. /**
  19223. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19224. */
  19225. influence: number;
  19226. /**
  19227. * Gets or sets the id of the morph Target
  19228. */
  19229. id: string;
  19230. private _animationPropertiesOverride;
  19231. /**
  19232. * Gets or sets the animation properties override
  19233. */
  19234. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19235. /**
  19236. * Creates a new MorphTarget
  19237. * @param name defines the name of the target
  19238. * @param influence defines the influence to use
  19239. * @param scene defines the scene the morphtarget belongs to
  19240. */
  19241. constructor(
  19242. /** defines the name of the target */
  19243. name: string, influence?: number, scene?: Nullable<Scene>);
  19244. /**
  19245. * Gets a boolean defining if the target contains position data
  19246. */
  19247. readonly hasPositions: boolean;
  19248. /**
  19249. * Gets a boolean defining if the target contains normal data
  19250. */
  19251. readonly hasNormals: boolean;
  19252. /**
  19253. * Gets a boolean defining if the target contains tangent data
  19254. */
  19255. readonly hasTangents: boolean;
  19256. /**
  19257. * Affects position data to this target
  19258. * @param data defines the position data to use
  19259. */
  19260. setPositions(data: Nullable<FloatArray>): void;
  19261. /**
  19262. * Gets the position data stored in this target
  19263. * @returns a FloatArray containing the position data (or null if not present)
  19264. */
  19265. getPositions(): Nullable<FloatArray>;
  19266. /**
  19267. * Affects normal data to this target
  19268. * @param data defines the normal data to use
  19269. */
  19270. setNormals(data: Nullable<FloatArray>): void;
  19271. /**
  19272. * Gets the normal data stored in this target
  19273. * @returns a FloatArray containing the normal data (or null if not present)
  19274. */
  19275. getNormals(): Nullable<FloatArray>;
  19276. /**
  19277. * Affects tangent data to this target
  19278. * @param data defines the tangent data to use
  19279. */
  19280. setTangents(data: Nullable<FloatArray>): void;
  19281. /**
  19282. * Gets the tangent data stored in this target
  19283. * @returns a FloatArray containing the tangent data (or null if not present)
  19284. */
  19285. getTangents(): Nullable<FloatArray>;
  19286. /**
  19287. * Serializes the current target into a Serialization object
  19288. * @returns the serialized object
  19289. */
  19290. serialize(): any;
  19291. /**
  19292. * Returns the string "MorphTarget"
  19293. * @returns "MorphTarget"
  19294. */
  19295. getClassName(): string;
  19296. /**
  19297. * Creates a new target from serialized data
  19298. * @param serializationObject defines the serialized data to use
  19299. * @returns a new MorphTarget
  19300. */
  19301. static Parse(serializationObject: any): MorphTarget;
  19302. /**
  19303. * Creates a MorphTarget from mesh data
  19304. * @param mesh defines the source mesh
  19305. * @param name defines the name to use for the new target
  19306. * @param influence defines the influence to attach to the target
  19307. * @returns a new MorphTarget
  19308. */
  19309. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19310. }
  19311. }
  19312. declare module "babylonjs/Morph/morphTargetManager" {
  19313. import { Nullable } from "babylonjs/types";
  19314. import { Scene } from "babylonjs/scene";
  19315. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  19316. /**
  19317. * This class is used to deform meshes using morphing between different targets
  19318. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19319. */
  19320. export class MorphTargetManager {
  19321. private _targets;
  19322. private _targetInfluenceChangedObservers;
  19323. private _targetDataLayoutChangedObservers;
  19324. private _activeTargets;
  19325. private _scene;
  19326. private _influences;
  19327. private _supportsNormals;
  19328. private _supportsTangents;
  19329. private _vertexCount;
  19330. private _uniqueId;
  19331. private _tempInfluences;
  19332. /**
  19333. * Creates a new MorphTargetManager
  19334. * @param scene defines the current scene
  19335. */
  19336. constructor(scene?: Nullable<Scene>);
  19337. /**
  19338. * Gets the unique ID of this manager
  19339. */
  19340. readonly uniqueId: number;
  19341. /**
  19342. * Gets the number of vertices handled by this manager
  19343. */
  19344. readonly vertexCount: number;
  19345. /**
  19346. * Gets a boolean indicating if this manager supports morphing of normals
  19347. */
  19348. readonly supportsNormals: boolean;
  19349. /**
  19350. * Gets a boolean indicating if this manager supports morphing of tangents
  19351. */
  19352. readonly supportsTangents: boolean;
  19353. /**
  19354. * Gets the number of targets stored in this manager
  19355. */
  19356. readonly numTargets: number;
  19357. /**
  19358. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19359. */
  19360. readonly numInfluencers: number;
  19361. /**
  19362. * Gets the list of influences (one per target)
  19363. */
  19364. readonly influences: Float32Array;
  19365. /**
  19366. * Gets the active target at specified index. An active target is a target with an influence > 0
  19367. * @param index defines the index to check
  19368. * @returns the requested target
  19369. */
  19370. getActiveTarget(index: number): MorphTarget;
  19371. /**
  19372. * Gets the target at specified index
  19373. * @param index defines the index to check
  19374. * @returns the requested target
  19375. */
  19376. getTarget(index: number): MorphTarget;
  19377. /**
  19378. * Add a new target to this manager
  19379. * @param target defines the target to add
  19380. */
  19381. addTarget(target: MorphTarget): void;
  19382. /**
  19383. * Removes a target from the manager
  19384. * @param target defines the target to remove
  19385. */
  19386. removeTarget(target: MorphTarget): void;
  19387. /**
  19388. * Serializes the current manager into a Serialization object
  19389. * @returns the serialized object
  19390. */
  19391. serialize(): any;
  19392. private _syncActiveTargets;
  19393. /**
  19394. * Syncrhonize the targets with all the meshes using this morph target manager
  19395. */
  19396. synchronize(): void;
  19397. /**
  19398. * Creates a new MorphTargetManager from serialized data
  19399. * @param serializationObject defines the serialized data
  19400. * @param scene defines the hosting scene
  19401. * @returns the new MorphTargetManager
  19402. */
  19403. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19404. }
  19405. }
  19406. declare module "babylonjs/Meshes/groundMesh" {
  19407. import { Scene } from "babylonjs/scene";
  19408. import { Vector3 } from "babylonjs/Maths/math";
  19409. import { Mesh } from "babylonjs/Meshes/mesh";
  19410. /**
  19411. * Mesh representing the gorund
  19412. */
  19413. export class GroundMesh extends Mesh {
  19414. /** If octree should be generated */
  19415. generateOctree: boolean;
  19416. private _heightQuads;
  19417. /** @hidden */
  19418. _subdivisionsX: number;
  19419. /** @hidden */
  19420. _subdivisionsY: number;
  19421. /** @hidden */
  19422. _width: number;
  19423. /** @hidden */
  19424. _height: number;
  19425. /** @hidden */
  19426. _minX: number;
  19427. /** @hidden */
  19428. _maxX: number;
  19429. /** @hidden */
  19430. _minZ: number;
  19431. /** @hidden */
  19432. _maxZ: number;
  19433. constructor(name: string, scene: Scene);
  19434. /**
  19435. * "GroundMesh"
  19436. * @returns "GroundMesh"
  19437. */
  19438. getClassName(): string;
  19439. /**
  19440. * The minimum of x and y subdivisions
  19441. */
  19442. readonly subdivisions: number;
  19443. /**
  19444. * X subdivisions
  19445. */
  19446. readonly subdivisionsX: number;
  19447. /**
  19448. * Y subdivisions
  19449. */
  19450. readonly subdivisionsY: number;
  19451. /**
  19452. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19453. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19454. * @param chunksCount the number of subdivisions for x and y
  19455. * @param octreeBlocksSize (Default: 32)
  19456. */
  19457. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19458. /**
  19459. * Returns a height (y) value in the Worl system :
  19460. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19461. * @param x x coordinate
  19462. * @param z z coordinate
  19463. * @returns the ground y position if (x, z) are outside the ground surface.
  19464. */
  19465. getHeightAtCoordinates(x: number, z: number): number;
  19466. /**
  19467. * Returns a normalized vector (Vector3) orthogonal to the ground
  19468. * at the ground coordinates (x, z) expressed in the World system.
  19469. * @param x x coordinate
  19470. * @param z z coordinate
  19471. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19472. */
  19473. getNormalAtCoordinates(x: number, z: number): Vector3;
  19474. /**
  19475. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19476. * at the ground coordinates (x, z) expressed in the World system.
  19477. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19478. * @param x x coordinate
  19479. * @param z z coordinate
  19480. * @param ref vector to store the result
  19481. * @returns the GroundMesh.
  19482. */
  19483. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19484. /**
  19485. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19486. * if the ground has been updated.
  19487. * This can be used in the render loop.
  19488. * @returns the GroundMesh.
  19489. */
  19490. updateCoordinateHeights(): GroundMesh;
  19491. private _getFacetAt;
  19492. private _initHeightQuads;
  19493. private _computeHeightQuads;
  19494. /**
  19495. * Serializes this ground mesh
  19496. * @param serializationObject object to write serialization to
  19497. */
  19498. serialize(serializationObject: any): void;
  19499. /**
  19500. * Parses a serialized ground mesh
  19501. * @param parsedMesh the serialized mesh
  19502. * @param scene the scene to create the ground mesh in
  19503. * @returns the created ground mesh
  19504. */
  19505. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19506. }
  19507. }
  19508. declare module "babylonjs/Physics/physicsJoint" {
  19509. import { Vector3 } from "babylonjs/Maths/math";
  19510. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  19511. /**
  19512. * Interface for Physics-Joint data
  19513. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19514. */
  19515. export interface PhysicsJointData {
  19516. /**
  19517. * The main pivot of the joint
  19518. */
  19519. mainPivot?: Vector3;
  19520. /**
  19521. * The connected pivot of the joint
  19522. */
  19523. connectedPivot?: Vector3;
  19524. /**
  19525. * The main axis of the joint
  19526. */
  19527. mainAxis?: Vector3;
  19528. /**
  19529. * The connected axis of the joint
  19530. */
  19531. connectedAxis?: Vector3;
  19532. /**
  19533. * The collision of the joint
  19534. */
  19535. collision?: boolean;
  19536. /**
  19537. * Native Oimo/Cannon/Energy data
  19538. */
  19539. nativeParams?: any;
  19540. }
  19541. /**
  19542. * This is a holder class for the physics joint created by the physics plugin
  19543. * It holds a set of functions to control the underlying joint
  19544. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19545. */
  19546. export class PhysicsJoint {
  19547. /**
  19548. * The type of the physics joint
  19549. */
  19550. type: number;
  19551. /**
  19552. * The data for the physics joint
  19553. */
  19554. jointData: PhysicsJointData;
  19555. private _physicsJoint;
  19556. protected _physicsPlugin: IPhysicsEnginePlugin;
  19557. /**
  19558. * Initializes the physics joint
  19559. * @param type The type of the physics joint
  19560. * @param jointData The data for the physics joint
  19561. */
  19562. constructor(
  19563. /**
  19564. * The type of the physics joint
  19565. */
  19566. type: number,
  19567. /**
  19568. * The data for the physics joint
  19569. */
  19570. jointData: PhysicsJointData);
  19571. /**
  19572. * Gets the physics joint
  19573. */
  19574. /**
  19575. * Sets the physics joint
  19576. */
  19577. physicsJoint: any;
  19578. /**
  19579. * Sets the physics plugin
  19580. */
  19581. physicsPlugin: IPhysicsEnginePlugin;
  19582. /**
  19583. * Execute a function that is physics-plugin specific.
  19584. * @param {Function} func the function that will be executed.
  19585. * It accepts two parameters: the physics world and the physics joint
  19586. */
  19587. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19588. /**
  19589. * Distance-Joint type
  19590. */
  19591. static DistanceJoint: number;
  19592. /**
  19593. * Hinge-Joint type
  19594. */
  19595. static HingeJoint: number;
  19596. /**
  19597. * Ball-and-Socket joint type
  19598. */
  19599. static BallAndSocketJoint: number;
  19600. /**
  19601. * Wheel-Joint type
  19602. */
  19603. static WheelJoint: number;
  19604. /**
  19605. * Slider-Joint type
  19606. */
  19607. static SliderJoint: number;
  19608. /**
  19609. * Prismatic-Joint type
  19610. */
  19611. static PrismaticJoint: number;
  19612. /**
  19613. * Universal-Joint type
  19614. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19615. */
  19616. static UniversalJoint: number;
  19617. /**
  19618. * Hinge-Joint 2 type
  19619. */
  19620. static Hinge2Joint: number;
  19621. /**
  19622. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19623. */
  19624. static PointToPointJoint: number;
  19625. /**
  19626. * Spring-Joint type
  19627. */
  19628. static SpringJoint: number;
  19629. /**
  19630. * Lock-Joint type
  19631. */
  19632. static LockJoint: number;
  19633. }
  19634. /**
  19635. * A class representing a physics distance joint
  19636. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19637. */
  19638. export class DistanceJoint extends PhysicsJoint {
  19639. /**
  19640. *
  19641. * @param jointData The data for the Distance-Joint
  19642. */
  19643. constructor(jointData: DistanceJointData);
  19644. /**
  19645. * Update the predefined distance.
  19646. * @param maxDistance The maximum preferred distance
  19647. * @param minDistance The minimum preferred distance
  19648. */
  19649. updateDistance(maxDistance: number, minDistance?: number): void;
  19650. }
  19651. /**
  19652. * Represents a Motor-Enabled Joint
  19653. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19654. */
  19655. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19656. /**
  19657. * Initializes the Motor-Enabled Joint
  19658. * @param type The type of the joint
  19659. * @param jointData The physica joint data for the joint
  19660. */
  19661. constructor(type: number, jointData: PhysicsJointData);
  19662. /**
  19663. * Set the motor values.
  19664. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19665. * @param force the force to apply
  19666. * @param maxForce max force for this motor.
  19667. */
  19668. setMotor(force?: number, maxForce?: number): void;
  19669. /**
  19670. * Set the motor's limits.
  19671. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19672. * @param upperLimit The upper limit of the motor
  19673. * @param lowerLimit The lower limit of the motor
  19674. */
  19675. setLimit(upperLimit: number, lowerLimit?: number): void;
  19676. }
  19677. /**
  19678. * This class represents a single physics Hinge-Joint
  19679. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19680. */
  19681. export class HingeJoint extends MotorEnabledJoint {
  19682. /**
  19683. * Initializes the Hinge-Joint
  19684. * @param jointData The joint data for the Hinge-Joint
  19685. */
  19686. constructor(jointData: PhysicsJointData);
  19687. /**
  19688. * Set the motor values.
  19689. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19690. * @param {number} force the force to apply
  19691. * @param {number} maxForce max force for this motor.
  19692. */
  19693. setMotor(force?: number, maxForce?: number): void;
  19694. /**
  19695. * Set the motor's limits.
  19696. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19697. * @param upperLimit The upper limit of the motor
  19698. * @param lowerLimit The lower limit of the motor
  19699. */
  19700. setLimit(upperLimit: number, lowerLimit?: number): void;
  19701. }
  19702. /**
  19703. * This class represents a dual hinge physics joint (same as wheel joint)
  19704. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19705. */
  19706. export class Hinge2Joint extends MotorEnabledJoint {
  19707. /**
  19708. * Initializes the Hinge2-Joint
  19709. * @param jointData The joint data for the Hinge2-Joint
  19710. */
  19711. constructor(jointData: PhysicsJointData);
  19712. /**
  19713. * Set the motor values.
  19714. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19715. * @param {number} targetSpeed the speed the motor is to reach
  19716. * @param {number} maxForce max force for this motor.
  19717. * @param {motorIndex} the motor's index, 0 or 1.
  19718. */
  19719. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19720. /**
  19721. * Set the motor limits.
  19722. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19723. * @param {number} upperLimit the upper limit
  19724. * @param {number} lowerLimit lower limit
  19725. * @param {motorIndex} the motor's index, 0 or 1.
  19726. */
  19727. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19728. }
  19729. /**
  19730. * Interface for a motor enabled joint
  19731. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19732. */
  19733. export interface IMotorEnabledJoint {
  19734. /**
  19735. * Physics joint
  19736. */
  19737. physicsJoint: any;
  19738. /**
  19739. * Sets the motor of the motor-enabled joint
  19740. * @param force The force of the motor
  19741. * @param maxForce The maximum force of the motor
  19742. * @param motorIndex The index of the motor
  19743. */
  19744. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19745. /**
  19746. * Sets the limit of the motor
  19747. * @param upperLimit The upper limit of the motor
  19748. * @param lowerLimit The lower limit of the motor
  19749. * @param motorIndex The index of the motor
  19750. */
  19751. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19752. }
  19753. /**
  19754. * Joint data for a Distance-Joint
  19755. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19756. */
  19757. export interface DistanceJointData extends PhysicsJointData {
  19758. /**
  19759. * Max distance the 2 joint objects can be apart
  19760. */
  19761. maxDistance: number;
  19762. }
  19763. /**
  19764. * Joint data from a spring joint
  19765. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19766. */
  19767. export interface SpringJointData extends PhysicsJointData {
  19768. /**
  19769. * Length of the spring
  19770. */
  19771. length: number;
  19772. /**
  19773. * Stiffness of the spring
  19774. */
  19775. stiffness: number;
  19776. /**
  19777. * Damping of the spring
  19778. */
  19779. damping: number;
  19780. /** this callback will be called when applying the force to the impostors. */
  19781. forceApplicationCallback: () => void;
  19782. }
  19783. }
  19784. declare module "babylonjs/Physics/IPhysicsEngine" {
  19785. import { Nullable } from "babylonjs/types";
  19786. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  19787. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19788. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  19789. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  19790. /**
  19791. * Interface used to describe a physics joint
  19792. */
  19793. export interface PhysicsImpostorJoint {
  19794. /** Defines the main impostor to which the joint is linked */
  19795. mainImpostor: PhysicsImpostor;
  19796. /** Defines the impostor that is connected to the main impostor using this joint */
  19797. connectedImpostor: PhysicsImpostor;
  19798. /** Defines the joint itself */
  19799. joint: PhysicsJoint;
  19800. }
  19801. /** @hidden */
  19802. export interface IPhysicsEnginePlugin {
  19803. world: any;
  19804. name: string;
  19805. setGravity(gravity: Vector3): void;
  19806. setTimeStep(timeStep: number): void;
  19807. getTimeStep(): number;
  19808. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19809. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19810. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19811. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19812. removePhysicsBody(impostor: PhysicsImpostor): void;
  19813. generateJoint(joint: PhysicsImpostorJoint): void;
  19814. removeJoint(joint: PhysicsImpostorJoint): void;
  19815. isSupported(): boolean;
  19816. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19817. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19818. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19819. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19820. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19821. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19822. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19823. getBodyMass(impostor: PhysicsImpostor): number;
  19824. getBodyFriction(impostor: PhysicsImpostor): number;
  19825. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19826. getBodyRestitution(impostor: PhysicsImpostor): number;
  19827. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19828. sleepBody(impostor: PhysicsImpostor): void;
  19829. wakeUpBody(impostor: PhysicsImpostor): void;
  19830. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19831. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19832. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19833. getRadius(impostor: PhysicsImpostor): number;
  19834. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19835. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19836. dispose(): void;
  19837. }
  19838. /**
  19839. * Interface used to define a physics engine
  19840. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19841. */
  19842. export interface IPhysicsEngine {
  19843. /**
  19844. * Gets the gravity vector used by the simulation
  19845. */
  19846. gravity: Vector3;
  19847. /**
  19848. * Sets the gravity vector used by the simulation
  19849. * @param gravity defines the gravity vector to use
  19850. */
  19851. setGravity(gravity: Vector3): void;
  19852. /**
  19853. * Set the time step of the physics engine.
  19854. * Default is 1/60.
  19855. * To slow it down, enter 1/600 for example.
  19856. * To speed it up, 1/30
  19857. * @param newTimeStep the new timestep to apply to this world.
  19858. */
  19859. setTimeStep(newTimeStep: number): void;
  19860. /**
  19861. * Get the time step of the physics engine.
  19862. * @returns the current time step
  19863. */
  19864. getTimeStep(): number;
  19865. /**
  19866. * Release all resources
  19867. */
  19868. dispose(): void;
  19869. /**
  19870. * Gets the name of the current physics plugin
  19871. * @returns the name of the plugin
  19872. */
  19873. getPhysicsPluginName(): string;
  19874. /**
  19875. * Adding a new impostor for the impostor tracking.
  19876. * This will be done by the impostor itself.
  19877. * @param impostor the impostor to add
  19878. */
  19879. addImpostor(impostor: PhysicsImpostor): void;
  19880. /**
  19881. * Remove an impostor from the engine.
  19882. * This impostor and its mesh will not longer be updated by the physics engine.
  19883. * @param impostor the impostor to remove
  19884. */
  19885. removeImpostor(impostor: PhysicsImpostor): void;
  19886. /**
  19887. * Add a joint to the physics engine
  19888. * @param mainImpostor defines the main impostor to which the joint is added.
  19889. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  19890. * @param joint defines the joint that will connect both impostors.
  19891. */
  19892. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19893. /**
  19894. * Removes a joint from the simulation
  19895. * @param mainImpostor defines the impostor used with the joint
  19896. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  19897. * @param joint defines the joint to remove
  19898. */
  19899. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19900. /**
  19901. * Gets the current plugin used to run the simulation
  19902. * @returns current plugin
  19903. */
  19904. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19905. /**
  19906. * Gets the list of physic impostors
  19907. * @returns an array of PhysicsImpostor
  19908. */
  19909. getImpostors(): Array<PhysicsImpostor>;
  19910. /**
  19911. * Gets the impostor for a physics enabled object
  19912. * @param object defines the object impersonated by the impostor
  19913. * @returns the PhysicsImpostor or null if not found
  19914. */
  19915. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19916. /**
  19917. * Gets the impostor for a physics body object
  19918. * @param body defines physics body used by the impostor
  19919. * @returns the PhysicsImpostor or null if not found
  19920. */
  19921. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19922. /**
  19923. * Called by the scene. No need to call it.
  19924. * @param delta defines the timespam between frames
  19925. */
  19926. _step(delta: number): void;
  19927. }
  19928. }
  19929. declare module "babylonjs/Physics/physicsImpostor" {
  19930. import { Nullable, IndicesArray } from "babylonjs/types";
  19931. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  19932. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19933. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19934. import { Scene } from "babylonjs/scene";
  19935. import { Bone } from "babylonjs/Bones/bone";
  19936. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  19937. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  19938. /**
  19939. * The interface for the physics imposter parameters
  19940. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19941. */
  19942. export interface PhysicsImpostorParameters {
  19943. /**
  19944. * The mass of the physics imposter
  19945. */
  19946. mass: number;
  19947. /**
  19948. * The friction of the physics imposter
  19949. */
  19950. friction?: number;
  19951. /**
  19952. * The coefficient of restitution of the physics imposter
  19953. */
  19954. restitution?: number;
  19955. /**
  19956. * The native options of the physics imposter
  19957. */
  19958. nativeOptions?: any;
  19959. /**
  19960. * Specifies if the parent should be ignored
  19961. */
  19962. ignoreParent?: boolean;
  19963. /**
  19964. * Specifies if bi-directional transformations should be disabled
  19965. */
  19966. disableBidirectionalTransformation?: boolean;
  19967. }
  19968. /**
  19969. * Interface for a physics-enabled object
  19970. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19971. */
  19972. export interface IPhysicsEnabledObject {
  19973. /**
  19974. * The position of the physics-enabled object
  19975. */
  19976. position: Vector3;
  19977. /**
  19978. * The rotation of the physics-enabled object
  19979. */
  19980. rotationQuaternion: Nullable<Quaternion>;
  19981. /**
  19982. * The scale of the physics-enabled object
  19983. */
  19984. scaling: Vector3;
  19985. /**
  19986. * The rotation of the physics-enabled object
  19987. */
  19988. rotation?: Vector3;
  19989. /**
  19990. * The parent of the physics-enabled object
  19991. */
  19992. parent?: any;
  19993. /**
  19994. * The bounding info of the physics-enabled object
  19995. * @returns The bounding info of the physics-enabled object
  19996. */
  19997. getBoundingInfo(): BoundingInfo;
  19998. /**
  19999. * Computes the world matrix
  20000. * @param force Specifies if the world matrix should be computed by force
  20001. * @returns A world matrix
  20002. */
  20003. computeWorldMatrix(force: boolean): Matrix;
  20004. /**
  20005. * Gets the world matrix
  20006. * @returns A world matrix
  20007. */
  20008. getWorldMatrix?(): Matrix;
  20009. /**
  20010. * Gets the child meshes
  20011. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20012. * @returns An array of abstract meshes
  20013. */
  20014. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20015. /**
  20016. * Gets the vertex data
  20017. * @param kind The type of vertex data
  20018. * @returns A nullable array of numbers, or a float32 array
  20019. */
  20020. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20021. /**
  20022. * Gets the indices from the mesh
  20023. * @returns A nullable array of index arrays
  20024. */
  20025. getIndices?(): Nullable<IndicesArray>;
  20026. /**
  20027. * Gets the scene from the mesh
  20028. * @returns the indices array or null
  20029. */
  20030. getScene?(): Scene;
  20031. /**
  20032. * Gets the absolute position from the mesh
  20033. * @returns the absolute position
  20034. */
  20035. getAbsolutePosition(): Vector3;
  20036. /**
  20037. * Gets the absolute pivot point from the mesh
  20038. * @returns the absolute pivot point
  20039. */
  20040. getAbsolutePivotPoint(): Vector3;
  20041. /**
  20042. * Rotates the mesh
  20043. * @param axis The axis of rotation
  20044. * @param amount The amount of rotation
  20045. * @param space The space of the rotation
  20046. * @returns The rotation transform node
  20047. */
  20048. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20049. /**
  20050. * Translates the mesh
  20051. * @param axis The axis of translation
  20052. * @param distance The distance of translation
  20053. * @param space The space of the translation
  20054. * @returns The transform node
  20055. */
  20056. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20057. /**
  20058. * Sets the absolute position of the mesh
  20059. * @param absolutePosition The absolute position of the mesh
  20060. * @returns The transform node
  20061. */
  20062. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20063. /**
  20064. * Gets the class name of the mesh
  20065. * @returns The class name
  20066. */
  20067. getClassName(): string;
  20068. }
  20069. /**
  20070. * Represents a physics imposter
  20071. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20072. */
  20073. export class PhysicsImpostor {
  20074. /**
  20075. * The physics-enabled object used as the physics imposter
  20076. */
  20077. object: IPhysicsEnabledObject;
  20078. /**
  20079. * The type of the physics imposter
  20080. */
  20081. type: number;
  20082. private _options;
  20083. private _scene?;
  20084. /**
  20085. * The default object size of the imposter
  20086. */
  20087. static DEFAULT_OBJECT_SIZE: Vector3;
  20088. /**
  20089. * The identity quaternion of the imposter
  20090. */
  20091. static IDENTITY_QUATERNION: Quaternion;
  20092. /** @hidden */
  20093. _pluginData: any;
  20094. private _physicsEngine;
  20095. private _physicsBody;
  20096. private _bodyUpdateRequired;
  20097. private _onBeforePhysicsStepCallbacks;
  20098. private _onAfterPhysicsStepCallbacks;
  20099. /** @hidden */
  20100. _onPhysicsCollideCallbacks: Array<{
  20101. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20102. otherImpostors: Array<PhysicsImpostor>;
  20103. }>;
  20104. private _deltaPosition;
  20105. private _deltaRotation;
  20106. private _deltaRotationConjugated;
  20107. private _parent;
  20108. private _isDisposed;
  20109. private static _tmpVecs;
  20110. private static _tmpQuat;
  20111. /**
  20112. * Specifies if the physics imposter is disposed
  20113. */
  20114. readonly isDisposed: boolean;
  20115. /**
  20116. * Gets the mass of the physics imposter
  20117. */
  20118. mass: number;
  20119. /**
  20120. * Gets the coefficient of friction
  20121. */
  20122. /**
  20123. * Sets the coefficient of friction
  20124. */
  20125. friction: number;
  20126. /**
  20127. * Gets the coefficient of restitution
  20128. */
  20129. /**
  20130. * Sets the coefficient of restitution
  20131. */
  20132. restitution: number;
  20133. /**
  20134. * The unique id of the physics imposter
  20135. * set by the physics engine when adding this impostor to the array
  20136. */
  20137. uniqueId: number;
  20138. private _joints;
  20139. /**
  20140. * Initializes the physics imposter
  20141. * @param object The physics-enabled object used as the physics imposter
  20142. * @param type The type of the physics imposter
  20143. * @param _options The options for the physics imposter
  20144. * @param _scene The Babylon scene
  20145. */
  20146. constructor(
  20147. /**
  20148. * The physics-enabled object used as the physics imposter
  20149. */
  20150. object: IPhysicsEnabledObject,
  20151. /**
  20152. * The type of the physics imposter
  20153. */
  20154. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20155. /**
  20156. * This function will completly initialize this impostor.
  20157. * It will create a new body - but only if this mesh has no parent.
  20158. * If it has, this impostor will not be used other than to define the impostor
  20159. * of the child mesh.
  20160. * @hidden
  20161. */
  20162. _init(): void;
  20163. private _getPhysicsParent;
  20164. /**
  20165. * Should a new body be generated.
  20166. * @returns boolean specifying if body initialization is required
  20167. */
  20168. isBodyInitRequired(): boolean;
  20169. /**
  20170. * Sets the updated scaling
  20171. * @param updated Specifies if the scaling is updated
  20172. */
  20173. setScalingUpdated(): void;
  20174. /**
  20175. * Force a regeneration of this or the parent's impostor's body.
  20176. * Use under cautious - This will remove all joints already implemented.
  20177. */
  20178. forceUpdate(): void;
  20179. /**
  20180. * Gets the body that holds this impostor. Either its own, or its parent.
  20181. */
  20182. /**
  20183. * Set the physics body. Used mainly by the physics engine/plugin
  20184. */
  20185. physicsBody: any;
  20186. /**
  20187. * Get the parent of the physics imposter
  20188. * @returns Physics imposter or null
  20189. */
  20190. /**
  20191. * Sets the parent of the physics imposter
  20192. */
  20193. parent: Nullable<PhysicsImpostor>;
  20194. /**
  20195. * Resets the update flags
  20196. */
  20197. resetUpdateFlags(): void;
  20198. /**
  20199. * Gets the object extend size
  20200. * @returns the object extend size
  20201. */
  20202. getObjectExtendSize(): Vector3;
  20203. /**
  20204. * Gets the object center
  20205. * @returns The object center
  20206. */
  20207. getObjectCenter(): Vector3;
  20208. /**
  20209. * Get a specific parametes from the options parameter
  20210. * @param paramName The object parameter name
  20211. * @returns The object parameter
  20212. */
  20213. getParam(paramName: string): any;
  20214. /**
  20215. * Sets a specific parameter in the options given to the physics plugin
  20216. * @param paramName The parameter name
  20217. * @param value The value of the parameter
  20218. */
  20219. setParam(paramName: string, value: number): void;
  20220. /**
  20221. * Specifically change the body's mass option. Won't recreate the physics body object
  20222. * @param mass The mass of the physics imposter
  20223. */
  20224. setMass(mass: number): void;
  20225. /**
  20226. * Gets the linear velocity
  20227. * @returns linear velocity or null
  20228. */
  20229. getLinearVelocity(): Nullable<Vector3>;
  20230. /**
  20231. * Sets the linear velocity
  20232. * @param velocity linear velocity or null
  20233. */
  20234. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20235. /**
  20236. * Gets the angular velocity
  20237. * @returns angular velocity or null
  20238. */
  20239. getAngularVelocity(): Nullable<Vector3>;
  20240. /**
  20241. * Sets the angular velocity
  20242. * @param velocity The velocity or null
  20243. */
  20244. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20245. /**
  20246. * Execute a function with the physics plugin native code
  20247. * Provide a function the will have two variables - the world object and the physics body object
  20248. * @param func The function to execute with the physics plugin native code
  20249. */
  20250. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20251. /**
  20252. * Register a function that will be executed before the physics world is stepping forward
  20253. * @param func The function to execute before the physics world is stepped forward
  20254. */
  20255. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20256. /**
  20257. * Unregister a function that will be executed before the physics world is stepping forward
  20258. * @param func The function to execute before the physics world is stepped forward
  20259. */
  20260. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20261. /**
  20262. * Register a function that will be executed after the physics step
  20263. * @param func The function to execute after physics step
  20264. */
  20265. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20266. /**
  20267. * Unregisters a function that will be executed after the physics step
  20268. * @param func The function to execute after physics step
  20269. */
  20270. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20271. /**
  20272. * register a function that will be executed when this impostor collides against a different body
  20273. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20274. * @param func Callback that is executed on collision
  20275. */
  20276. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20277. /**
  20278. * Unregisters the physics imposter on contact
  20279. * @param collideAgainst The physics object to collide against
  20280. * @param func Callback to execute on collision
  20281. */
  20282. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20283. private _tmpQuat;
  20284. private _tmpQuat2;
  20285. /**
  20286. * Get the parent rotation
  20287. * @returns The parent rotation
  20288. */
  20289. getParentsRotation(): Quaternion;
  20290. /**
  20291. * this function is executed by the physics engine.
  20292. */
  20293. beforeStep: () => void;
  20294. /**
  20295. * this function is executed by the physics engine
  20296. */
  20297. afterStep: () => void;
  20298. /**
  20299. * Legacy collision detection event support
  20300. */
  20301. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20302. /**
  20303. * event and body object due to cannon's event-based architecture.
  20304. */
  20305. onCollide: (e: {
  20306. body: any;
  20307. }) => void;
  20308. /**
  20309. * Apply a force
  20310. * @param force The force to apply
  20311. * @param contactPoint The contact point for the force
  20312. * @returns The physics imposter
  20313. */
  20314. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20315. /**
  20316. * Apply an impulse
  20317. * @param force The impulse force
  20318. * @param contactPoint The contact point for the impulse force
  20319. * @returns The physics imposter
  20320. */
  20321. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20322. /**
  20323. * A help function to create a joint
  20324. * @param otherImpostor A physics imposter used to create a joint
  20325. * @param jointType The type of joint
  20326. * @param jointData The data for the joint
  20327. * @returns The physics imposter
  20328. */
  20329. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20330. /**
  20331. * Add a joint to this impostor with a different impostor
  20332. * @param otherImpostor A physics imposter used to add a joint
  20333. * @param joint The joint to add
  20334. * @returns The physics imposter
  20335. */
  20336. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20337. /**
  20338. * Will keep this body still, in a sleep mode.
  20339. * @returns the physics imposter
  20340. */
  20341. sleep(): PhysicsImpostor;
  20342. /**
  20343. * Wake the body up.
  20344. * @returns The physics imposter
  20345. */
  20346. wakeUp(): PhysicsImpostor;
  20347. /**
  20348. * Clones the physics imposter
  20349. * @param newObject The physics imposter clones to this physics-enabled object
  20350. * @returns A nullable physics imposter
  20351. */
  20352. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20353. /**
  20354. * Disposes the physics imposter
  20355. */
  20356. dispose(): void;
  20357. /**
  20358. * Sets the delta position
  20359. * @param position The delta position amount
  20360. */
  20361. setDeltaPosition(position: Vector3): void;
  20362. /**
  20363. * Sets the delta rotation
  20364. * @param rotation The delta rotation amount
  20365. */
  20366. setDeltaRotation(rotation: Quaternion): void;
  20367. /**
  20368. * Gets the box size of the physics imposter and stores the result in the input parameter
  20369. * @param result Stores the box size
  20370. * @returns The physics imposter
  20371. */
  20372. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20373. /**
  20374. * Gets the radius of the physics imposter
  20375. * @returns Radius of the physics imposter
  20376. */
  20377. getRadius(): number;
  20378. /**
  20379. * Sync a bone with this impostor
  20380. * @param bone The bone to sync to the impostor.
  20381. * @param boneMesh The mesh that the bone is influencing.
  20382. * @param jointPivot The pivot of the joint / bone in local space.
  20383. * @param distToJoint Optional distance from the impostor to the joint.
  20384. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20385. */
  20386. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20387. /**
  20388. * Sync impostor to a bone
  20389. * @param bone The bone that the impostor will be synced to.
  20390. * @param boneMesh The mesh that the bone is influencing.
  20391. * @param jointPivot The pivot of the joint / bone in local space.
  20392. * @param distToJoint Optional distance from the impostor to the joint.
  20393. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20394. * @param boneAxis Optional vector3 axis the bone is aligned with
  20395. */
  20396. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20397. /**
  20398. * No-Imposter type
  20399. */
  20400. static NoImpostor: number;
  20401. /**
  20402. * Sphere-Imposter type
  20403. */
  20404. static SphereImpostor: number;
  20405. /**
  20406. * Box-Imposter type
  20407. */
  20408. static BoxImpostor: number;
  20409. /**
  20410. * Plane-Imposter type
  20411. */
  20412. static PlaneImpostor: number;
  20413. /**
  20414. * Mesh-imposter type
  20415. */
  20416. static MeshImpostor: number;
  20417. /**
  20418. * Cylinder-Imposter type
  20419. */
  20420. static CylinderImpostor: number;
  20421. /**
  20422. * Particle-Imposter type
  20423. */
  20424. static ParticleImpostor: number;
  20425. /**
  20426. * Heightmap-Imposter type
  20427. */
  20428. static HeightmapImpostor: number;
  20429. }
  20430. }
  20431. declare module "babylonjs/Meshes/mesh" {
  20432. import { Observable } from "babylonjs/Misc/observable";
  20433. import { IAnimatable } from "babylonjs/Misc/tools";
  20434. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  20435. import { Camera } from "babylonjs/Cameras/camera";
  20436. import { Scene } from "babylonjs/scene";
  20437. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  20438. import { Engine } from "babylonjs/Engines/engine";
  20439. import { Node } from "babylonjs/node";
  20440. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20441. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  20442. import { Buffer } from "babylonjs/Meshes/buffer";
  20443. import { Geometry } from "babylonjs/Meshes/geometry";
  20444. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20445. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20446. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  20447. import { Effect } from "babylonjs/Materials/effect";
  20448. import { Material } from "babylonjs/Materials/material";
  20449. import { Skeleton } from "babylonjs/Bones/skeleton";
  20450. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  20451. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  20452. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20453. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  20454. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20455. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  20456. /**
  20457. * Class used to represent a specific level of detail of a mesh
  20458. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20459. */
  20460. export class MeshLODLevel {
  20461. /** Defines the distance where this level should star being displayed */
  20462. distance: number;
  20463. /** Defines the mesh to use to render this level */
  20464. mesh: Nullable<Mesh>;
  20465. /**
  20466. * Creates a new LOD level
  20467. * @param distance defines the distance where this level should star being displayed
  20468. * @param mesh defines the mesh to use to render this level
  20469. */
  20470. constructor(
  20471. /** Defines the distance where this level should star being displayed */
  20472. distance: number,
  20473. /** Defines the mesh to use to render this level */
  20474. mesh: Nullable<Mesh>);
  20475. }
  20476. /**
  20477. * @hidden
  20478. **/
  20479. export class _CreationDataStorage {
  20480. closePath?: boolean;
  20481. closeArray?: boolean;
  20482. idx: number[];
  20483. dashSize: number;
  20484. gapSize: number;
  20485. path3D: Path3D;
  20486. pathArray: Vector3[][];
  20487. arc: number;
  20488. radius: number;
  20489. cap: number;
  20490. tessellation: number;
  20491. }
  20492. /**
  20493. * @hidden
  20494. **/
  20495. class _InstanceDataStorage {
  20496. visibleInstances: any;
  20497. renderIdForInstances: number[];
  20498. batchCache: _InstancesBatch;
  20499. instancesBufferSize: number;
  20500. instancesBuffer: Nullable<Buffer>;
  20501. instancesData: Float32Array;
  20502. overridenInstanceCount: number;
  20503. }
  20504. /**
  20505. * @hidden
  20506. **/
  20507. export class _InstancesBatch {
  20508. mustReturn: boolean;
  20509. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  20510. renderSelf: boolean[];
  20511. }
  20512. /**
  20513. * Class used to represent renderable models
  20514. */
  20515. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20516. /**
  20517. * Mesh side orientation : usually the external or front surface
  20518. */
  20519. static readonly FRONTSIDE: number;
  20520. /**
  20521. * Mesh side orientation : usually the internal or back surface
  20522. */
  20523. static readonly BACKSIDE: number;
  20524. /**
  20525. * Mesh side orientation : both internal and external or front and back surfaces
  20526. */
  20527. static readonly DOUBLESIDE: number;
  20528. /**
  20529. * Mesh side orientation : by default, `FRONTSIDE`
  20530. */
  20531. static readonly DEFAULTSIDE: number;
  20532. /**
  20533. * Mesh cap setting : no cap
  20534. */
  20535. static readonly NO_CAP: number;
  20536. /**
  20537. * Mesh cap setting : one cap at the beginning of the mesh
  20538. */
  20539. static readonly CAP_START: number;
  20540. /**
  20541. * Mesh cap setting : one cap at the end of the mesh
  20542. */
  20543. static readonly CAP_END: number;
  20544. /**
  20545. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20546. */
  20547. static readonly CAP_ALL: number;
  20548. /**
  20549. * Gets the default side orientation.
  20550. * @param orientation the orientation to value to attempt to get
  20551. * @returns the default orientation
  20552. * @hidden
  20553. */
  20554. static _GetDefaultSideOrientation(orientation?: number): number;
  20555. private _onBeforeRenderObservable;
  20556. private _onBeforeBindObservable;
  20557. private _onAfterRenderObservable;
  20558. private _onBeforeDrawObservable;
  20559. /**
  20560. * An event triggered before rendering the mesh
  20561. */
  20562. readonly onBeforeRenderObservable: Observable<Mesh>;
  20563. /**
  20564. * An event triggered before binding the mesh
  20565. */
  20566. readonly onBeforeBindObservable: Observable<Mesh>;
  20567. /**
  20568. * An event triggered after rendering the mesh
  20569. */
  20570. readonly onAfterRenderObservable: Observable<Mesh>;
  20571. /**
  20572. * An event triggered before drawing the mesh
  20573. */
  20574. readonly onBeforeDrawObservable: Observable<Mesh>;
  20575. private _onBeforeDrawObserver;
  20576. /**
  20577. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20578. */
  20579. onBeforeDraw: () => void;
  20580. /**
  20581. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20582. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20583. */
  20584. delayLoadState: number;
  20585. /**
  20586. * Gets the list of instances created from this mesh
  20587. * it is not supposed to be modified manually.
  20588. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20589. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20590. */
  20591. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  20592. /**
  20593. * Gets the file containing delay loading data for this mesh
  20594. */
  20595. delayLoadingFile: string;
  20596. /** @hidden */
  20597. _binaryInfo: any;
  20598. private _LODLevels;
  20599. /**
  20600. * User defined function used to change how LOD level selection is done
  20601. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20602. */
  20603. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20604. private _morphTargetManager;
  20605. /**
  20606. * Gets or sets the morph target manager
  20607. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20608. */
  20609. morphTargetManager: Nullable<MorphTargetManager>;
  20610. /** @hidden */
  20611. _creationDataStorage: Nullable<_CreationDataStorage>;
  20612. /** @hidden */
  20613. _geometry: Nullable<Geometry>;
  20614. /** @hidden */
  20615. _delayInfo: Array<string>;
  20616. /** @hidden */
  20617. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20618. /** @hidden */
  20619. _instanceDataStorage: _InstanceDataStorage;
  20620. private _effectiveMaterial;
  20621. /** @hidden */
  20622. _shouldGenerateFlatShading: boolean;
  20623. private _preActivateId;
  20624. /** @hidden */
  20625. _originalBuilderSideOrientation: number;
  20626. /**
  20627. * Use this property to change the original side orientation defined at construction time
  20628. */
  20629. overrideMaterialSideOrientation: Nullable<number>;
  20630. private _areNormalsFrozen;
  20631. private _sourcePositions;
  20632. private _sourceNormals;
  20633. private _source;
  20634. private meshMap;
  20635. /**
  20636. * Gets the source mesh (the one used to clone this one from)
  20637. */
  20638. readonly source: Nullable<Mesh>;
  20639. /**
  20640. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20641. */
  20642. isUnIndexed: boolean;
  20643. /**
  20644. * @constructor
  20645. * @param name The value used by scene.getMeshByName() to do a lookup.
  20646. * @param scene The scene to add this mesh to.
  20647. * @param parent The parent of this mesh, if it has one
  20648. * @param source An optional Mesh from which geometry is shared, cloned.
  20649. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20650. * When false, achieved by calling a clone(), also passing False.
  20651. * This will make creation of children, recursive.
  20652. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20653. */
  20654. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20655. /**
  20656. * Gets the class name
  20657. * @returns the string "Mesh".
  20658. */
  20659. getClassName(): string;
  20660. /** @hidden */
  20661. readonly _isMesh: boolean;
  20662. /**
  20663. * Returns a description of this mesh
  20664. * @param fullDetails define if full details about this mesh must be used
  20665. * @returns a descriptive string representing this mesh
  20666. */
  20667. toString(fullDetails?: boolean): string;
  20668. /** @hidden */
  20669. _unBindEffect(): void;
  20670. /**
  20671. * Gets a boolean indicating if this mesh has LOD
  20672. */
  20673. readonly hasLODLevels: boolean;
  20674. /**
  20675. * Gets the list of MeshLODLevel associated with the current mesh
  20676. * @returns an array of MeshLODLevel
  20677. */
  20678. getLODLevels(): MeshLODLevel[];
  20679. private _sortLODLevels;
  20680. /**
  20681. * Add a mesh as LOD level triggered at the given distance.
  20682. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20683. * @param distance The distance from the center of the object to show this level
  20684. * @param mesh The mesh to be added as LOD level (can be null)
  20685. * @return This mesh (for chaining)
  20686. */
  20687. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20688. /**
  20689. * Returns the LOD level mesh at the passed distance or null if not found.
  20690. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20691. * @param distance The distance from the center of the object to show this level
  20692. * @returns a Mesh or `null`
  20693. */
  20694. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20695. /**
  20696. * Remove a mesh from the LOD array
  20697. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20698. * @param mesh defines the mesh to be removed
  20699. * @return This mesh (for chaining)
  20700. */
  20701. removeLODLevel(mesh: Mesh): Mesh;
  20702. /**
  20703. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20704. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20705. * @param camera defines the camera to use to compute distance
  20706. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  20707. * @return This mesh (for chaining)
  20708. */
  20709. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20710. /**
  20711. * Gets the mesh internal Geometry object
  20712. */
  20713. readonly geometry: Nullable<Geometry>;
  20714. /**
  20715. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20716. * @returns the total number of vertices
  20717. */
  20718. getTotalVertices(): number;
  20719. /**
  20720. * Returns the content of an associated vertex buffer
  20721. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20722. * - VertexBuffer.PositionKind
  20723. * - VertexBuffer.UVKind
  20724. * - VertexBuffer.UV2Kind
  20725. * - VertexBuffer.UV3Kind
  20726. * - VertexBuffer.UV4Kind
  20727. * - VertexBuffer.UV5Kind
  20728. * - VertexBuffer.UV6Kind
  20729. * - VertexBuffer.ColorKind
  20730. * - VertexBuffer.MatricesIndicesKind
  20731. * - VertexBuffer.MatricesIndicesExtraKind
  20732. * - VertexBuffer.MatricesWeightsKind
  20733. * - VertexBuffer.MatricesWeightsExtraKind
  20734. * @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
  20735. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  20736. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  20737. */
  20738. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20739. /**
  20740. * Returns the mesh VertexBuffer object from the requested `kind`
  20741. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20742. * - VertexBuffer.PositionKind
  20743. * - VertexBuffer.UVKind
  20744. * - VertexBuffer.UV2Kind
  20745. * - VertexBuffer.UV3Kind
  20746. * - VertexBuffer.UV4Kind
  20747. * - VertexBuffer.UV5Kind
  20748. * - VertexBuffer.UV6Kind
  20749. * - VertexBuffer.ColorKind
  20750. * - VertexBuffer.MatricesIndicesKind
  20751. * - VertexBuffer.MatricesIndicesExtraKind
  20752. * - VertexBuffer.MatricesWeightsKind
  20753. * - VertexBuffer.MatricesWeightsExtraKind
  20754. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  20755. */
  20756. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20757. /**
  20758. * Tests if a specific vertex buffer is associated with this mesh
  20759. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20760. * - VertexBuffer.PositionKind
  20761. * - VertexBuffer.UVKind
  20762. * - VertexBuffer.UV2Kind
  20763. * - VertexBuffer.UV3Kind
  20764. * - VertexBuffer.UV4Kind
  20765. * - VertexBuffer.UV5Kind
  20766. * - VertexBuffer.UV6Kind
  20767. * - VertexBuffer.ColorKind
  20768. * - VertexBuffer.MatricesIndicesKind
  20769. * - VertexBuffer.MatricesIndicesExtraKind
  20770. * - VertexBuffer.MatricesWeightsKind
  20771. * - VertexBuffer.MatricesWeightsExtraKind
  20772. * @returns a boolean
  20773. */
  20774. isVerticesDataPresent(kind: string): boolean;
  20775. /**
  20776. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20777. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20778. * - VertexBuffer.PositionKind
  20779. * - VertexBuffer.UVKind
  20780. * - VertexBuffer.UV2Kind
  20781. * - VertexBuffer.UV3Kind
  20782. * - VertexBuffer.UV4Kind
  20783. * - VertexBuffer.UV5Kind
  20784. * - VertexBuffer.UV6Kind
  20785. * - VertexBuffer.ColorKind
  20786. * - VertexBuffer.MatricesIndicesKind
  20787. * - VertexBuffer.MatricesIndicesExtraKind
  20788. * - VertexBuffer.MatricesWeightsKind
  20789. * - VertexBuffer.MatricesWeightsExtraKind
  20790. * @returns a boolean
  20791. */
  20792. isVertexBufferUpdatable(kind: string): boolean;
  20793. /**
  20794. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  20795. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20796. * - VertexBuffer.PositionKind
  20797. * - VertexBuffer.UVKind
  20798. * - VertexBuffer.UV2Kind
  20799. * - VertexBuffer.UV3Kind
  20800. * - VertexBuffer.UV4Kind
  20801. * - VertexBuffer.UV5Kind
  20802. * - VertexBuffer.UV6Kind
  20803. * - VertexBuffer.ColorKind
  20804. * - VertexBuffer.MatricesIndicesKind
  20805. * - VertexBuffer.MatricesIndicesExtraKind
  20806. * - VertexBuffer.MatricesWeightsKind
  20807. * - VertexBuffer.MatricesWeightsExtraKind
  20808. * @returns an array of strings
  20809. */
  20810. getVerticesDataKinds(): string[];
  20811. /**
  20812. * Returns a positive integer : the total number of indices in this mesh geometry.
  20813. * @returns the numner of indices or zero if the mesh has no geometry.
  20814. */
  20815. getTotalIndices(): number;
  20816. /**
  20817. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20818. * @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.
  20819. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20820. * @returns the indices array or an empty array if the mesh has no geometry
  20821. */
  20822. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20823. readonly isBlocked: boolean;
  20824. /**
  20825. * Determine if the current mesh is ready to be rendered
  20826. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20827. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20828. * @returns true if all associated assets are ready (material, textures, shaders)
  20829. */
  20830. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20831. /**
  20832. * 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.
  20833. */
  20834. readonly areNormalsFrozen: boolean;
  20835. /**
  20836. * 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.
  20837. * @returns the current mesh
  20838. */
  20839. freezeNormals(): Mesh;
  20840. /**
  20841. * 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
  20842. * @returns the current mesh
  20843. */
  20844. unfreezeNormals(): Mesh;
  20845. /**
  20846. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20847. */
  20848. overridenInstanceCount: number;
  20849. /** @hidden */
  20850. _preActivate(): Mesh;
  20851. /** @hidden */
  20852. _preActivateForIntermediateRendering(renderId: number): Mesh;
  20853. /** @hidden */
  20854. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20855. /**
  20856. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20857. * This means the mesh underlying bounding box and sphere are recomputed.
  20858. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  20859. * @returns the current mesh
  20860. */
  20861. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  20862. /** @hidden */
  20863. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20864. /**
  20865. * This function will subdivide the mesh into multiple submeshes
  20866. * @param count defines the expected number of submeshes
  20867. */
  20868. subdivide(count: number): void;
  20869. /**
  20870. * Copy a FloatArray into a specific associated vertex buffer
  20871. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20872. * - VertexBuffer.PositionKind
  20873. * - VertexBuffer.UVKind
  20874. * - VertexBuffer.UV2Kind
  20875. * - VertexBuffer.UV3Kind
  20876. * - VertexBuffer.UV4Kind
  20877. * - VertexBuffer.UV5Kind
  20878. * - VertexBuffer.UV6Kind
  20879. * - VertexBuffer.ColorKind
  20880. * - VertexBuffer.MatricesIndicesKind
  20881. * - VertexBuffer.MatricesIndicesExtraKind
  20882. * - VertexBuffer.MatricesWeightsKind
  20883. * - VertexBuffer.MatricesWeightsExtraKind
  20884. * @param data defines the data source
  20885. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20886. * @param stride defines the data stride size (can be null)
  20887. * @returns the current mesh
  20888. */
  20889. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20890. /**
  20891. * Flags an associated vertex buffer as updatable
  20892. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  20893. * - VertexBuffer.PositionKind
  20894. * - VertexBuffer.UVKind
  20895. * - VertexBuffer.UV2Kind
  20896. * - VertexBuffer.UV3Kind
  20897. * - VertexBuffer.UV4Kind
  20898. * - VertexBuffer.UV5Kind
  20899. * - VertexBuffer.UV6Kind
  20900. * - VertexBuffer.ColorKind
  20901. * - VertexBuffer.MatricesIndicesKind
  20902. * - VertexBuffer.MatricesIndicesExtraKind
  20903. * - VertexBuffer.MatricesWeightsKind
  20904. * - VertexBuffer.MatricesWeightsExtraKind
  20905. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20906. */
  20907. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20908. /**
  20909. * Sets the mesh global Vertex Buffer
  20910. * @param buffer defines the buffer to use
  20911. * @returns the current mesh
  20912. */
  20913. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20914. /**
  20915. * Update a specific associated vertex buffer
  20916. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20917. * - VertexBuffer.PositionKind
  20918. * - VertexBuffer.UVKind
  20919. * - VertexBuffer.UV2Kind
  20920. * - VertexBuffer.UV3Kind
  20921. * - VertexBuffer.UV4Kind
  20922. * - VertexBuffer.UV5Kind
  20923. * - VertexBuffer.UV6Kind
  20924. * - VertexBuffer.ColorKind
  20925. * - VertexBuffer.MatricesIndicesKind
  20926. * - VertexBuffer.MatricesIndicesExtraKind
  20927. * - VertexBuffer.MatricesWeightsKind
  20928. * - VertexBuffer.MatricesWeightsExtraKind
  20929. * @param data defines the data source
  20930. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20931. * @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)
  20932. * @returns the current mesh
  20933. */
  20934. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20935. /**
  20936. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20937. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20938. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  20939. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  20940. * @returns the current mesh
  20941. */
  20942. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20943. /**
  20944. * Creates a un-shared specific occurence of the geometry for the mesh.
  20945. * @returns the current mesh
  20946. */
  20947. makeGeometryUnique(): Mesh;
  20948. /**
  20949. * Set the index buffer of this mesh
  20950. * @param indices defines the source data
  20951. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  20952. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  20953. * @returns the current mesh
  20954. */
  20955. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20956. /**
  20957. * Update the current index buffer
  20958. * @param indices defines the source data
  20959. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  20960. * @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)
  20961. * @returns the current mesh
  20962. */
  20963. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  20964. /**
  20965. * Invert the geometry to move from a right handed system to a left handed one.
  20966. * @returns the current mesh
  20967. */
  20968. toLeftHanded(): Mesh;
  20969. /** @hidden */
  20970. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20971. /** @hidden */
  20972. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  20973. /**
  20974. * Registers for this mesh a javascript function called just before the rendering process
  20975. * @param func defines the function to call before rendering this mesh
  20976. * @returns the current mesh
  20977. */
  20978. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20979. /**
  20980. * Disposes a previously registered javascript function called before the rendering
  20981. * @param func defines the function to remove
  20982. * @returns the current mesh
  20983. */
  20984. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20985. /**
  20986. * Registers for this mesh a javascript function called just after the rendering is complete
  20987. * @param func defines the function to call after rendering this mesh
  20988. * @returns the current mesh
  20989. */
  20990. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20991. /**
  20992. * Disposes a previously registered javascript function called after the rendering.
  20993. * @param func defines the function to remove
  20994. * @returns the current mesh
  20995. */
  20996. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20997. /** @hidden */
  20998. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20999. /** @hidden */
  21000. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21001. /** @hidden */
  21002. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21003. /**
  21004. * 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
  21005. * @param subMesh defines the subMesh to render
  21006. * @param enableAlphaMode defines if alpha mode can be changed
  21007. * @returns the current mesh
  21008. */
  21009. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21010. private _onBeforeDraw;
  21011. /**
  21012. * Renormalize the mesh and patch it up if there are no weights
  21013. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21014. * However in the case of zero weights then we set just a single influence to 1.
  21015. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21016. */
  21017. cleanMatrixWeights(): void;
  21018. private normalizeSkinFourWeights;
  21019. private normalizeSkinWeightsAndExtra;
  21020. /**
  21021. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21022. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21023. * the user know there was an issue with importing the mesh
  21024. * @returns a validation object with skinned, valid and report string
  21025. */
  21026. validateSkinning(): {
  21027. skinned: boolean;
  21028. valid: boolean;
  21029. report: string;
  21030. };
  21031. /** @hidden */
  21032. _checkDelayState(): Mesh;
  21033. private _queueLoad;
  21034. /**
  21035. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21036. * A mesh is in the frustum if its bounding box intersects the frustum
  21037. * @param frustumPlanes defines the frustum to test
  21038. * @returns true if the mesh is in the frustum planes
  21039. */
  21040. isInFrustum(frustumPlanes: Plane[]): boolean;
  21041. /**
  21042. * Sets the mesh material by the material or multiMaterial `id` property
  21043. * @param id is a string identifying the material or the multiMaterial
  21044. * @returns the current mesh
  21045. */
  21046. setMaterialByID(id: string): Mesh;
  21047. /**
  21048. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21049. * @returns an array of IAnimatable
  21050. */
  21051. getAnimatables(): IAnimatable[];
  21052. /**
  21053. * Modifies the mesh geometry according to the passed transformation matrix.
  21054. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21055. * The mesh normals are modified using the same transformation.
  21056. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21057. * @param transform defines the transform matrix to use
  21058. * @see http://doc.babylonjs.com/resources/baking_transformations
  21059. * @returns the current mesh
  21060. */
  21061. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21062. /**
  21063. * Modifies the mesh geometry according to its own current World Matrix.
  21064. * The mesh World Matrix is then reset.
  21065. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21066. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21067. * @see http://doc.babylonjs.com/resources/baking_transformations
  21068. * @returns the current mesh
  21069. */
  21070. bakeCurrentTransformIntoVertices(): Mesh;
  21071. /** @hidden */
  21072. readonly _positions: Nullable<Vector3[]>;
  21073. /** @hidden */
  21074. _resetPointsArrayCache(): Mesh;
  21075. /** @hidden */
  21076. _generatePointsArray(): boolean;
  21077. /**
  21078. * Returns a new Mesh object generated from the current mesh properties.
  21079. * This method must not get confused with createInstance()
  21080. * @param name is a string, the name given to the new mesh
  21081. * @param newParent can be any Node object (default `null`)
  21082. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  21083. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21084. * @returns a new mesh
  21085. */
  21086. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21087. /**
  21088. * Releases resources associated with this mesh.
  21089. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21090. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21091. */
  21092. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21093. /**
  21094. * Modifies the mesh geometry according to a displacement map.
  21095. * 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.
  21096. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21097. * @param url is a string, the URL from the image file is to be downloaded.
  21098. * @param minHeight is the lower limit of the displacement.
  21099. * @param maxHeight is the upper limit of the displacement.
  21100. * @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.
  21101. * @param uvOffset is an optional vector2 used to offset UV.
  21102. * @param uvScale is an optional vector2 used to scale UV.
  21103. * @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.
  21104. * @returns the Mesh.
  21105. */
  21106. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21107. /**
  21108. * Modifies the mesh geometry according to a displacementMap buffer.
  21109. * 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.
  21110. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21111. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21112. * @param heightMapWidth is the width of the buffer image.
  21113. * @param heightMapHeight is the height of the buffer image.
  21114. * @param minHeight is the lower limit of the displacement.
  21115. * @param maxHeight is the upper limit of the displacement.
  21116. * @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.
  21117. * @param uvOffset is an optional vector2 used to offset UV.
  21118. * @param uvScale is an optional vector2 used to scale UV.
  21119. * @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.
  21120. * @returns the Mesh.
  21121. */
  21122. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21123. /**
  21124. * Modify the mesh to get a flat shading rendering.
  21125. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21126. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21127. * @returns current mesh
  21128. */
  21129. convertToFlatShadedMesh(): Mesh;
  21130. /**
  21131. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21132. * In other words, more vertices, no more indices and a single bigger VBO.
  21133. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21134. * @returns current mesh
  21135. */
  21136. convertToUnIndexedMesh(): Mesh;
  21137. /**
  21138. * Inverses facet orientations.
  21139. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21140. * @param flipNormals will also inverts the normals
  21141. * @returns current mesh
  21142. */
  21143. flipFaces(flipNormals?: boolean): Mesh;
  21144. /** @hidden */
  21145. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21146. /** @hidden */
  21147. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21148. /**
  21149. * Creates a new InstancedMesh object from the mesh model.
  21150. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21151. * @param name defines the name of the new instance
  21152. * @returns a new InstancedMesh
  21153. */
  21154. createInstance(name: string): InstancedMesh;
  21155. /**
  21156. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21157. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21158. * @returns the current mesh
  21159. */
  21160. synchronizeInstances(): Mesh;
  21161. /**
  21162. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21163. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21164. * This should be used together with the simplification to avoid disappearing triangles.
  21165. * @param successCallback an optional success callback to be called after the optimization finished.
  21166. * @returns the current mesh
  21167. */
  21168. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21169. /**
  21170. * Serialize current mesh
  21171. * @param serializationObject defines the object which will receive the serialization data
  21172. */
  21173. serialize(serializationObject: any): void;
  21174. /** @hidden */
  21175. _syncGeometryWithMorphTargetManager(): void;
  21176. /** @hidden */
  21177. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21178. /**
  21179. * Returns a new Mesh object parsed from the source provided.
  21180. * @param parsedMesh is the source
  21181. * @param scene defines the hosting scene
  21182. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21183. * @returns a new Mesh
  21184. */
  21185. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21186. /**
  21187. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21188. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21189. * @param name defines the name of the mesh to create
  21190. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21191. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21192. * @param closePath creates a seam between the first and the last points of each path of the path array
  21193. * @param offset is taken in account only if the `pathArray` is containing a single path
  21194. * @param scene defines the hosting scene
  21195. * @param updatable defines if the mesh must be flagged as updatable
  21196. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21197. * @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)
  21198. * @returns a new Mesh
  21199. */
  21200. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21201. /**
  21202. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21203. * @param name defines the name of the mesh to create
  21204. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21205. * @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
  21206. * @param scene defines the hosting scene
  21207. * @param updatable defines if the mesh must be flagged as updatable
  21208. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21209. * @returns a new Mesh
  21210. */
  21211. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21212. /**
  21213. * Creates a box 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 size sets the size (float) of each box side (default 1)
  21216. * @param scene defines the hosting scene
  21217. * @param updatable defines if the mesh must be flagged as updatable
  21218. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21219. * @returns a new Mesh
  21220. */
  21221. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21222. /**
  21223. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21224. * @param name defines the name of the mesh to create
  21225. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21226. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21227. * @param scene defines the hosting scene
  21228. * @param updatable defines if the mesh must be flagged as updatable
  21229. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21230. * @returns a new Mesh
  21231. */
  21232. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21233. /**
  21234. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21235. * @param name defines the name of the mesh to create
  21236. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21237. * @param diameterTop set the top cap diameter (floats, default 1)
  21238. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21239. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21240. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21241. * @param scene defines the hosting scene
  21242. * @param updatable defines if the mesh must be flagged as updatable
  21243. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21244. * @returns a new Mesh
  21245. */
  21246. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21247. /**
  21248. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21249. * @param name defines the name of the mesh to create
  21250. * @param diameter sets the diameter size (float) of the torus (default 1)
  21251. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21252. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21253. * @param scene defines the hosting scene
  21254. * @param updatable defines if the mesh must be flagged as updatable
  21255. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21256. * @returns a new Mesh
  21257. */
  21258. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21259. /**
  21260. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21261. * @param name defines the name of the mesh to create
  21262. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21263. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21264. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21265. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21266. * @param p the number of windings on X axis (positive integers, default 2)
  21267. * @param q the number of windings on Y axis (positive integers, default 3)
  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. * @returns a new Mesh
  21272. */
  21273. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21274. /**
  21275. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21276. * @param name defines the name of the mesh to create
  21277. * @param points is an array successive Vector3
  21278. * @param scene defines the hosting scene
  21279. * @param updatable defines if the mesh must be flagged as updatable
  21280. * @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).
  21281. * @returns a new Mesh
  21282. */
  21283. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21284. /**
  21285. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21286. * @param name defines the name of the mesh to create
  21287. * @param points is an array successive Vector3
  21288. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21289. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21290. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21291. * @param scene defines the hosting scene
  21292. * @param updatable defines if the mesh must be flagged as updatable
  21293. * @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)
  21294. * @returns a new Mesh
  21295. */
  21296. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21297. /**
  21298. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21299. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21300. * 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.
  21301. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21302. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21303. * Remember you can only change the shape positions, not their number when updating a polygon.
  21304. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21305. * @param name defines the name of the mesh to create
  21306. * @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
  21307. * @param scene defines the hosting scene
  21308. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21309. * @param updatable defines if the mesh must be flagged as updatable
  21310. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21311. * @param earcutInjection can be used to inject your own earcut reference
  21312. * @returns a new Mesh
  21313. */
  21314. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21315. /**
  21316. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21317. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21318. * @param name defines the name of the mesh to create
  21319. * @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
  21320. * @param depth defines the height of extrusion
  21321. * @param scene defines the hosting scene
  21322. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21323. * @param updatable defines if the mesh must be flagged as updatable
  21324. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21325. * @param earcutInjection can be used to inject your own earcut reference
  21326. * @returns a new Mesh
  21327. */
  21328. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21329. /**
  21330. * Creates an extruded shape mesh.
  21331. * 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
  21332. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21333. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21334. * @param name defines the name of the mesh to create
  21335. * @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
  21336. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21337. * @param scale is the value to scale the shape
  21338. * @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
  21339. * @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
  21340. * @param scene defines the hosting scene
  21341. * @param updatable defines if the mesh must be flagged as updatable
  21342. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21343. * @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)
  21344. * @returns a new Mesh
  21345. */
  21346. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21347. /**
  21348. * Creates an custom extruded shape mesh.
  21349. * The custom extrusion is a parametric shape.
  21350. * It has no predefined shape. Its final shape will depend on the input parameters.
  21351. * Please consider using the same method from the MeshBuilder class instead
  21352. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21353. * @param name defines the name of the mesh to create
  21354. * @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
  21355. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21356. * @param scaleFunction is a custom Javascript function called on each path point
  21357. * @param rotationFunction is a custom Javascript function called on each path point
  21358. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21359. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21360. * @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
  21361. * @param scene defines the hosting scene
  21362. * @param updatable defines if the mesh must be flagged as updatable
  21363. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21364. * @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)
  21365. * @returns a new Mesh
  21366. */
  21367. 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;
  21368. /**
  21369. * Creates lathe mesh.
  21370. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21371. * Please consider using the same method from the MeshBuilder class instead
  21372. * @param name defines the name of the mesh to create
  21373. * @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
  21374. * @param radius is the radius value of the lathe
  21375. * @param tessellation is the side number of the lathe.
  21376. * @param scene defines the hosting scene
  21377. * @param updatable defines if the mesh must be flagged as updatable
  21378. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21379. * @returns a new Mesh
  21380. */
  21381. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21382. /**
  21383. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21384. * @param name defines the name of the mesh to create
  21385. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21386. * @param scene defines the hosting scene
  21387. * @param updatable defines if the mesh must be flagged as updatable
  21388. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21389. * @returns a new Mesh
  21390. */
  21391. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21392. /**
  21393. * Creates a ground mesh.
  21394. * Please consider using the same method from the MeshBuilder class instead
  21395. * @param name defines the name of the mesh to create
  21396. * @param width set the width of the ground
  21397. * @param height set the height of the ground
  21398. * @param subdivisions sets the number of subdivisions per side
  21399. * @param scene defines the hosting scene
  21400. * @param updatable defines if the mesh must be flagged as updatable
  21401. * @returns a new Mesh
  21402. */
  21403. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21404. /**
  21405. * Creates a tiled ground mesh.
  21406. * Please consider using the same method from the MeshBuilder class instead
  21407. * @param name defines the name of the mesh to create
  21408. * @param xmin set the ground minimum X coordinate
  21409. * @param zmin set the ground minimum Y coordinate
  21410. * @param xmax set the ground maximum X coordinate
  21411. * @param zmax set the ground maximum Z coordinate
  21412. * @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
  21413. * @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
  21414. * @param scene defines the hosting scene
  21415. * @param updatable defines if the mesh must be flagged as updatable
  21416. * @returns a new Mesh
  21417. */
  21418. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21419. w: number;
  21420. h: number;
  21421. }, precision: {
  21422. w: number;
  21423. h: number;
  21424. }, scene: Scene, updatable?: boolean): Mesh;
  21425. /**
  21426. * Creates a ground mesh from a height map.
  21427. * Please consider using the same method from the MeshBuilder class instead
  21428. * @see http://doc.babylonjs.com/babylon101/height_map
  21429. * @param name defines the name of the mesh to create
  21430. * @param url sets the URL of the height map image resource
  21431. * @param width set the ground width size
  21432. * @param height set the ground height size
  21433. * @param subdivisions sets the number of subdivision per side
  21434. * @param minHeight is the minimum altitude on the ground
  21435. * @param maxHeight is the maximum altitude on the ground
  21436. * @param scene defines the hosting scene
  21437. * @param updatable defines if the mesh must be flagged as updatable
  21438. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21439. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21440. * @returns a new Mesh
  21441. */
  21442. 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;
  21443. /**
  21444. * Creates a tube mesh.
  21445. * The tube is a parametric shape.
  21446. * It has no predefined shape. Its final shape will depend on the input parameters.
  21447. * Please consider using the same method from the MeshBuilder class instead
  21448. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21449. * @param name defines the name of the mesh to create
  21450. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21451. * @param radius sets the tube radius size
  21452. * @param tessellation is the number of sides on the tubular surface
  21453. * @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
  21454. * @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
  21455. * @param scene defines the hosting scene
  21456. * @param updatable defines if the mesh must be flagged as updatable
  21457. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21458. * @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)
  21459. * @returns a new Mesh
  21460. */
  21461. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21462. (i: number, distance: number): number;
  21463. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21464. /**
  21465. * Creates a polyhedron mesh.
  21466. * Please consider using the same method from the MeshBuilder class instead.
  21467. * * 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
  21468. * * The parameter `size` (positive float, default 1) sets the polygon size
  21469. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21470. * * 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`
  21471. * * 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
  21472. * * 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)`)
  21473. * * 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
  21474. * * 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
  21475. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21476. * * If you create a double-sided mesh, you can choose what parts of 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
  21477. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21478. * @param name defines the name of the mesh to create
  21479. * @param options defines the options used to create the mesh
  21480. * @param scene defines the hosting scene
  21481. * @returns a new Mesh
  21482. */
  21483. static CreatePolyhedron(name: string, options: {
  21484. type?: number;
  21485. size?: number;
  21486. sizeX?: number;
  21487. sizeY?: number;
  21488. sizeZ?: number;
  21489. custom?: any;
  21490. faceUV?: Vector4[];
  21491. faceColors?: Color4[];
  21492. updatable?: boolean;
  21493. sideOrientation?: number;
  21494. }, scene: Scene): Mesh;
  21495. /**
  21496. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21497. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21498. * * 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`)
  21499. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21500. * * 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
  21501. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21502. * * If you create a double-sided mesh, you can choose what parts of 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
  21503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21504. * @param name defines the name of the mesh
  21505. * @param options defines the options used to create the mesh
  21506. * @param scene defines the hosting scene
  21507. * @returns a new Mesh
  21508. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21509. */
  21510. static CreateIcoSphere(name: string, options: {
  21511. radius?: number;
  21512. flat?: boolean;
  21513. subdivisions?: number;
  21514. sideOrientation?: number;
  21515. updatable?: boolean;
  21516. }, scene: Scene): Mesh;
  21517. /**
  21518. * Creates a decal mesh.
  21519. * Please consider using the same method from the MeshBuilder class instead.
  21520. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21521. * @param name defines the name of the mesh
  21522. * @param sourceMesh defines the mesh receiving the decal
  21523. * @param position sets the position of the decal in world coordinates
  21524. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21525. * @param size sets the decal scaling
  21526. * @param angle sets the angle to rotate the decal
  21527. * @returns a new Mesh
  21528. */
  21529. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21530. /**
  21531. * Prepare internal position array for software CPU skinning
  21532. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21533. */
  21534. setPositionsForCPUSkinning(): Float32Array;
  21535. /**
  21536. * Prepare internal normal array for software CPU skinning
  21537. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21538. */
  21539. setNormalsForCPUSkinning(): Float32Array;
  21540. /**
  21541. * Updates the vertex buffer by applying transformation from the bones
  21542. * @param skeleton defines the skeleton to apply to current mesh
  21543. * @returns the current mesh
  21544. */
  21545. applySkeleton(skeleton: Skeleton): Mesh;
  21546. /**
  21547. * 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
  21548. * @param meshes defines the list of meshes to scan
  21549. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21550. */
  21551. static MinMax(meshes: AbstractMesh[]): {
  21552. min: Vector3;
  21553. max: Vector3;
  21554. };
  21555. /**
  21556. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21557. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21558. * @returns a vector3
  21559. */
  21560. static Center(meshesOrMinMaxVector: {
  21561. min: Vector3;
  21562. max: Vector3;
  21563. } | AbstractMesh[]): Vector3;
  21564. /**
  21565. * Merge the array of meshes into a single mesh for performance reasons.
  21566. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21567. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21568. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21569. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21570. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21571. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21572. * @returns a new mesh
  21573. */
  21574. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21575. /** @hidden */
  21576. addInstance(instance: InstancedMesh): void;
  21577. /** @hidden */
  21578. removeInstance(instance: InstancedMesh): void;
  21579. }
  21580. }
  21581. declare module "babylonjs/Materials/material" {
  21582. import { IAnimatable } from "babylonjs/Misc/tools";
  21583. import { SmartArray } from "babylonjs/Misc/smartArray";
  21584. import { Observable } from "babylonjs/Misc/observable";
  21585. import { Nullable } from "babylonjs/types";
  21586. import { Scene } from "babylonjs/scene";
  21587. import { Matrix } from "babylonjs/Maths/math";
  21588. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21589. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21590. import { Mesh } from "babylonjs/Meshes/mesh";
  21591. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21592. import { Effect } from "babylonjs/Materials/effect";
  21593. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21594. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21595. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21596. import { Animation } from "babylonjs/Animations/animation";
  21597. /**
  21598. * Base class for the main features of a material in Babylon.js
  21599. */
  21600. export class Material implements IAnimatable {
  21601. /**
  21602. * Returns the triangle fill mode
  21603. */
  21604. static readonly TriangleFillMode: number;
  21605. /**
  21606. * Returns the wireframe mode
  21607. */
  21608. static readonly WireFrameFillMode: number;
  21609. /**
  21610. * Returns the point fill mode
  21611. */
  21612. static readonly PointFillMode: number;
  21613. /**
  21614. * Returns the point list draw mode
  21615. */
  21616. static readonly PointListDrawMode: number;
  21617. /**
  21618. * Returns the line list draw mode
  21619. */
  21620. static readonly LineListDrawMode: number;
  21621. /**
  21622. * Returns the line loop draw mode
  21623. */
  21624. static readonly LineLoopDrawMode: number;
  21625. /**
  21626. * Returns the line strip draw mode
  21627. */
  21628. static readonly LineStripDrawMode: number;
  21629. /**
  21630. * Returns the triangle strip draw mode
  21631. */
  21632. static readonly TriangleStripDrawMode: number;
  21633. /**
  21634. * Returns the triangle fan draw mode
  21635. */
  21636. static readonly TriangleFanDrawMode: number;
  21637. /**
  21638. * Stores the clock-wise side orientation
  21639. */
  21640. static readonly ClockWiseSideOrientation: number;
  21641. /**
  21642. * Stores the counter clock-wise side orientation
  21643. */
  21644. static readonly CounterClockWiseSideOrientation: number;
  21645. /**
  21646. * The dirty texture flag value
  21647. */
  21648. static readonly TextureDirtyFlag: number;
  21649. /**
  21650. * The dirty light flag value
  21651. */
  21652. static readonly LightDirtyFlag: number;
  21653. /**
  21654. * The dirty fresnel flag value
  21655. */
  21656. static readonly FresnelDirtyFlag: number;
  21657. /**
  21658. * The dirty attribute flag value
  21659. */
  21660. static readonly AttributesDirtyFlag: number;
  21661. /**
  21662. * The dirty misc flag value
  21663. */
  21664. static readonly MiscDirtyFlag: number;
  21665. /**
  21666. * The all dirty flag value
  21667. */
  21668. static readonly AllDirtyFlag: number;
  21669. /**
  21670. * The ID of the material
  21671. */
  21672. id: string;
  21673. /**
  21674. * Gets or sets the unique id of the material
  21675. */
  21676. uniqueId: number;
  21677. /**
  21678. * The name of the material
  21679. */
  21680. name: string;
  21681. /**
  21682. * Gets or sets user defined metadata
  21683. */
  21684. metadata: any;
  21685. /**
  21686. * For internal use only. Please do not use.
  21687. */
  21688. reservedDataStore: any;
  21689. /**
  21690. * Specifies if the ready state should be checked on each call
  21691. */
  21692. checkReadyOnEveryCall: boolean;
  21693. /**
  21694. * Specifies if the ready state should be checked once
  21695. */
  21696. checkReadyOnlyOnce: boolean;
  21697. /**
  21698. * The state of the material
  21699. */
  21700. state: string;
  21701. /**
  21702. * The alpha value of the material
  21703. */
  21704. protected _alpha: number;
  21705. /**
  21706. * Sets the alpha value of the material
  21707. */
  21708. /**
  21709. * Gets the alpha value of the material
  21710. */
  21711. alpha: number;
  21712. /**
  21713. * Specifies if back face culling is enabled
  21714. */
  21715. protected _backFaceCulling: boolean;
  21716. /**
  21717. * Sets the back-face culling state
  21718. */
  21719. /**
  21720. * Gets the back-face culling state
  21721. */
  21722. backFaceCulling: boolean;
  21723. /**
  21724. * Stores the value for side orientation
  21725. */
  21726. sideOrientation: number;
  21727. /**
  21728. * Callback triggered when the material is compiled
  21729. */
  21730. onCompiled: (effect: Effect) => void;
  21731. /**
  21732. * Callback triggered when an error occurs
  21733. */
  21734. onError: (effect: Effect, errors: string) => void;
  21735. /**
  21736. * Callback triggered to get the render target textures
  21737. */
  21738. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  21739. /**
  21740. * Gets a boolean indicating that current material needs to register RTT
  21741. */
  21742. readonly hasRenderTargetTextures: boolean;
  21743. /**
  21744. * Specifies if the material should be serialized
  21745. */
  21746. doNotSerialize: boolean;
  21747. /**
  21748. * @hidden
  21749. */
  21750. _storeEffectOnSubMeshes: boolean;
  21751. /**
  21752. * Stores the animations for the material
  21753. */
  21754. animations: Array<Animation>;
  21755. /**
  21756. * An event triggered when the material is disposed
  21757. */
  21758. onDisposeObservable: Observable<Material>;
  21759. /**
  21760. * An observer which watches for dispose events
  21761. */
  21762. private _onDisposeObserver;
  21763. private _onUnBindObservable;
  21764. /**
  21765. * Called during a dispose event
  21766. */
  21767. onDispose: () => void;
  21768. private _onBindObservable;
  21769. /**
  21770. * An event triggered when the material is bound
  21771. */
  21772. readonly onBindObservable: Observable<AbstractMesh>;
  21773. /**
  21774. * An observer which watches for bind events
  21775. */
  21776. private _onBindObserver;
  21777. /**
  21778. * Called during a bind event
  21779. */
  21780. onBind: (Mesh: AbstractMesh) => void;
  21781. /**
  21782. * An event triggered when the material is unbound
  21783. */
  21784. readonly onUnBindObservable: Observable<Material>;
  21785. /**
  21786. * Stores the value of the alpha mode
  21787. */
  21788. private _alphaMode;
  21789. /**
  21790. * Sets the value of the alpha mode.
  21791. *
  21792. * | Value | Type | Description |
  21793. * | --- | --- | --- |
  21794. * | 0 | ALPHA_DISABLE | |
  21795. * | 1 | ALPHA_ADD | |
  21796. * | 2 | ALPHA_COMBINE | |
  21797. * | 3 | ALPHA_SUBTRACT | |
  21798. * | 4 | ALPHA_MULTIPLY | |
  21799. * | 5 | ALPHA_MAXIMIZED | |
  21800. * | 6 | ALPHA_ONEONE | |
  21801. * | 7 | ALPHA_PREMULTIPLIED | |
  21802. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21803. * | 9 | ALPHA_INTERPOLATE | |
  21804. * | 10 | ALPHA_SCREENMODE | |
  21805. *
  21806. */
  21807. /**
  21808. * Gets the value of the alpha mode
  21809. */
  21810. alphaMode: number;
  21811. /**
  21812. * Stores the state of the need depth pre-pass value
  21813. */
  21814. private _needDepthPrePass;
  21815. /**
  21816. * Sets the need depth pre-pass value
  21817. */
  21818. /**
  21819. * Gets the depth pre-pass value
  21820. */
  21821. needDepthPrePass: boolean;
  21822. /**
  21823. * Specifies if depth writing should be disabled
  21824. */
  21825. disableDepthWrite: boolean;
  21826. /**
  21827. * Specifies if depth writing should be forced
  21828. */
  21829. forceDepthWrite: boolean;
  21830. /**
  21831. * Specifies if there should be a separate pass for culling
  21832. */
  21833. separateCullingPass: boolean;
  21834. /**
  21835. * Stores the state specifing if fog should be enabled
  21836. */
  21837. private _fogEnabled;
  21838. /**
  21839. * Sets the state for enabling fog
  21840. */
  21841. /**
  21842. * Gets the value of the fog enabled state
  21843. */
  21844. fogEnabled: boolean;
  21845. /**
  21846. * Stores the size of points
  21847. */
  21848. pointSize: number;
  21849. /**
  21850. * Stores the z offset value
  21851. */
  21852. zOffset: number;
  21853. /**
  21854. * Gets a value specifying if wireframe mode is enabled
  21855. */
  21856. /**
  21857. * Sets the state of wireframe mode
  21858. */
  21859. wireframe: boolean;
  21860. /**
  21861. * Gets the value specifying if point clouds are enabled
  21862. */
  21863. /**
  21864. * Sets the state of point cloud mode
  21865. */
  21866. pointsCloud: boolean;
  21867. /**
  21868. * Gets the material fill mode
  21869. */
  21870. /**
  21871. * Sets the material fill mode
  21872. */
  21873. fillMode: number;
  21874. /**
  21875. * @hidden
  21876. * Stores the effects for the material
  21877. */
  21878. _effect: Nullable<Effect>;
  21879. /**
  21880. * @hidden
  21881. * Specifies if the material was previously ready
  21882. */
  21883. _wasPreviouslyReady: boolean;
  21884. /**
  21885. * Specifies if uniform buffers should be used
  21886. */
  21887. private _useUBO;
  21888. /**
  21889. * Stores a reference to the scene
  21890. */
  21891. private _scene;
  21892. /**
  21893. * Stores the fill mode state
  21894. */
  21895. private _fillMode;
  21896. /**
  21897. * Specifies if the depth write state should be cached
  21898. */
  21899. private _cachedDepthWriteState;
  21900. /**
  21901. * Stores the uniform buffer
  21902. */
  21903. protected _uniformBuffer: UniformBuffer;
  21904. /** @hidden */
  21905. _indexInSceneMaterialArray: number;
  21906. /** @hidden */
  21907. meshMap: Nullable<{
  21908. [id: string]: AbstractMesh | undefined;
  21909. }>;
  21910. /**
  21911. * Creates a material instance
  21912. * @param name defines the name of the material
  21913. * @param scene defines the scene to reference
  21914. * @param doNotAdd specifies if the material should be added to the scene
  21915. */
  21916. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21917. /**
  21918. * Returns a string representation of the current material
  21919. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21920. * @returns a string with material information
  21921. */
  21922. toString(fullDetails?: boolean): string;
  21923. /**
  21924. * Gets the class name of the material
  21925. * @returns a string with the class name of the material
  21926. */
  21927. getClassName(): string;
  21928. /**
  21929. * Specifies if updates for the material been locked
  21930. */
  21931. readonly isFrozen: boolean;
  21932. /**
  21933. * Locks updates for the material
  21934. */
  21935. freeze(): void;
  21936. /**
  21937. * Unlocks updates for the material
  21938. */
  21939. unfreeze(): void;
  21940. /**
  21941. * Specifies if the material is ready to be used
  21942. * @param mesh defines the mesh to check
  21943. * @param useInstances specifies if instances should be used
  21944. * @returns a boolean indicating if the material is ready to be used
  21945. */
  21946. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21947. /**
  21948. * Specifies that the submesh is ready to be used
  21949. * @param mesh defines the mesh to check
  21950. * @param subMesh defines which submesh to check
  21951. * @param useInstances specifies that instances should be used
  21952. * @returns a boolean indicating that the submesh is ready or not
  21953. */
  21954. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21955. /**
  21956. * Returns the material effect
  21957. * @returns the effect associated with the material
  21958. */
  21959. getEffect(): Nullable<Effect>;
  21960. /**
  21961. * Returns the current scene
  21962. * @returns a Scene
  21963. */
  21964. getScene(): Scene;
  21965. /**
  21966. * Specifies if the material will require alpha blending
  21967. * @returns a boolean specifying if alpha blending is needed
  21968. */
  21969. needAlphaBlending(): boolean;
  21970. /**
  21971. * Specifies if the mesh will require alpha blending
  21972. * @param mesh defines the mesh to check
  21973. * @returns a boolean specifying if alpha blending is needed for the mesh
  21974. */
  21975. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21976. /**
  21977. * Specifies if this material should be rendered in alpha test mode
  21978. * @returns a boolean specifying if an alpha test is needed.
  21979. */
  21980. needAlphaTesting(): boolean;
  21981. /**
  21982. * Gets the texture used for the alpha test
  21983. * @returns the texture to use for alpha testing
  21984. */
  21985. getAlphaTestTexture(): Nullable<BaseTexture>;
  21986. /**
  21987. * Marks the material to indicate that it needs to be re-calculated
  21988. */
  21989. markDirty(): void;
  21990. /** @hidden */
  21991. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21992. /**
  21993. * Binds the material to the mesh
  21994. * @param world defines the world transformation matrix
  21995. * @param mesh defines the mesh to bind the material to
  21996. */
  21997. bind(world: Matrix, mesh?: Mesh): void;
  21998. /**
  21999. * Binds the submesh to the material
  22000. * @param world defines the world transformation matrix
  22001. * @param mesh defines the mesh containing the submesh
  22002. * @param subMesh defines the submesh to bind the material to
  22003. */
  22004. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22005. /**
  22006. * Binds the world matrix to the material
  22007. * @param world defines the world transformation matrix
  22008. */
  22009. bindOnlyWorldMatrix(world: Matrix): void;
  22010. /**
  22011. * Binds the scene's uniform buffer to the effect.
  22012. * @param effect defines the effect to bind to the scene uniform buffer
  22013. * @param sceneUbo defines the uniform buffer storing scene data
  22014. */
  22015. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22016. /**
  22017. * Binds the view matrix to the effect
  22018. * @param effect defines the effect to bind the view matrix to
  22019. */
  22020. bindView(effect: Effect): void;
  22021. /**
  22022. * Binds the view projection matrix to the effect
  22023. * @param effect defines the effect to bind the view projection matrix to
  22024. */
  22025. bindViewProjection(effect: Effect): void;
  22026. /**
  22027. * Specifies if material alpha testing should be turned on for the mesh
  22028. * @param mesh defines the mesh to check
  22029. */
  22030. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22031. /**
  22032. * Processes to execute after binding the material to a mesh
  22033. * @param mesh defines the rendered mesh
  22034. */
  22035. protected _afterBind(mesh?: Mesh): void;
  22036. /**
  22037. * Unbinds the material from the mesh
  22038. */
  22039. unbind(): void;
  22040. /**
  22041. * Gets the active textures from the material
  22042. * @returns an array of textures
  22043. */
  22044. getActiveTextures(): BaseTexture[];
  22045. /**
  22046. * Specifies if the material uses a texture
  22047. * @param texture defines the texture to check against the material
  22048. * @returns a boolean specifying if the material uses the texture
  22049. */
  22050. hasTexture(texture: BaseTexture): boolean;
  22051. /**
  22052. * Makes a duplicate of the material, and gives it a new name
  22053. * @param name defines the new name for the duplicated material
  22054. * @returns the cloned material
  22055. */
  22056. clone(name: string): Nullable<Material>;
  22057. /**
  22058. * Gets the meshes bound to the material
  22059. * @returns an array of meshes bound to the material
  22060. */
  22061. getBindedMeshes(): AbstractMesh[];
  22062. /**
  22063. * Force shader compilation
  22064. * @param mesh defines the mesh associated with this material
  22065. * @param onCompiled defines a function to execute once the material is compiled
  22066. * @param options defines the options to configure the compilation
  22067. */
  22068. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22069. clipPlane: boolean;
  22070. }>): void;
  22071. /**
  22072. * Force shader compilation
  22073. * @param mesh defines the mesh that will use this material
  22074. * @param options defines additional options for compiling the shaders
  22075. * @returns a promise that resolves when the compilation completes
  22076. */
  22077. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22078. clipPlane: boolean;
  22079. }>): Promise<void>;
  22080. private static readonly _ImageProcessingDirtyCallBack;
  22081. private static readonly _TextureDirtyCallBack;
  22082. private static readonly _FresnelDirtyCallBack;
  22083. private static readonly _MiscDirtyCallBack;
  22084. private static readonly _LightsDirtyCallBack;
  22085. private static readonly _AttributeDirtyCallBack;
  22086. private static _FresnelAndMiscDirtyCallBack;
  22087. private static _TextureAndMiscDirtyCallBack;
  22088. private static readonly _DirtyCallbackArray;
  22089. private static readonly _RunDirtyCallBacks;
  22090. /**
  22091. * Marks a define in the material to indicate that it needs to be re-computed
  22092. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22093. */
  22094. markAsDirty(flag: number): void;
  22095. /**
  22096. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22097. * @param func defines a function which checks material defines against the submeshes
  22098. */
  22099. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22100. /**
  22101. * Indicates that image processing needs to be re-calculated for all submeshes
  22102. */
  22103. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22104. /**
  22105. * Indicates that textures need to be re-calculated for all submeshes
  22106. */
  22107. protected _markAllSubMeshesAsTexturesDirty(): void;
  22108. /**
  22109. * Indicates that fresnel needs to be re-calculated for all submeshes
  22110. */
  22111. protected _markAllSubMeshesAsFresnelDirty(): void;
  22112. /**
  22113. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22114. */
  22115. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22116. /**
  22117. * Indicates that lights need to be re-calculated for all submeshes
  22118. */
  22119. protected _markAllSubMeshesAsLightsDirty(): void;
  22120. /**
  22121. * Indicates that attributes need to be re-calculated for all submeshes
  22122. */
  22123. protected _markAllSubMeshesAsAttributesDirty(): void;
  22124. /**
  22125. * Indicates that misc needs to be re-calculated for all submeshes
  22126. */
  22127. protected _markAllSubMeshesAsMiscDirty(): void;
  22128. /**
  22129. * Indicates that textures and misc need to be re-calculated for all submeshes
  22130. */
  22131. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22132. /**
  22133. * Disposes the material
  22134. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22135. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22136. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22137. */
  22138. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22139. /** @hidden */
  22140. private releaseVertexArrayObject;
  22141. /**
  22142. * Serializes this material
  22143. * @returns the serialized material object
  22144. */
  22145. serialize(): any;
  22146. /**
  22147. * Creates a material from parsed material data
  22148. * @param parsedMaterial defines parsed material data
  22149. * @param scene defines the hosting scene
  22150. * @param rootUrl defines the root URL to use to load textures
  22151. * @returns a new material
  22152. */
  22153. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  22154. }
  22155. }
  22156. declare module "babylonjs/Meshes/subMesh" {
  22157. import { Nullable, IndicesArray, DeepImmutable } from "babylonjs/types";
  22158. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  22159. import { Engine } from "babylonjs/Engines/engine";
  22160. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22161. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22162. import { Effect } from "babylonjs/Materials/effect";
  22163. import { Collider } from "babylonjs/Collisions/collider";
  22164. import { Material } from "babylonjs/Materials/material";
  22165. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22166. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22167. import { Mesh } from "babylonjs/Meshes/mesh";
  22168. import { Ray } from "babylonjs/Culling/ray";
  22169. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22170. /**
  22171. * Base class for submeshes
  22172. */
  22173. export class BaseSubMesh {
  22174. /** @hidden */
  22175. _materialDefines: Nullable<MaterialDefines>;
  22176. /** @hidden */
  22177. _materialEffect: Nullable<Effect>;
  22178. /**
  22179. * Gets associated effect
  22180. */
  22181. readonly effect: Nullable<Effect>;
  22182. /**
  22183. * Sets associated effect (effect used to render this submesh)
  22184. * @param effect defines the effect to associate with
  22185. * @param defines defines the set of defines used to compile this effect
  22186. */
  22187. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22188. }
  22189. /**
  22190. * Defines a subdivision inside a mesh
  22191. */
  22192. export class SubMesh extends BaseSubMesh implements ICullable {
  22193. /** the material index to use */
  22194. materialIndex: number;
  22195. /** vertex index start */
  22196. verticesStart: number;
  22197. /** vertices count */
  22198. verticesCount: number;
  22199. /** index start */
  22200. indexStart: number;
  22201. /** indices count */
  22202. indexCount: number;
  22203. /** @hidden */
  22204. _linesIndexCount: number;
  22205. private _mesh;
  22206. private _renderingMesh;
  22207. private _boundingInfo;
  22208. private _linesIndexBuffer;
  22209. /** @hidden */
  22210. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22211. /** @hidden */
  22212. _trianglePlanes: Plane[];
  22213. /** @hidden */
  22214. _lastColliderTransformMatrix: Matrix;
  22215. /** @hidden */
  22216. _renderId: number;
  22217. /** @hidden */
  22218. _alphaIndex: number;
  22219. /** @hidden */
  22220. _distanceToCamera: number;
  22221. /** @hidden */
  22222. _id: number;
  22223. private _currentMaterial;
  22224. /**
  22225. * Add a new submesh to a mesh
  22226. * @param materialIndex defines the material index to use
  22227. * @param verticesStart defines vertex index start
  22228. * @param verticesCount defines vertices count
  22229. * @param indexStart defines index start
  22230. * @param indexCount defines indices count
  22231. * @param mesh defines the parent mesh
  22232. * @param renderingMesh defines an optional rendering mesh
  22233. * @param createBoundingBox defines if bounding box should be created for this submesh
  22234. * @returns the new submesh
  22235. */
  22236. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22237. /**
  22238. * Creates a new submesh
  22239. * @param materialIndex defines the material index to use
  22240. * @param verticesStart defines vertex index start
  22241. * @param verticesCount defines vertices count
  22242. * @param indexStart defines index start
  22243. * @param indexCount defines indices count
  22244. * @param mesh defines the parent mesh
  22245. * @param renderingMesh defines an optional rendering mesh
  22246. * @param createBoundingBox defines if bounding box should be created for this submesh
  22247. */
  22248. constructor(
  22249. /** the material index to use */
  22250. materialIndex: number,
  22251. /** vertex index start */
  22252. verticesStart: number,
  22253. /** vertices count */
  22254. verticesCount: number,
  22255. /** index start */
  22256. indexStart: number,
  22257. /** indices count */
  22258. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22259. /**
  22260. * Returns true if this submesh covers the entire parent mesh
  22261. * @ignorenaming
  22262. */
  22263. readonly IsGlobal: boolean;
  22264. /**
  22265. * Returns the submesh BoudingInfo object
  22266. * @returns current bounding info (or mesh's one if the submesh is global)
  22267. */
  22268. getBoundingInfo(): BoundingInfo;
  22269. /**
  22270. * Sets the submesh BoundingInfo
  22271. * @param boundingInfo defines the new bounding info to use
  22272. * @returns the SubMesh
  22273. */
  22274. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22275. /**
  22276. * Returns the mesh of the current submesh
  22277. * @return the parent mesh
  22278. */
  22279. getMesh(): AbstractMesh;
  22280. /**
  22281. * Returns the rendering mesh of the submesh
  22282. * @returns the rendering mesh (could be different from parent mesh)
  22283. */
  22284. getRenderingMesh(): Mesh;
  22285. /**
  22286. * Returns the submesh material
  22287. * @returns null or the current material
  22288. */
  22289. getMaterial(): Nullable<Material>;
  22290. /**
  22291. * Sets a new updated BoundingInfo object to the submesh
  22292. * @returns the SubMesh
  22293. */
  22294. refreshBoundingInfo(): SubMesh;
  22295. /** @hidden */
  22296. _checkCollision(collider: Collider): boolean;
  22297. /**
  22298. * Updates the submesh BoundingInfo
  22299. * @param world defines the world matrix to use to update the bounding info
  22300. * @returns the submesh
  22301. */
  22302. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22303. /**
  22304. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22305. * @param frustumPlanes defines the frustum planes
  22306. * @returns true if the submesh is intersecting with the frustum
  22307. */
  22308. isInFrustum(frustumPlanes: Plane[]): boolean;
  22309. /**
  22310. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22311. * @param frustumPlanes defines the frustum planes
  22312. * @returns true if the submesh is inside the frustum
  22313. */
  22314. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22315. /**
  22316. * Renders the submesh
  22317. * @param enableAlphaMode defines if alpha needs to be used
  22318. * @returns the submesh
  22319. */
  22320. render(enableAlphaMode: boolean): SubMesh;
  22321. /**
  22322. * @hidden
  22323. */
  22324. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22325. /**
  22326. * Checks if the submesh intersects with a ray
  22327. * @param ray defines the ray to test
  22328. * @returns true is the passed ray intersects the submesh bounding box
  22329. */
  22330. canIntersects(ray: Ray): boolean;
  22331. /**
  22332. * Intersects current submesh with a ray
  22333. * @param ray defines the ray to test
  22334. * @param positions defines mesh's positions array
  22335. * @param indices defines mesh's indices array
  22336. * @param fastCheck defines if only bounding info should be used
  22337. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22338. * @returns intersection info or null if no intersection
  22339. */
  22340. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22341. /** @hidden */
  22342. private _intersectLines;
  22343. /** @hidden */
  22344. private _intersectTriangles;
  22345. /** @hidden */
  22346. _rebuild(): void;
  22347. /**
  22348. * Creates a new submesh from the passed mesh
  22349. * @param newMesh defines the new hosting mesh
  22350. * @param newRenderingMesh defines an optional rendering mesh
  22351. * @returns the new submesh
  22352. */
  22353. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22354. /**
  22355. * Release associated resources
  22356. */
  22357. dispose(): void;
  22358. /**
  22359. * Gets the class name
  22360. * @returns the string "SubMesh".
  22361. */
  22362. getClassName(): string;
  22363. /**
  22364. * Creates a new submesh from indices data
  22365. * @param materialIndex the index of the main mesh material
  22366. * @param startIndex the index where to start the copy in the mesh indices array
  22367. * @param indexCount the number of indices to copy then from the startIndex
  22368. * @param mesh the main mesh to create the submesh from
  22369. * @param renderingMesh the optional rendering mesh
  22370. * @returns a new submesh
  22371. */
  22372. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22373. }
  22374. }
  22375. declare module "babylonjs/Meshes/geometry" {
  22376. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22377. import { Scene } from "babylonjs/scene";
  22378. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  22379. import { Engine } from "babylonjs/Engines/engine";
  22380. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22381. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22382. import { Effect } from "babylonjs/Materials/effect";
  22383. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22384. import { Mesh } from "babylonjs/Meshes/mesh";
  22385. /**
  22386. * Class used to store geometry data (vertex buffers + index buffer)
  22387. */
  22388. export class Geometry implements IGetSetVerticesData {
  22389. /**
  22390. * Gets or sets the ID of the geometry
  22391. */
  22392. id: string;
  22393. /**
  22394. * Gets or sets the unique ID of the geometry
  22395. */
  22396. uniqueId: number;
  22397. /**
  22398. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22399. */
  22400. delayLoadState: number;
  22401. /**
  22402. * Gets the file containing the data to load when running in delay load state
  22403. */
  22404. delayLoadingFile: Nullable<string>;
  22405. /**
  22406. * Callback called when the geometry is updated
  22407. */
  22408. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22409. private _scene;
  22410. private _engine;
  22411. private _meshes;
  22412. private _totalVertices;
  22413. /** @hidden */
  22414. _indices: IndicesArray;
  22415. /** @hidden */
  22416. _vertexBuffers: {
  22417. [key: string]: VertexBuffer;
  22418. };
  22419. private _isDisposed;
  22420. private _extend;
  22421. private _boundingBias;
  22422. /** @hidden */
  22423. _delayInfo: Array<string>;
  22424. private _indexBuffer;
  22425. private _indexBufferIsUpdatable;
  22426. /** @hidden */
  22427. _boundingInfo: Nullable<BoundingInfo>;
  22428. /** @hidden */
  22429. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22430. /** @hidden */
  22431. _softwareSkinningFrameId: number;
  22432. private _vertexArrayObjects;
  22433. private _updatable;
  22434. /** @hidden */
  22435. _positions: Nullable<Vector3[]>;
  22436. /**
  22437. * 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
  22438. */
  22439. /**
  22440. * 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
  22441. */
  22442. boundingBias: Vector2;
  22443. /**
  22444. * Static function used to attach a new empty geometry to a mesh
  22445. * @param mesh defines the mesh to attach the geometry to
  22446. * @returns the new Geometry
  22447. */
  22448. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22449. /**
  22450. * Creates a new geometry
  22451. * @param id defines the unique ID
  22452. * @param scene defines the hosting scene
  22453. * @param vertexData defines the VertexData used to get geometry data
  22454. * @param updatable defines if geometry must be updatable (false by default)
  22455. * @param mesh defines the mesh that will be associated with the geometry
  22456. */
  22457. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22458. /**
  22459. * Gets the current extend of the geometry
  22460. */
  22461. readonly extend: {
  22462. minimum: Vector3;
  22463. maximum: Vector3;
  22464. };
  22465. /**
  22466. * Gets the hosting scene
  22467. * @returns the hosting Scene
  22468. */
  22469. getScene(): Scene;
  22470. /**
  22471. * Gets the hosting engine
  22472. * @returns the hosting Engine
  22473. */
  22474. getEngine(): Engine;
  22475. /**
  22476. * Defines if the geometry is ready to use
  22477. * @returns true if the geometry is ready to be used
  22478. */
  22479. isReady(): boolean;
  22480. /**
  22481. * Gets a value indicating that the geometry should not be serialized
  22482. */
  22483. readonly doNotSerialize: boolean;
  22484. /** @hidden */
  22485. _rebuild(): void;
  22486. /**
  22487. * Affects all geometry data in one call
  22488. * @param vertexData defines the geometry data
  22489. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22490. */
  22491. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22492. /**
  22493. * Set specific vertex data
  22494. * @param kind defines the data kind (Position, normal, etc...)
  22495. * @param data defines the vertex data to use
  22496. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22497. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22498. */
  22499. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22500. /**
  22501. * Removes a specific vertex data
  22502. * @param kind defines the data kind (Position, normal, etc...)
  22503. */
  22504. removeVerticesData(kind: string): void;
  22505. /**
  22506. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22507. * @param buffer defines the vertex buffer to use
  22508. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22509. */
  22510. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22511. /**
  22512. * Update a specific vertex buffer
  22513. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  22514. * It will do nothing if the buffer is not updatable
  22515. * @param kind defines the data kind (Position, normal, etc...)
  22516. * @param data defines the data to use
  22517. * @param offset defines the offset in the target buffer where to store the data
  22518. * @param useBytes set to true if the offset is in bytes
  22519. */
  22520. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22521. /**
  22522. * Update a specific vertex buffer
  22523. * This function will create a new buffer if the current one is not updatable
  22524. * @param kind defines the data kind (Position, normal, etc...)
  22525. * @param data defines the data to use
  22526. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22527. */
  22528. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22529. private _updateBoundingInfo;
  22530. /** @hidden */
  22531. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  22532. /**
  22533. * Gets total number of vertices
  22534. * @returns the total number of vertices
  22535. */
  22536. getTotalVertices(): number;
  22537. /**
  22538. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22539. * @param kind defines the data kind (Position, normal, etc...)
  22540. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22541. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22542. * @returns a float array containing vertex data
  22543. */
  22544. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22545. /**
  22546. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22547. * @param kind defines the data kind (Position, normal, etc...)
  22548. * @returns true if the vertex buffer with the specified kind is updatable
  22549. */
  22550. isVertexBufferUpdatable(kind: string): boolean;
  22551. /**
  22552. * Gets a specific vertex buffer
  22553. * @param kind defines the data kind (Position, normal, etc...)
  22554. * @returns a VertexBuffer
  22555. */
  22556. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22557. /**
  22558. * Returns all vertex buffers
  22559. * @return an object holding all vertex buffers indexed by kind
  22560. */
  22561. getVertexBuffers(): Nullable<{
  22562. [key: string]: VertexBuffer;
  22563. }>;
  22564. /**
  22565. * Gets a boolean indicating if specific vertex buffer is present
  22566. * @param kind defines the data kind (Position, normal, etc...)
  22567. * @returns true if data is present
  22568. */
  22569. isVerticesDataPresent(kind: string): boolean;
  22570. /**
  22571. * Gets a list of all attached data kinds (Position, normal, etc...)
  22572. * @returns a list of string containing all kinds
  22573. */
  22574. getVerticesDataKinds(): string[];
  22575. /**
  22576. * Update index buffer
  22577. * @param indices defines the indices to store in the index buffer
  22578. * @param offset defines the offset in the target buffer where to store the data
  22579. * @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)
  22580. */
  22581. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22582. /**
  22583. * Creates a new index buffer
  22584. * @param indices defines the indices to store in the index buffer
  22585. * @param totalVertices defines the total number of vertices (could be null)
  22586. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22587. */
  22588. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22589. /**
  22590. * Return the total number of indices
  22591. * @returns the total number of indices
  22592. */
  22593. getTotalIndices(): number;
  22594. /**
  22595. * Gets the index buffer array
  22596. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22597. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22598. * @returns the index buffer array
  22599. */
  22600. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22601. /**
  22602. * Gets the index buffer
  22603. * @return the index buffer
  22604. */
  22605. getIndexBuffer(): Nullable<WebGLBuffer>;
  22606. /** @hidden */
  22607. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22608. /**
  22609. * Release the associated resources for a specific mesh
  22610. * @param mesh defines the source mesh
  22611. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22612. */
  22613. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22614. /**
  22615. * Apply current geometry to a given mesh
  22616. * @param mesh defines the mesh to apply geometry to
  22617. */
  22618. applyToMesh(mesh: Mesh): void;
  22619. private _updateExtend;
  22620. private _applyToMesh;
  22621. private notifyUpdate;
  22622. /**
  22623. * Load the geometry if it was flagged as delay loaded
  22624. * @param scene defines the hosting scene
  22625. * @param onLoaded defines a callback called when the geometry is loaded
  22626. */
  22627. load(scene: Scene, onLoaded?: () => void): void;
  22628. private _queueLoad;
  22629. /**
  22630. * Invert the geometry to move from a right handed system to a left handed one.
  22631. */
  22632. toLeftHanded(): void;
  22633. /** @hidden */
  22634. _resetPointsArrayCache(): void;
  22635. /** @hidden */
  22636. _generatePointsArray(): boolean;
  22637. /**
  22638. * Gets a value indicating if the geometry is disposed
  22639. * @returns true if the geometry was disposed
  22640. */
  22641. isDisposed(): boolean;
  22642. private _disposeVertexArrayObjects;
  22643. /**
  22644. * Free all associated resources
  22645. */
  22646. dispose(): void;
  22647. /**
  22648. * Clone the current geometry into a new geometry
  22649. * @param id defines the unique ID of the new geometry
  22650. * @returns a new geometry object
  22651. */
  22652. copy(id: string): Geometry;
  22653. /**
  22654. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22655. * @return a JSON representation of the current geometry data (without the vertices data)
  22656. */
  22657. serialize(): any;
  22658. private toNumberArray;
  22659. /**
  22660. * Serialize all vertices data into a JSON oject
  22661. * @returns a JSON representation of the current geometry data
  22662. */
  22663. serializeVerticeData(): any;
  22664. /**
  22665. * Extracts a clone of a mesh geometry
  22666. * @param mesh defines the source mesh
  22667. * @param id defines the unique ID of the new geometry object
  22668. * @returns the new geometry object
  22669. */
  22670. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22671. /**
  22672. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22673. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22674. * Be aware Math.random() could cause collisions, but:
  22675. * "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"
  22676. * @returns a string containing a new GUID
  22677. */
  22678. static RandomId(): string;
  22679. /** @hidden */
  22680. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22681. private static _CleanMatricesWeights;
  22682. /**
  22683. * Create a new geometry from persisted data (Using .babylon file format)
  22684. * @param parsedVertexData defines the persisted data
  22685. * @param scene defines the hosting scene
  22686. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22687. * @returns the new geometry object
  22688. */
  22689. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22690. }
  22691. }
  22692. declare module "babylonjs/Meshes/mesh.vertexData" {
  22693. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22694. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  22695. import { Geometry } from "babylonjs/Meshes/geometry";
  22696. import { Mesh } from "babylonjs/Meshes/mesh";
  22697. /**
  22698. * Define an interface for all classes that will get and set the data on vertices
  22699. */
  22700. export interface IGetSetVerticesData {
  22701. /**
  22702. * Gets a boolean indicating if specific vertex data is present
  22703. * @param kind defines the vertex data kind to use
  22704. * @returns true is data kind is present
  22705. */
  22706. isVerticesDataPresent(kind: string): boolean;
  22707. /**
  22708. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22709. * @param kind defines the data kind (Position, normal, etc...)
  22710. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22711. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22712. * @returns a float array containing vertex data
  22713. */
  22714. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22715. /**
  22716. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22717. * @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.
  22718. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22719. * @returns the indices array or an empty array if the mesh has no geometry
  22720. */
  22721. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22722. /**
  22723. * Set specific vertex data
  22724. * @param kind defines the data kind (Position, normal, etc...)
  22725. * @param data defines the vertex data to use
  22726. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22727. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22728. */
  22729. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22730. /**
  22731. * Update a specific associated vertex buffer
  22732. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22733. * - VertexBuffer.PositionKind
  22734. * - VertexBuffer.UVKind
  22735. * - VertexBuffer.UV2Kind
  22736. * - VertexBuffer.UV3Kind
  22737. * - VertexBuffer.UV4Kind
  22738. * - VertexBuffer.UV5Kind
  22739. * - VertexBuffer.UV6Kind
  22740. * - VertexBuffer.ColorKind
  22741. * - VertexBuffer.MatricesIndicesKind
  22742. * - VertexBuffer.MatricesIndicesExtraKind
  22743. * - VertexBuffer.MatricesWeightsKind
  22744. * - VertexBuffer.MatricesWeightsExtraKind
  22745. * @param data defines the data source
  22746. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22747. * @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)
  22748. */
  22749. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22750. /**
  22751. * Creates a new index buffer
  22752. * @param indices defines the indices to store in the index buffer
  22753. * @param totalVertices defines the total number of vertices (could be null)
  22754. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22755. */
  22756. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22757. }
  22758. /**
  22759. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22760. */
  22761. export class VertexData {
  22762. /**
  22763. * Mesh side orientation : usually the external or front surface
  22764. */
  22765. static readonly FRONTSIDE: number;
  22766. /**
  22767. * Mesh side orientation : usually the internal or back surface
  22768. */
  22769. static readonly BACKSIDE: number;
  22770. /**
  22771. * Mesh side orientation : both internal and external or front and back surfaces
  22772. */
  22773. static readonly DOUBLESIDE: number;
  22774. /**
  22775. * Mesh side orientation : by default, `FRONTSIDE`
  22776. */
  22777. static readonly DEFAULTSIDE: number;
  22778. /**
  22779. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22780. */
  22781. positions: Nullable<FloatArray>;
  22782. /**
  22783. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22784. */
  22785. normals: Nullable<FloatArray>;
  22786. /**
  22787. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22788. */
  22789. tangents: Nullable<FloatArray>;
  22790. /**
  22791. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22792. */
  22793. uvs: Nullable<FloatArray>;
  22794. /**
  22795. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22796. */
  22797. uvs2: Nullable<FloatArray>;
  22798. /**
  22799. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22800. */
  22801. uvs3: Nullable<FloatArray>;
  22802. /**
  22803. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22804. */
  22805. uvs4: Nullable<FloatArray>;
  22806. /**
  22807. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22808. */
  22809. uvs5: Nullable<FloatArray>;
  22810. /**
  22811. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22812. */
  22813. uvs6: Nullable<FloatArray>;
  22814. /**
  22815. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22816. */
  22817. colors: Nullable<FloatArray>;
  22818. /**
  22819. * 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).
  22820. */
  22821. matricesIndices: Nullable<FloatArray>;
  22822. /**
  22823. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22824. */
  22825. matricesWeights: Nullable<FloatArray>;
  22826. /**
  22827. * An array extending the number of possible indices
  22828. */
  22829. matricesIndicesExtra: Nullable<FloatArray>;
  22830. /**
  22831. * An array extending the number of possible weights when the number of indices is extended
  22832. */
  22833. matricesWeightsExtra: Nullable<FloatArray>;
  22834. /**
  22835. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22836. */
  22837. indices: Nullable<IndicesArray>;
  22838. /**
  22839. * Uses the passed data array to set the set the values for the specified kind of data
  22840. * @param data a linear array of floating numbers
  22841. * @param kind the type of data that is being set, eg positions, colors etc
  22842. */
  22843. set(data: FloatArray, kind: string): void;
  22844. /**
  22845. * Associates the vertexData to the passed Mesh.
  22846. * Sets it as updatable or not (default `false`)
  22847. * @param mesh the mesh the vertexData is applied to
  22848. * @param updatable when used and having the value true allows new data to update the vertexData
  22849. * @returns the VertexData
  22850. */
  22851. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22852. /**
  22853. * Associates the vertexData to the passed Geometry.
  22854. * Sets it as updatable or not (default `false`)
  22855. * @param geometry the geometry the vertexData is applied to
  22856. * @param updatable when used and having the value true allows new data to update the vertexData
  22857. * @returns VertexData
  22858. */
  22859. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22860. /**
  22861. * Updates the associated mesh
  22862. * @param mesh the mesh to be updated
  22863. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22864. * @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
  22865. * @returns VertexData
  22866. */
  22867. updateMesh(mesh: Mesh): VertexData;
  22868. /**
  22869. * Updates the associated geometry
  22870. * @param geometry the geometry to be updated
  22871. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22872. * @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
  22873. * @returns VertexData.
  22874. */
  22875. updateGeometry(geometry: Geometry): VertexData;
  22876. private _applyTo;
  22877. private _update;
  22878. /**
  22879. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22880. * @param matrix the transforming matrix
  22881. * @returns the VertexData
  22882. */
  22883. transform(matrix: Matrix): VertexData;
  22884. /**
  22885. * Merges the passed VertexData into the current one
  22886. * @param other the VertexData to be merged into the current one
  22887. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22888. * @returns the modified VertexData
  22889. */
  22890. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22891. private _mergeElement;
  22892. private _validate;
  22893. /**
  22894. * Serializes the VertexData
  22895. * @returns a serialized object
  22896. */
  22897. serialize(): any;
  22898. /**
  22899. * Extracts the vertexData from a mesh
  22900. * @param mesh the mesh from which to extract the VertexData
  22901. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22902. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22903. * @returns the object VertexData associated to the passed mesh
  22904. */
  22905. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22906. /**
  22907. * Extracts the vertexData from the geometry
  22908. * @param geometry the geometry from which to extract the VertexData
  22909. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22910. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22911. * @returns the object VertexData associated to the passed mesh
  22912. */
  22913. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22914. private static _ExtractFrom;
  22915. /**
  22916. * Creates the VertexData for a Ribbon
  22917. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22918. * * pathArray array of paths, each of which an array of successive Vector3
  22919. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22920. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22921. * * 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
  22922. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22923. * * 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)
  22924. * * 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)
  22925. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22926. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22927. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22928. * @returns the VertexData of the ribbon
  22929. */
  22930. static CreateRibbon(options: {
  22931. pathArray: Vector3[][];
  22932. closeArray?: boolean;
  22933. closePath?: boolean;
  22934. offset?: number;
  22935. sideOrientation?: number;
  22936. frontUVs?: Vector4;
  22937. backUVs?: Vector4;
  22938. invertUV?: boolean;
  22939. uvs?: Vector2[];
  22940. colors?: Color4[];
  22941. }): VertexData;
  22942. /**
  22943. * Creates the VertexData for a box
  22944. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22945. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22946. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22947. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22948. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22949. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22950. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22951. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22952. * * 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)
  22953. * * 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)
  22954. * @returns the VertexData of the box
  22955. */
  22956. static CreateBox(options: {
  22957. size?: number;
  22958. width?: number;
  22959. height?: number;
  22960. depth?: number;
  22961. faceUV?: Vector4[];
  22962. faceColors?: Color4[];
  22963. sideOrientation?: number;
  22964. frontUVs?: Vector4;
  22965. backUVs?: Vector4;
  22966. }): VertexData;
  22967. /**
  22968. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22969. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22970. * * segments sets the number of horizontal strips optional, default 32
  22971. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22972. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22973. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22974. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22975. * * 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
  22976. * * 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
  22977. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22978. * * 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)
  22979. * * 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)
  22980. * @returns the VertexData of the ellipsoid
  22981. */
  22982. static CreateSphere(options: {
  22983. segments?: number;
  22984. diameter?: number;
  22985. diameterX?: number;
  22986. diameterY?: number;
  22987. diameterZ?: number;
  22988. arc?: number;
  22989. slice?: number;
  22990. sideOrientation?: number;
  22991. frontUVs?: Vector4;
  22992. backUVs?: Vector4;
  22993. }): VertexData;
  22994. /**
  22995. * Creates the VertexData for a cylinder, cone or prism
  22996. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22997. * * height sets the height (y direction) of the cylinder, optional, default 2
  22998. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22999. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23000. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23001. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23002. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23003. * * 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
  23004. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23005. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23006. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23007. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23008. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23009. * * 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)
  23010. * * 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)
  23011. * @returns the VertexData of the cylinder, cone or prism
  23012. */
  23013. static CreateCylinder(options: {
  23014. height?: number;
  23015. diameterTop?: number;
  23016. diameterBottom?: number;
  23017. diameter?: number;
  23018. tessellation?: number;
  23019. subdivisions?: number;
  23020. arc?: number;
  23021. faceColors?: Color4[];
  23022. faceUV?: Vector4[];
  23023. hasRings?: boolean;
  23024. enclose?: boolean;
  23025. sideOrientation?: number;
  23026. frontUVs?: Vector4;
  23027. backUVs?: Vector4;
  23028. }): VertexData;
  23029. /**
  23030. * Creates the VertexData for a torus
  23031. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23032. * * diameter the diameter of the torus, optional default 1
  23033. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23034. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23035. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23036. * * 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)
  23037. * * 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)
  23038. * @returns the VertexData of the torus
  23039. */
  23040. static CreateTorus(options: {
  23041. diameter?: number;
  23042. thickness?: number;
  23043. tessellation?: number;
  23044. sideOrientation?: number;
  23045. frontUVs?: Vector4;
  23046. backUVs?: Vector4;
  23047. }): VertexData;
  23048. /**
  23049. * Creates the VertexData of the LineSystem
  23050. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23051. * - lines an array of lines, each line being an array of successive Vector3
  23052. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23053. * @returns the VertexData of the LineSystem
  23054. */
  23055. static CreateLineSystem(options: {
  23056. lines: Vector3[][];
  23057. colors?: Nullable<Color4[][]>;
  23058. }): VertexData;
  23059. /**
  23060. * Create the VertexData for a DashedLines
  23061. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23062. * - points an array successive Vector3
  23063. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23064. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23065. * - dashNb the intended total number of dashes, optional, default 200
  23066. * @returns the VertexData for the DashedLines
  23067. */
  23068. static CreateDashedLines(options: {
  23069. points: Vector3[];
  23070. dashSize?: number;
  23071. gapSize?: number;
  23072. dashNb?: number;
  23073. }): VertexData;
  23074. /**
  23075. * Creates the VertexData for a Ground
  23076. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23077. * - width the width (x direction) of the ground, optional, default 1
  23078. * - height the height (z direction) of the ground, optional, default 1
  23079. * - subdivisions the number of subdivisions per side, optional, default 1
  23080. * @returns the VertexData of the Ground
  23081. */
  23082. static CreateGround(options: {
  23083. width?: number;
  23084. height?: number;
  23085. subdivisions?: number;
  23086. subdivisionsX?: number;
  23087. subdivisionsY?: number;
  23088. }): VertexData;
  23089. /**
  23090. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23091. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23092. * * xmin the ground minimum X coordinate, optional, default -1
  23093. * * zmin the ground minimum Z coordinate, optional, default -1
  23094. * * xmax the ground maximum X coordinate, optional, default 1
  23095. * * zmax the ground maximum Z coordinate, optional, default 1
  23096. * * 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}
  23097. * * 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}
  23098. * @returns the VertexData of the TiledGround
  23099. */
  23100. static CreateTiledGround(options: {
  23101. xmin: number;
  23102. zmin: number;
  23103. xmax: number;
  23104. zmax: number;
  23105. subdivisions?: {
  23106. w: number;
  23107. h: number;
  23108. };
  23109. precision?: {
  23110. w: number;
  23111. h: number;
  23112. };
  23113. }): VertexData;
  23114. /**
  23115. * Creates the VertexData of the Ground designed from a heightmap
  23116. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23117. * * width the width (x direction) of the ground
  23118. * * height the height (z direction) of the ground
  23119. * * subdivisions the number of subdivisions per side
  23120. * * minHeight the minimum altitude on the ground, optional, default 0
  23121. * * maxHeight the maximum altitude on the ground, optional default 1
  23122. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23123. * * buffer the array holding the image color data
  23124. * * bufferWidth the width of image
  23125. * * bufferHeight the height of image
  23126. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23127. * @returns the VertexData of the Ground designed from a heightmap
  23128. */
  23129. static CreateGroundFromHeightMap(options: {
  23130. width: number;
  23131. height: number;
  23132. subdivisions: number;
  23133. minHeight: number;
  23134. maxHeight: number;
  23135. colorFilter: Color3;
  23136. buffer: Uint8Array;
  23137. bufferWidth: number;
  23138. bufferHeight: number;
  23139. alphaFilter: number;
  23140. }): VertexData;
  23141. /**
  23142. * Creates the VertexData for a Plane
  23143. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23144. * * size sets the width and height of the plane to the value of size, optional default 1
  23145. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23146. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23147. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23148. * * 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)
  23149. * * 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)
  23150. * @returns the VertexData of the box
  23151. */
  23152. static CreatePlane(options: {
  23153. size?: number;
  23154. width?: number;
  23155. height?: number;
  23156. sideOrientation?: number;
  23157. frontUVs?: Vector4;
  23158. backUVs?: Vector4;
  23159. }): VertexData;
  23160. /**
  23161. * Creates the VertexData of the Disc or regular Polygon
  23162. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23163. * * radius the radius of the disc, optional default 0.5
  23164. * * tessellation the number of polygon sides, optional, default 64
  23165. * * 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
  23166. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23167. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23168. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23169. * @returns the VertexData of the box
  23170. */
  23171. static CreateDisc(options: {
  23172. radius?: number;
  23173. tessellation?: number;
  23174. arc?: number;
  23175. sideOrientation?: number;
  23176. frontUVs?: Vector4;
  23177. backUVs?: Vector4;
  23178. }): VertexData;
  23179. /**
  23180. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23181. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23182. * @param polygon a mesh built from polygonTriangulation.build()
  23183. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23184. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23185. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23186. * @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)
  23187. * @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)
  23188. * @returns the VertexData of the Polygon
  23189. */
  23190. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23191. /**
  23192. * Creates the VertexData of the IcoSphere
  23193. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23194. * * radius the radius of the IcoSphere, optional default 1
  23195. * * radiusX allows stretching in the x direction, optional, default radius
  23196. * * radiusY allows stretching in the y direction, optional, default radius
  23197. * * radiusZ allows stretching in the z direction, optional, default radius
  23198. * * flat when true creates a flat shaded mesh, optional, default true
  23199. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23200. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23201. * * 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)
  23202. * * 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)
  23203. * @returns the VertexData of the IcoSphere
  23204. */
  23205. static CreateIcoSphere(options: {
  23206. radius?: number;
  23207. radiusX?: number;
  23208. radiusY?: number;
  23209. radiusZ?: number;
  23210. flat?: boolean;
  23211. subdivisions?: number;
  23212. sideOrientation?: number;
  23213. frontUVs?: Vector4;
  23214. backUVs?: Vector4;
  23215. }): VertexData;
  23216. /**
  23217. * Creates the VertexData for a Polyhedron
  23218. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23219. * * type provided types are:
  23220. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23221. * * 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)
  23222. * * size the size of the IcoSphere, optional default 1
  23223. * * sizeX allows stretching in the x direction, optional, default size
  23224. * * sizeY allows stretching in the y direction, optional, default size
  23225. * * sizeZ allows stretching in the z direction, optional, default size
  23226. * * 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
  23227. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23228. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23229. * * flat when true creates a flat shaded mesh, optional, default true
  23230. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23231. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23232. * * 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)
  23233. * * 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)
  23234. * @returns the VertexData of the Polyhedron
  23235. */
  23236. static CreatePolyhedron(options: {
  23237. type?: number;
  23238. size?: number;
  23239. sizeX?: number;
  23240. sizeY?: number;
  23241. sizeZ?: number;
  23242. custom?: any;
  23243. faceUV?: Vector4[];
  23244. faceColors?: Color4[];
  23245. flat?: boolean;
  23246. sideOrientation?: number;
  23247. frontUVs?: Vector4;
  23248. backUVs?: Vector4;
  23249. }): VertexData;
  23250. /**
  23251. * Creates the VertexData for a TorusKnot
  23252. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23253. * * radius the radius of the torus knot, optional, default 2
  23254. * * tube the thickness of the tube, optional, default 0.5
  23255. * * radialSegments the number of sides on each tube segments, optional, default 32
  23256. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23257. * * p the number of windings around the z axis, optional, default 2
  23258. * * q the number of windings around the x axis, optional, default 3
  23259. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23260. * * 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)
  23261. * * 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)
  23262. * @returns the VertexData of the Torus Knot
  23263. */
  23264. static CreateTorusKnot(options: {
  23265. radius?: number;
  23266. tube?: number;
  23267. radialSegments?: number;
  23268. tubularSegments?: number;
  23269. p?: number;
  23270. q?: number;
  23271. sideOrientation?: number;
  23272. frontUVs?: Vector4;
  23273. backUVs?: Vector4;
  23274. }): VertexData;
  23275. /**
  23276. * Compute normals for given positions and indices
  23277. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23278. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23279. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23280. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23281. * * facetNormals : optional array of facet normals (vector3)
  23282. * * facetPositions : optional array of facet positions (vector3)
  23283. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23284. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23285. * * bInfo : optional bounding info, required for facetPartitioning computation
  23286. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23287. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23288. * * useRightHandedSystem: optional boolean to for right handed system computation
  23289. * * depthSort : optional boolean to enable the facet depth sort computation
  23290. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23291. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23292. */
  23293. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23294. facetNormals?: any;
  23295. facetPositions?: any;
  23296. facetPartitioning?: any;
  23297. ratio?: number;
  23298. bInfo?: any;
  23299. bbSize?: Vector3;
  23300. subDiv?: any;
  23301. useRightHandedSystem?: boolean;
  23302. depthSort?: boolean;
  23303. distanceTo?: Vector3;
  23304. depthSortedFacets?: any;
  23305. }): void;
  23306. /** @hidden */
  23307. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23308. /**
  23309. * Applies VertexData created from the imported parameters to the geometry
  23310. * @param parsedVertexData the parsed data from an imported file
  23311. * @param geometry the geometry to apply the VertexData to
  23312. */
  23313. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23314. }
  23315. }
  23316. declare module "babylonjs/Meshes/Builders/discBuilder" {
  23317. import { Nullable } from "babylonjs/types";
  23318. import { Scene } from "babylonjs/scene";
  23319. import { Vector4 } from "babylonjs/Maths/math";
  23320. import { Mesh } from "babylonjs/Meshes/mesh";
  23321. /**
  23322. * Class containing static functions to help procedurally build meshes
  23323. */
  23324. export class DiscBuilder {
  23325. /**
  23326. * Creates a plane polygonal mesh. By default, this is a disc
  23327. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23328. * * 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
  23329. * * 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
  23330. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23331. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23332. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23333. * @param name defines the name of the mesh
  23334. * @param options defines the options used to create the mesh
  23335. * @param scene defines the hosting scene
  23336. * @returns the plane polygonal mesh
  23337. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23338. */
  23339. static CreateDisc(name: string, options: {
  23340. radius?: number;
  23341. tessellation?: number;
  23342. arc?: number;
  23343. updatable?: boolean;
  23344. sideOrientation?: number;
  23345. frontUVs?: Vector4;
  23346. backUVs?: Vector4;
  23347. }, scene?: Nullable<Scene>): Mesh;
  23348. }
  23349. }
  23350. declare module "babylonjs/Particles/solidParticleSystem" {
  23351. import { Vector3 } from "babylonjs/Maths/math";
  23352. import { Mesh } from "babylonjs/Meshes/mesh";
  23353. import { Scene, IDisposable } from "babylonjs/scene";
  23354. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  23355. /**
  23356. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23357. *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.
  23358. * The SPS is also a particle system. It provides some methods to manage the particles.
  23359. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23360. *
  23361. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23362. */
  23363. export class SolidParticleSystem implements IDisposable {
  23364. /**
  23365. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23366. * Example : var p = SPS.particles[i];
  23367. */
  23368. particles: SolidParticle[];
  23369. /**
  23370. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23371. */
  23372. nbParticles: number;
  23373. /**
  23374. * If the particles must ever face the camera (default false). Useful for planar particles.
  23375. */
  23376. billboard: boolean;
  23377. /**
  23378. * Recompute normals when adding a shape
  23379. */
  23380. recomputeNormals: boolean;
  23381. /**
  23382. * This a counter ofr your own usage. It's not set by any SPS functions.
  23383. */
  23384. counter: number;
  23385. /**
  23386. * The SPS name. This name is also given to the underlying mesh.
  23387. */
  23388. name: string;
  23389. /**
  23390. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23391. */
  23392. mesh: Mesh;
  23393. /**
  23394. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23395. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23396. */
  23397. vars: any;
  23398. /**
  23399. * This array is populated when the SPS is set as 'pickable'.
  23400. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23401. * Each element of this array is an object `{idx: int, faceId: int}`.
  23402. * `idx` is the picked particle index in the `SPS.particles` array
  23403. * `faceId` is the picked face index counted within this particle.
  23404. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23405. */
  23406. pickedParticles: {
  23407. idx: number;
  23408. faceId: number;
  23409. }[];
  23410. /**
  23411. * This array is populated when `enableDepthSort` is set to true.
  23412. * Each element of this array is an instance of the class DepthSortedParticle.
  23413. */
  23414. depthSortedParticles: DepthSortedParticle[];
  23415. /**
  23416. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23417. * @hidden
  23418. */
  23419. _bSphereOnly: boolean;
  23420. /**
  23421. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23422. * @hidden
  23423. */
  23424. _bSphereRadiusFactor: number;
  23425. private _scene;
  23426. private _positions;
  23427. private _indices;
  23428. private _normals;
  23429. private _colors;
  23430. private _uvs;
  23431. private _indices32;
  23432. private _positions32;
  23433. private _normals32;
  23434. private _fixedNormal32;
  23435. private _colors32;
  23436. private _uvs32;
  23437. private _index;
  23438. private _updatable;
  23439. private _pickable;
  23440. private _isVisibilityBoxLocked;
  23441. private _alwaysVisible;
  23442. private _depthSort;
  23443. private _shapeCounter;
  23444. private _copy;
  23445. private _color;
  23446. private _computeParticleColor;
  23447. private _computeParticleTexture;
  23448. private _computeParticleRotation;
  23449. private _computeParticleVertex;
  23450. private _computeBoundingBox;
  23451. private _depthSortParticles;
  23452. private _camera;
  23453. private _mustUnrotateFixedNormals;
  23454. private _particlesIntersect;
  23455. private _needs32Bits;
  23456. /**
  23457. * Creates a SPS (Solid Particle System) object.
  23458. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23459. * @param scene (Scene) is the scene in which the SPS is added.
  23460. * @param options defines the options of the sps e.g.
  23461. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23462. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23463. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23464. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23465. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23466. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23467. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23468. */
  23469. constructor(name: string, scene: Scene, options?: {
  23470. updatable?: boolean;
  23471. isPickable?: boolean;
  23472. enableDepthSort?: boolean;
  23473. particleIntersection?: boolean;
  23474. boundingSphereOnly?: boolean;
  23475. bSphereRadiusFactor?: number;
  23476. });
  23477. /**
  23478. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23479. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23480. * @returns the created mesh
  23481. */
  23482. buildMesh(): Mesh;
  23483. /**
  23484. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23485. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23486. * Thus the particles generated from `digest()` have their property `position` set yet.
  23487. * @param mesh ( Mesh ) is the mesh to be digested
  23488. * @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
  23489. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23490. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23491. * @returns the current SPS
  23492. */
  23493. digest(mesh: Mesh, options?: {
  23494. facetNb?: number;
  23495. number?: number;
  23496. delta?: number;
  23497. }): SolidParticleSystem;
  23498. private _unrotateFixedNormals;
  23499. private _resetCopy;
  23500. private _meshBuilder;
  23501. private _posToShape;
  23502. private _uvsToShapeUV;
  23503. private _addParticle;
  23504. /**
  23505. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23506. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23507. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23508. * @param nb (positive integer) the number of particles to be created from this model
  23509. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23510. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23511. * @returns the number of shapes in the system
  23512. */
  23513. addShape(mesh: Mesh, nb: number, options?: {
  23514. positionFunction?: any;
  23515. vertexFunction?: any;
  23516. }): number;
  23517. private _rebuildParticle;
  23518. /**
  23519. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23520. * @returns the SPS.
  23521. */
  23522. rebuildMesh(): SolidParticleSystem;
  23523. /**
  23524. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23525. * This method calls `updateParticle()` for each particle of the SPS.
  23526. * For an animated SPS, it is usually called within the render loop.
  23527. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23528. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23529. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23530. * @returns the SPS.
  23531. */
  23532. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23533. /**
  23534. * Disposes the SPS.
  23535. */
  23536. dispose(): void;
  23537. /**
  23538. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23539. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23540. * @returns the SPS.
  23541. */
  23542. refreshVisibleSize(): SolidParticleSystem;
  23543. /**
  23544. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23545. * @param size the size (float) of the visibility box
  23546. * note : this doesn't lock the SPS mesh bounding box.
  23547. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23548. */
  23549. setVisibilityBox(size: number): void;
  23550. /**
  23551. * Gets whether the SPS as always visible or not
  23552. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23553. */
  23554. /**
  23555. * Sets the SPS as always visible or not
  23556. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23557. */
  23558. isAlwaysVisible: boolean;
  23559. /**
  23560. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23561. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23562. */
  23563. /**
  23564. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23565. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23566. */
  23567. isVisibilityBoxLocked: boolean;
  23568. /**
  23569. * Tells to `setParticles()` to compute the particle rotations or not.
  23570. * Default value : true. The SPS is faster when it's set to false.
  23571. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23572. */
  23573. /**
  23574. * Gets if `setParticles()` computes the particle rotations or not.
  23575. * Default value : true. The SPS is faster when it's set to false.
  23576. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23577. */
  23578. computeParticleRotation: boolean;
  23579. /**
  23580. * Tells to `setParticles()` to compute the particle colors or not.
  23581. * Default value : true. The SPS is faster when it's set to false.
  23582. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23583. */
  23584. /**
  23585. * Gets if `setParticles()` computes the particle colors or not.
  23586. * Default value : true. The SPS is faster when it's set to false.
  23587. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23588. */
  23589. computeParticleColor: boolean;
  23590. /**
  23591. * Gets if `setParticles()` computes the particle textures or not.
  23592. * Default value : true. The SPS is faster when it's set to false.
  23593. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23594. */
  23595. computeParticleTexture: boolean;
  23596. /**
  23597. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23598. * Default value : false. The SPS is faster when it's set to false.
  23599. * Note : the particle custom vertex positions aren't stored values.
  23600. */
  23601. /**
  23602. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23603. * Default value : false. The SPS is faster when it's set to false.
  23604. * Note : the particle custom vertex positions aren't stored values.
  23605. */
  23606. computeParticleVertex: boolean;
  23607. /**
  23608. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23609. */
  23610. /**
  23611. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23612. */
  23613. computeBoundingBox: boolean;
  23614. /**
  23615. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23616. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23617. * Default : `true`
  23618. */
  23619. /**
  23620. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23621. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23622. * Default : `true`
  23623. */
  23624. depthSortParticles: boolean;
  23625. /**
  23626. * This function does nothing. It may be overwritten to set all the particle first values.
  23627. * The SPS doesn't call this function, you may have to call it by your own.
  23628. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23629. */
  23630. initParticles(): void;
  23631. /**
  23632. * This function does nothing. It may be overwritten to recycle a particle.
  23633. * The SPS doesn't call this function, you may have to call it by your own.
  23634. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23635. * @param particle The particle to recycle
  23636. * @returns the recycled particle
  23637. */
  23638. recycleParticle(particle: SolidParticle): SolidParticle;
  23639. /**
  23640. * Updates a particle : this function should be overwritten by the user.
  23641. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23642. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23643. * @example : just set a particle position or velocity and recycle conditions
  23644. * @param particle The particle to update
  23645. * @returns the updated particle
  23646. */
  23647. updateParticle(particle: SolidParticle): SolidParticle;
  23648. /**
  23649. * Updates a vertex of a particle : it can be overwritten by the user.
  23650. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23651. * @param particle the current particle
  23652. * @param vertex the current index of the current particle
  23653. * @param pt the index of the current vertex in the particle shape
  23654. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23655. * @example : just set a vertex particle position
  23656. * @returns the updated vertex
  23657. */
  23658. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23659. /**
  23660. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23661. * This does nothing and may be overwritten by the user.
  23662. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23663. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23664. * @param update the boolean update value actually passed to setParticles()
  23665. */
  23666. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23667. /**
  23668. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23669. * This will be passed three parameters.
  23670. * This does nothing and may be overwritten by the user.
  23671. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23672. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23673. * @param update the boolean update value actually passed to setParticles()
  23674. */
  23675. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23676. }
  23677. }
  23678. declare module "babylonjs/Particles/solidParticle" {
  23679. import { Nullable } from "babylonjs/types";
  23680. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  23681. import { Mesh } from "babylonjs/Meshes/mesh";
  23682. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23683. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  23684. /**
  23685. * Represents one particle of a solid particle system.
  23686. */
  23687. export class SolidParticle {
  23688. /**
  23689. * particle global index
  23690. */
  23691. idx: number;
  23692. /**
  23693. * The color of the particle
  23694. */
  23695. color: Nullable<Color4>;
  23696. /**
  23697. * The world space position of the particle.
  23698. */
  23699. position: Vector3;
  23700. /**
  23701. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23702. */
  23703. rotation: Vector3;
  23704. /**
  23705. * The world space rotation quaternion of the particle.
  23706. */
  23707. rotationQuaternion: Nullable<Quaternion>;
  23708. /**
  23709. * The scaling of the particle.
  23710. */
  23711. scaling: Vector3;
  23712. /**
  23713. * The uvs of the particle.
  23714. */
  23715. uvs: Vector4;
  23716. /**
  23717. * The current speed of the particle.
  23718. */
  23719. velocity: Vector3;
  23720. /**
  23721. * The pivot point in the particle local space.
  23722. */
  23723. pivot: Vector3;
  23724. /**
  23725. * Must the particle be translated from its pivot point in its local space ?
  23726. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23727. * Default : false
  23728. */
  23729. translateFromPivot: boolean;
  23730. /**
  23731. * Is the particle active or not ?
  23732. */
  23733. alive: boolean;
  23734. /**
  23735. * Is the particle visible or not ?
  23736. */
  23737. isVisible: boolean;
  23738. /**
  23739. * Index of this particle in the global "positions" array (Internal use)
  23740. * @hidden
  23741. */
  23742. _pos: number;
  23743. /**
  23744. * @hidden Index of this particle in the global "indices" array (Internal use)
  23745. */
  23746. _ind: number;
  23747. /**
  23748. * @hidden ModelShape of this particle (Internal use)
  23749. */
  23750. _model: ModelShape;
  23751. /**
  23752. * ModelShape id of this particle
  23753. */
  23754. shapeId: number;
  23755. /**
  23756. * Index of the particle in its shape id (Internal use)
  23757. */
  23758. idxInShape: number;
  23759. /**
  23760. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  23761. */
  23762. _modelBoundingInfo: BoundingInfo;
  23763. /**
  23764. * @hidden Particle BoundingInfo object (Internal use)
  23765. */
  23766. _boundingInfo: BoundingInfo;
  23767. /**
  23768. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  23769. */
  23770. _sps: SolidParticleSystem;
  23771. /**
  23772. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  23773. */
  23774. _stillInvisible: boolean;
  23775. /**
  23776. * @hidden Last computed particle rotation matrix
  23777. */
  23778. _rotationMatrix: number[];
  23779. /**
  23780. * Parent particle Id, if any.
  23781. * Default null.
  23782. */
  23783. parentId: Nullable<number>;
  23784. /**
  23785. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  23786. * The possible values are :
  23787. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23788. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23789. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23790. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23791. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23792. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  23793. * */
  23794. cullingStrategy: number;
  23795. /**
  23796. * @hidden Internal global position in the SPS.
  23797. */
  23798. _globalPosition: Vector3;
  23799. /**
  23800. * Creates a Solid Particle object.
  23801. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23802. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23803. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23804. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23805. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23806. * @param shapeId (integer) is the model shape identifier in the SPS.
  23807. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23808. * @param sps defines the sps it is associated to
  23809. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23810. */
  23811. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23812. /**
  23813. * Legacy support, changed scale to scaling
  23814. */
  23815. /**
  23816. * Legacy support, changed scale to scaling
  23817. */
  23818. scale: Vector3;
  23819. /**
  23820. * Legacy support, changed quaternion to rotationQuaternion
  23821. */
  23822. /**
  23823. * Legacy support, changed quaternion to rotationQuaternion
  23824. */
  23825. quaternion: Nullable<Quaternion>;
  23826. /**
  23827. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23828. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23829. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23830. * @returns true if it intersects
  23831. */
  23832. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23833. /**
  23834. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  23835. * A particle is in the frustum if its bounding box intersects the frustum
  23836. * @param frustumPlanes defines the frustum to test
  23837. * @returns true if the particle is in the frustum planes
  23838. */
  23839. isInFrustum(frustumPlanes: Plane[]): boolean;
  23840. /**
  23841. * get the rotation matrix of the particle
  23842. * @hidden
  23843. */
  23844. getRotationMatrix(m: Matrix): void;
  23845. }
  23846. /**
  23847. * Represents the shape of the model used by one particle of a solid particle system.
  23848. * SPS internal tool, don't use it manually.
  23849. */
  23850. export class ModelShape {
  23851. /**
  23852. * The shape id
  23853. * @hidden
  23854. */
  23855. shapeID: number;
  23856. /**
  23857. * flat array of model positions (internal use)
  23858. * @hidden
  23859. */
  23860. _shape: Vector3[];
  23861. /**
  23862. * flat array of model UVs (internal use)
  23863. * @hidden
  23864. */
  23865. _shapeUV: number[];
  23866. /**
  23867. * length of the shape in the model indices array (internal use)
  23868. * @hidden
  23869. */
  23870. _indicesLength: number;
  23871. /**
  23872. * Custom position function (internal use)
  23873. * @hidden
  23874. */
  23875. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  23876. /**
  23877. * Custom vertex function (internal use)
  23878. * @hidden
  23879. */
  23880. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23881. /**
  23882. * 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.
  23883. * SPS internal tool, don't use it manually.
  23884. * @hidden
  23885. */
  23886. 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>);
  23887. }
  23888. /**
  23889. * Represents a Depth Sorted Particle in the solid particle system.
  23890. */
  23891. export class DepthSortedParticle {
  23892. /**
  23893. * Index of the particle in the "indices" array
  23894. */
  23895. ind: number;
  23896. /**
  23897. * Length of the particle shape in the "indices" array
  23898. */
  23899. indicesLength: number;
  23900. /**
  23901. * Squared distance from the particle to the camera
  23902. */
  23903. sqDistance: number;
  23904. }
  23905. }
  23906. declare module "babylonjs/Meshes/abstractMesh" {
  23907. import { Observable } from "babylonjs/Misc/observable";
  23908. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  23909. import { Camera } from "babylonjs/Cameras/camera";
  23910. import { Scene, IDisposable } from "babylonjs/scene";
  23911. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  23912. import { Node } from "babylonjs/node";
  23913. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  23914. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23915. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23916. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  23917. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23918. import { Material } from "babylonjs/Materials/material";
  23919. import { Light } from "babylonjs/Lights/light";
  23920. import { Skeleton } from "babylonjs/Bones/skeleton";
  23921. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  23922. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  23923. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  23924. import { Ray } from "babylonjs/Culling/ray";
  23925. import { Collider } from "babylonjs/Collisions/collider";
  23926. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  23927. /**
  23928. * Class used to store all common mesh properties
  23929. */
  23930. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23931. /** No occlusion */
  23932. static OCCLUSION_TYPE_NONE: number;
  23933. /** Occlusion set to optimisitic */
  23934. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23935. /** Occlusion set to strict */
  23936. static OCCLUSION_TYPE_STRICT: number;
  23937. /** Use an accurante occlusion algorithm */
  23938. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23939. /** Use a conservative occlusion algorithm */
  23940. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23941. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  23942. * Test order :
  23943. * Is the bounding sphere outside the frustum ?
  23944. * If not, are the bounding box vertices outside the frustum ?
  23945. * It not, then the cullable object is in the frustum.
  23946. */
  23947. static readonly CULLINGSTRATEGY_STANDARD: number;
  23948. /** Culling strategy : Bounding Sphere Only.
  23949. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  23950. * It's also less accurate than the standard because some not visible objects can still be selected.
  23951. * Test : is the bounding sphere outside the frustum ?
  23952. * If not, then the cullable object is in the frustum.
  23953. */
  23954. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23955. /** Culling strategy : Optimistic Inclusion.
  23956. * This in an inclusion test first, then the standard exclusion test.
  23957. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  23958. * 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.
  23959. * Anyway, it's as accurate as the standard strategy.
  23960. * Test :
  23961. * Is the cullable object bounding sphere center in the frustum ?
  23962. * If not, apply the default culling strategy.
  23963. */
  23964. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  23965. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  23966. * This in an inclusion test first, then the bounding sphere only exclusion test.
  23967. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  23968. * 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.
  23969. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  23970. * Test :
  23971. * Is the cullable object bounding sphere center in the frustum ?
  23972. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  23973. */
  23974. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  23975. /**
  23976. * No billboard
  23977. */
  23978. static readonly BILLBOARDMODE_NONE: number;
  23979. /** Billboard on X axis */
  23980. static readonly BILLBOARDMODE_X: number;
  23981. /** Billboard on Y axis */
  23982. static readonly BILLBOARDMODE_Y: number;
  23983. /** Billboard on Z axis */
  23984. static readonly BILLBOARDMODE_Z: number;
  23985. /** Billboard on all axes */
  23986. static readonly BILLBOARDMODE_ALL: number;
  23987. private _facetData;
  23988. /**
  23989. * The culling strategy to use to check whether the mesh must be rendered or not.
  23990. * This value can be changed at any time and will be used on the next render mesh selection.
  23991. * The possible values are :
  23992. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23993. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23994. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23995. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23996. * Please read each static variable documentation to get details about the culling process.
  23997. * */
  23998. cullingStrategy: number;
  23999. /**
  24000. * Gets the number of facets in the mesh
  24001. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24002. */
  24003. readonly facetNb: number;
  24004. /**
  24005. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24006. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24007. */
  24008. partitioningSubdivisions: number;
  24009. /**
  24010. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24011. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24012. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24013. */
  24014. partitioningBBoxRatio: number;
  24015. /**
  24016. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24017. * Works only for updatable meshes.
  24018. * Doesn't work with multi-materials
  24019. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24020. */
  24021. mustDepthSortFacets: boolean;
  24022. /**
  24023. * The location (Vector3) where the facet depth sort must be computed from.
  24024. * By default, the active camera position.
  24025. * Used only when facet depth sort is enabled
  24026. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24027. */
  24028. facetDepthSortFrom: Vector3;
  24029. /**
  24030. * gets a boolean indicating if facetData is enabled
  24031. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24032. */
  24033. readonly isFacetDataEnabled: boolean;
  24034. /** @hidden */
  24035. _updateNonUniformScalingState(value: boolean): boolean;
  24036. /**
  24037. * An event triggered when this mesh collides with another one
  24038. */
  24039. onCollideObservable: Observable<AbstractMesh>;
  24040. private _onCollideObserver;
  24041. /** Set a function to call when this mesh collides with another one */
  24042. onCollide: () => void;
  24043. /**
  24044. * An event triggered when the collision's position changes
  24045. */
  24046. onCollisionPositionChangeObservable: Observable<Vector3>;
  24047. private _onCollisionPositionChangeObserver;
  24048. /** Set a function to call when the collision's position changes */
  24049. onCollisionPositionChange: () => void;
  24050. /**
  24051. * An event triggered when material is changed
  24052. */
  24053. onMaterialChangedObservable: Observable<AbstractMesh>;
  24054. /**
  24055. * Gets or sets the orientation for POV movement & rotation
  24056. */
  24057. definedFacingForward: boolean;
  24058. /** @hidden */
  24059. _occlusionQuery: Nullable<WebGLQuery>;
  24060. private _visibility;
  24061. /**
  24062. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24063. */
  24064. /**
  24065. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24066. */
  24067. visibility: number;
  24068. /** Gets or sets the alpha index used to sort transparent meshes
  24069. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24070. */
  24071. alphaIndex: number;
  24072. /**
  24073. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24074. */
  24075. isVisible: boolean;
  24076. /**
  24077. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24078. */
  24079. isPickable: boolean;
  24080. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24081. showSubMeshesBoundingBox: boolean;
  24082. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24083. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24084. */
  24085. isBlocker: boolean;
  24086. /**
  24087. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24088. */
  24089. enablePointerMoveEvents: boolean;
  24090. /**
  24091. * Specifies the rendering group id for this mesh (0 by default)
  24092. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24093. */
  24094. renderingGroupId: number;
  24095. private _material;
  24096. /** Gets or sets current material */
  24097. material: Nullable<Material>;
  24098. private _receiveShadows;
  24099. /**
  24100. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24101. * @see http://doc.babylonjs.com/babylon101/shadows
  24102. */
  24103. receiveShadows: boolean;
  24104. /** Defines color to use when rendering outline */
  24105. outlineColor: Color3;
  24106. /** Define width to use when rendering outline */
  24107. outlineWidth: number;
  24108. /** Defines color to use when rendering overlay */
  24109. overlayColor: Color3;
  24110. /** Defines alpha to use when rendering overlay */
  24111. overlayAlpha: number;
  24112. private _hasVertexAlpha;
  24113. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24114. hasVertexAlpha: boolean;
  24115. private _useVertexColors;
  24116. /** 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) */
  24117. useVertexColors: boolean;
  24118. private _computeBonesUsingShaders;
  24119. /**
  24120. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24121. */
  24122. computeBonesUsingShaders: boolean;
  24123. private _numBoneInfluencers;
  24124. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24125. numBoneInfluencers: number;
  24126. private _applyFog;
  24127. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24128. applyFog: boolean;
  24129. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24130. useOctreeForRenderingSelection: boolean;
  24131. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24132. useOctreeForPicking: boolean;
  24133. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24134. useOctreeForCollisions: boolean;
  24135. private _layerMask;
  24136. /**
  24137. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24138. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24139. */
  24140. layerMask: number;
  24141. /**
  24142. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24143. */
  24144. alwaysSelectAsActiveMesh: boolean;
  24145. /**
  24146. * Gets or sets the current action manager
  24147. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24148. */
  24149. actionManager: Nullable<AbstractActionManager>;
  24150. private _checkCollisions;
  24151. private _collisionMask;
  24152. private _collisionGroup;
  24153. /**
  24154. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24155. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24156. */
  24157. ellipsoid: Vector3;
  24158. /**
  24159. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24160. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24161. */
  24162. ellipsoidOffset: Vector3;
  24163. private _collider;
  24164. private _oldPositionForCollisions;
  24165. private _diffPositionForCollisions;
  24166. /**
  24167. * Gets or sets a collision mask used to mask collisions (default is -1).
  24168. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24169. */
  24170. collisionMask: number;
  24171. /**
  24172. * Gets or sets the current collision group mask (-1 by default).
  24173. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24174. */
  24175. collisionGroup: number;
  24176. /**
  24177. * Defines edge width used when edgesRenderer is enabled
  24178. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24179. */
  24180. edgesWidth: number;
  24181. /**
  24182. * Defines edge color used when edgesRenderer is enabled
  24183. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24184. */
  24185. edgesColor: Color4;
  24186. /** @hidden */
  24187. _edgesRenderer: Nullable<IEdgesRenderer>;
  24188. /** @hidden */
  24189. _masterMesh: Nullable<AbstractMesh>;
  24190. /** @hidden */
  24191. _boundingInfo: Nullable<BoundingInfo>;
  24192. /** @hidden */
  24193. _renderId: number;
  24194. /**
  24195. * Gets or sets the list of subMeshes
  24196. * @see http://doc.babylonjs.com/how_to/multi_materials
  24197. */
  24198. subMeshes: SubMesh[];
  24199. /** @hidden */
  24200. _intersectionsInProgress: AbstractMesh[];
  24201. /** @hidden */
  24202. _unIndexed: boolean;
  24203. /** @hidden */
  24204. _lightSources: Light[];
  24205. /** @hidden */
  24206. readonly _positions: Nullable<Vector3[]>;
  24207. /** @hidden */
  24208. _waitingActions: any;
  24209. /** @hidden */
  24210. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24211. private _skeleton;
  24212. /** @hidden */
  24213. _bonesTransformMatrices: Nullable<Float32Array>;
  24214. /**
  24215. * Gets or sets a skeleton to apply skining transformations
  24216. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24217. */
  24218. skeleton: Nullable<Skeleton>;
  24219. /**
  24220. * An event triggered when the mesh is rebuilt.
  24221. */
  24222. onRebuildObservable: Observable<AbstractMesh>;
  24223. /**
  24224. * Creates a new AbstractMesh
  24225. * @param name defines the name of the mesh
  24226. * @param scene defines the hosting scene
  24227. */
  24228. constructor(name: string, scene?: Nullable<Scene>);
  24229. /**
  24230. * Returns the string "AbstractMesh"
  24231. * @returns "AbstractMesh"
  24232. */
  24233. getClassName(): string;
  24234. /**
  24235. * Gets a string representation of the current mesh
  24236. * @param fullDetails defines a boolean indicating if full details must be included
  24237. * @returns a string representation of the current mesh
  24238. */
  24239. toString(fullDetails?: boolean): string;
  24240. /** @hidden */
  24241. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24242. /** @hidden */
  24243. _rebuild(): void;
  24244. /** @hidden */
  24245. _resyncLightSources(): void;
  24246. /** @hidden */
  24247. _resyncLighSource(light: Light): void;
  24248. /** @hidden */
  24249. _unBindEffect(): void;
  24250. /** @hidden */
  24251. _removeLightSource(light: Light): void;
  24252. private _markSubMeshesAsDirty;
  24253. /** @hidden */
  24254. _markSubMeshesAsLightDirty(): void;
  24255. /** @hidden */
  24256. _markSubMeshesAsAttributesDirty(): void;
  24257. /** @hidden */
  24258. _markSubMeshesAsMiscDirty(): void;
  24259. /**
  24260. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24261. */
  24262. scaling: Vector3;
  24263. /**
  24264. * Returns true if the mesh is blocked. Implemented by child classes
  24265. */
  24266. readonly isBlocked: boolean;
  24267. /**
  24268. * Returns the mesh itself by default. Implemented by child classes
  24269. * @param camera defines the camera to use to pick the right LOD level
  24270. * @returns the currentAbstractMesh
  24271. */
  24272. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24273. /**
  24274. * Returns 0 by default. Implemented by child classes
  24275. * @returns an integer
  24276. */
  24277. getTotalVertices(): number;
  24278. /**
  24279. * Returns a positive integer : the total number of indices in this mesh geometry.
  24280. * @returns the numner of indices or zero if the mesh has no geometry.
  24281. */
  24282. getTotalIndices(): number;
  24283. /**
  24284. * Returns null by default. Implemented by child classes
  24285. * @returns null
  24286. */
  24287. getIndices(): Nullable<IndicesArray>;
  24288. /**
  24289. * Returns the array of the requested vertex data kind. Implemented by child classes
  24290. * @param kind defines the vertex data kind to use
  24291. * @returns null
  24292. */
  24293. getVerticesData(kind: string): Nullable<FloatArray>;
  24294. /**
  24295. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24296. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24297. * Note that a new underlying VertexBuffer object is created each call.
  24298. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24299. * @param kind defines vertex data kind:
  24300. * * VertexBuffer.PositionKind
  24301. * * VertexBuffer.UVKind
  24302. * * VertexBuffer.UV2Kind
  24303. * * VertexBuffer.UV3Kind
  24304. * * VertexBuffer.UV4Kind
  24305. * * VertexBuffer.UV5Kind
  24306. * * VertexBuffer.UV6Kind
  24307. * * VertexBuffer.ColorKind
  24308. * * VertexBuffer.MatricesIndicesKind
  24309. * * VertexBuffer.MatricesIndicesExtraKind
  24310. * * VertexBuffer.MatricesWeightsKind
  24311. * * VertexBuffer.MatricesWeightsExtraKind
  24312. * @param data defines the data source
  24313. * @param updatable defines if the data must be flagged as updatable (or static)
  24314. * @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
  24315. * @returns the current mesh
  24316. */
  24317. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24318. /**
  24319. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24320. * If the mesh has no geometry, it is simply returned as it is.
  24321. * @param kind defines vertex data kind:
  24322. * * VertexBuffer.PositionKind
  24323. * * VertexBuffer.UVKind
  24324. * * VertexBuffer.UV2Kind
  24325. * * VertexBuffer.UV3Kind
  24326. * * VertexBuffer.UV4Kind
  24327. * * VertexBuffer.UV5Kind
  24328. * * VertexBuffer.UV6Kind
  24329. * * VertexBuffer.ColorKind
  24330. * * VertexBuffer.MatricesIndicesKind
  24331. * * VertexBuffer.MatricesIndicesExtraKind
  24332. * * VertexBuffer.MatricesWeightsKind
  24333. * * VertexBuffer.MatricesWeightsExtraKind
  24334. * @param data defines the data source
  24335. * @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
  24336. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24337. * @returns the current mesh
  24338. */
  24339. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24340. /**
  24341. * Sets the mesh indices,
  24342. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24343. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24344. * @param totalVertices Defines the total number of vertices
  24345. * @returns the current mesh
  24346. */
  24347. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24348. /**
  24349. * Gets a boolean indicating if specific vertex data is present
  24350. * @param kind defines the vertex data kind to use
  24351. * @returns true is data kind is present
  24352. */
  24353. isVerticesDataPresent(kind: string): boolean;
  24354. /**
  24355. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24356. * @returns a BoundingInfo
  24357. */
  24358. getBoundingInfo(): BoundingInfo;
  24359. /**
  24360. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24361. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  24362. * @returns the current mesh
  24363. */
  24364. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  24365. /**
  24366. * Overwrite the current bounding info
  24367. * @param boundingInfo defines the new bounding info
  24368. * @returns the current mesh
  24369. */
  24370. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24371. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24372. readonly useBones: boolean;
  24373. /** @hidden */
  24374. _preActivate(): void;
  24375. /** @hidden */
  24376. _preActivateForIntermediateRendering(renderId: number): void;
  24377. /** @hidden */
  24378. _activate(renderId: number): void;
  24379. /**
  24380. * Gets the current world matrix
  24381. * @returns a Matrix
  24382. */
  24383. getWorldMatrix(): Matrix;
  24384. /** @hidden */
  24385. _getWorldMatrixDeterminant(): number;
  24386. /**
  24387. * Perform relative position change from the point of view of behind the front of the mesh.
  24388. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24389. * Supports definition of mesh facing forward or backward
  24390. * @param amountRight defines the distance on the right axis
  24391. * @param amountUp defines the distance on the up axis
  24392. * @param amountForward defines the distance on the forward axis
  24393. * @returns the current mesh
  24394. */
  24395. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24396. /**
  24397. * Calculate relative position change from the point of view of behind the front of the mesh.
  24398. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24399. * Supports definition of mesh facing forward or backward
  24400. * @param amountRight defines the distance on the right axis
  24401. * @param amountUp defines the distance on the up axis
  24402. * @param amountForward defines the distance on the forward axis
  24403. * @returns the new displacement vector
  24404. */
  24405. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24406. /**
  24407. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24408. * Supports definition of mesh facing forward or backward
  24409. * @param flipBack defines the flip
  24410. * @param twirlClockwise defines the twirl
  24411. * @param tiltRight defines the tilt
  24412. * @returns the current mesh
  24413. */
  24414. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24415. /**
  24416. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24417. * Supports definition of mesh facing forward or backward.
  24418. * @param flipBack defines the flip
  24419. * @param twirlClockwise defines the twirl
  24420. * @param tiltRight defines the tilt
  24421. * @returns the new rotation vector
  24422. */
  24423. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24424. /**
  24425. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24426. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24427. * @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
  24428. * @returns the new bounding vectors
  24429. */
  24430. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24431. min: Vector3;
  24432. max: Vector3;
  24433. };
  24434. /**
  24435. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24436. * This means the mesh underlying bounding box and sphere are recomputed.
  24437. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24438. * @returns the current mesh
  24439. */
  24440. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24441. /** @hidden */
  24442. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24443. /** @hidden */
  24444. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24445. /** @hidden */
  24446. _updateBoundingInfo(): AbstractMesh;
  24447. /** @hidden */
  24448. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24449. /** @hidden */
  24450. protected _afterComputeWorldMatrix(): void;
  24451. /**
  24452. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24453. * A mesh is in the frustum if its bounding box intersects the frustum
  24454. * @param frustumPlanes defines the frustum to test
  24455. * @returns true if the mesh is in the frustum planes
  24456. */
  24457. isInFrustum(frustumPlanes: Plane[]): boolean;
  24458. /**
  24459. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24460. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24461. * @param frustumPlanes defines the frustum to test
  24462. * @returns true if the mesh is completely in the frustum planes
  24463. */
  24464. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24465. /**
  24466. * True if the mesh intersects another mesh or a SolidParticle object
  24467. * @param mesh defines a target mesh or SolidParticle to test
  24468. * @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)
  24469. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24470. * @returns true if there is an intersection
  24471. */
  24472. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24473. /**
  24474. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24475. * @param point defines the point to test
  24476. * @returns true if there is an intersection
  24477. */
  24478. intersectsPoint(point: Vector3): boolean;
  24479. /**
  24480. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24481. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24482. */
  24483. checkCollisions: boolean;
  24484. /**
  24485. * Gets Collider object used to compute collisions (not physics)
  24486. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24487. */
  24488. readonly collider: Collider;
  24489. /**
  24490. * Move the mesh using collision engine
  24491. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24492. * @param displacement defines the requested displacement vector
  24493. * @returns the current mesh
  24494. */
  24495. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24496. private _onCollisionPositionChange;
  24497. /** @hidden */
  24498. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24499. /** @hidden */
  24500. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24501. /** @hidden */
  24502. _checkCollision(collider: Collider): AbstractMesh;
  24503. /** @hidden */
  24504. _generatePointsArray(): boolean;
  24505. /**
  24506. * Checks if the passed Ray intersects with the mesh
  24507. * @param ray defines the ray to use
  24508. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24509. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24510. * @returns the picking info
  24511. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24512. */
  24513. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24514. /**
  24515. * Clones the current mesh
  24516. * @param name defines the mesh name
  24517. * @param newParent defines the new mesh parent
  24518. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24519. * @returns the new mesh
  24520. */
  24521. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24522. /**
  24523. * Disposes all the submeshes of the current meshnp
  24524. * @returns the current mesh
  24525. */
  24526. releaseSubMeshes(): AbstractMesh;
  24527. /**
  24528. * Releases resources associated with this abstract mesh.
  24529. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24530. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24531. */
  24532. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24533. /**
  24534. * Adds the passed mesh as a child to the current mesh
  24535. * @param mesh defines the child mesh
  24536. * @returns the current mesh
  24537. */
  24538. addChild(mesh: AbstractMesh): AbstractMesh;
  24539. /**
  24540. * Removes the passed mesh from the current mesh children list
  24541. * @param mesh defines the child mesh
  24542. * @returns the current mesh
  24543. */
  24544. removeChild(mesh: AbstractMesh): AbstractMesh;
  24545. /** @hidden */
  24546. private _initFacetData;
  24547. /**
  24548. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24549. * This method can be called within the render loop.
  24550. * 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
  24551. * @returns the current mesh
  24552. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24553. */
  24554. updateFacetData(): AbstractMesh;
  24555. /**
  24556. * Returns the facetLocalNormals array.
  24557. * The normals are expressed in the mesh local spac
  24558. * @returns an array of Vector3
  24559. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24560. */
  24561. getFacetLocalNormals(): Vector3[];
  24562. /**
  24563. * Returns the facetLocalPositions array.
  24564. * The facet positions are expressed in the mesh local space
  24565. * @returns an array of Vector3
  24566. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24567. */
  24568. getFacetLocalPositions(): Vector3[];
  24569. /**
  24570. * Returns the facetLocalPartioning array
  24571. * @returns an array of array of numbers
  24572. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24573. */
  24574. getFacetLocalPartitioning(): number[][];
  24575. /**
  24576. * Returns the i-th facet position in the world system.
  24577. * This method allocates a new Vector3 per call
  24578. * @param i defines the facet index
  24579. * @returns a new Vector3
  24580. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24581. */
  24582. getFacetPosition(i: number): Vector3;
  24583. /**
  24584. * Sets the reference Vector3 with the i-th facet position in the world system
  24585. * @param i defines the facet index
  24586. * @param ref defines the target vector
  24587. * @returns the current mesh
  24588. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24589. */
  24590. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24591. /**
  24592. * Returns the i-th facet normal in the world system.
  24593. * This method allocates a new Vector3 per call
  24594. * @param i defines the facet index
  24595. * @returns a new Vector3
  24596. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24597. */
  24598. getFacetNormal(i: number): Vector3;
  24599. /**
  24600. * Sets the reference Vector3 with the i-th facet normal in the world system
  24601. * @param i defines the facet index
  24602. * @param ref defines the target vector
  24603. * @returns the current mesh
  24604. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24605. */
  24606. getFacetNormalToRef(i: number, ref: Vector3): this;
  24607. /**
  24608. * 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)
  24609. * @param x defines x coordinate
  24610. * @param y defines y coordinate
  24611. * @param z defines z coordinate
  24612. * @returns the array of facet indexes
  24613. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24614. */
  24615. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24616. /**
  24617. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24618. * @param projected sets as the (x,y,z) world projection on the facet
  24619. * @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
  24620. * @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
  24621. * @param x defines x coordinate
  24622. * @param y defines y coordinate
  24623. * @param z defines z coordinate
  24624. * @returns the face index if found (or null instead)
  24625. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24626. */
  24627. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24628. /**
  24629. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24630. * @param projected sets as the (x,y,z) local projection on the facet
  24631. * @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
  24632. * @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
  24633. * @param x defines x coordinate
  24634. * @param y defines y coordinate
  24635. * @param z defines z coordinate
  24636. * @returns the face index if found (or null instead)
  24637. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24638. */
  24639. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24640. /**
  24641. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24642. * @returns the parameters
  24643. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24644. */
  24645. getFacetDataParameters(): any;
  24646. /**
  24647. * Disables the feature FacetData and frees the related memory
  24648. * @returns the current mesh
  24649. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24650. */
  24651. disableFacetData(): AbstractMesh;
  24652. /**
  24653. * Updates the AbstractMesh indices array
  24654. * @param indices defines the data source
  24655. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24656. * @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)
  24657. * @returns the current mesh
  24658. */
  24659. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24660. /**
  24661. * Creates new normals data for the mesh
  24662. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24663. * @returns the current mesh
  24664. */
  24665. createNormals(updatable: boolean): AbstractMesh;
  24666. /**
  24667. * Align the mesh with a normal
  24668. * @param normal defines the normal to use
  24669. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24670. * @returns the current mesh
  24671. */
  24672. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24673. /** @hidden */
  24674. _checkOcclusionQuery(): boolean;
  24675. }
  24676. }
  24677. declare module "babylonjs/Actions/actionEvent" {
  24678. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24679. import { Nullable } from "babylonjs/types";
  24680. import { Sprite } from "babylonjs/Sprites/sprite";
  24681. import { Scene } from "babylonjs/scene";
  24682. import { Vector2 } from "babylonjs/Maths/math";
  24683. /**
  24684. * Interface used to define ActionEvent
  24685. */
  24686. export interface IActionEvent {
  24687. /** The mesh or sprite that triggered the action */
  24688. source: any;
  24689. /** The X mouse cursor position at the time of the event */
  24690. pointerX: number;
  24691. /** The Y mouse cursor position at the time of the event */
  24692. pointerY: number;
  24693. /** The mesh that is currently pointed at (can be null) */
  24694. meshUnderPointer: Nullable<AbstractMesh>;
  24695. /** the original (browser) event that triggered the ActionEvent */
  24696. sourceEvent?: any;
  24697. /** additional data for the event */
  24698. additionalData?: any;
  24699. }
  24700. /**
  24701. * ActionEvent is the event being sent when an action is triggered.
  24702. */
  24703. export class ActionEvent implements IActionEvent {
  24704. /** The mesh or sprite that triggered the action */
  24705. source: any;
  24706. /** The X mouse cursor position at the time of the event */
  24707. pointerX: number;
  24708. /** The Y mouse cursor position at the time of the event */
  24709. pointerY: number;
  24710. /** The mesh that is currently pointed at (can be null) */
  24711. meshUnderPointer: Nullable<AbstractMesh>;
  24712. /** the original (browser) event that triggered the ActionEvent */
  24713. sourceEvent?: any;
  24714. /** additional data for the event */
  24715. additionalData?: any;
  24716. /**
  24717. * Creates a new ActionEvent
  24718. * @param source The mesh or sprite that triggered the action
  24719. * @param pointerX The X mouse cursor position at the time of the event
  24720. * @param pointerY The Y mouse cursor position at the time of the event
  24721. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  24722. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  24723. * @param additionalData additional data for the event
  24724. */
  24725. constructor(
  24726. /** The mesh or sprite that triggered the action */
  24727. source: any,
  24728. /** The X mouse cursor position at the time of the event */
  24729. pointerX: number,
  24730. /** The Y mouse cursor position at the time of the event */
  24731. pointerY: number,
  24732. /** The mesh that is currently pointed at (can be null) */
  24733. meshUnderPointer: Nullable<AbstractMesh>,
  24734. /** the original (browser) event that triggered the ActionEvent */
  24735. sourceEvent?: any,
  24736. /** additional data for the event */
  24737. additionalData?: any);
  24738. /**
  24739. * Helper function to auto-create an ActionEvent from a source mesh.
  24740. * @param source The source mesh that triggered the event
  24741. * @param evt The original (browser) event
  24742. * @param additionalData additional data for the event
  24743. * @returns the new ActionEvent
  24744. */
  24745. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  24746. /**
  24747. * Helper function to auto-create an ActionEvent from a source sprite
  24748. * @param source The source sprite that triggered the event
  24749. * @param scene Scene associated with the sprite
  24750. * @param evt The original (browser) event
  24751. * @param additionalData additional data for the event
  24752. * @returns the new ActionEvent
  24753. */
  24754. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  24755. /**
  24756. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  24757. * @param scene the scene where the event occurred
  24758. * @param evt The original (browser) event
  24759. * @returns the new ActionEvent
  24760. */
  24761. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  24762. /**
  24763. * Helper function to auto-create an ActionEvent from a primitive
  24764. * @param prim defines the target primitive
  24765. * @param pointerPos defines the pointer position
  24766. * @param evt The original (browser) event
  24767. * @param additionalData additional data for the event
  24768. * @returns the new ActionEvent
  24769. */
  24770. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  24771. }
  24772. }
  24773. declare module "babylonjs/Actions/abstractActionManager" {
  24774. import { IDisposable } from "babylonjs/scene";
  24775. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  24776. import { IAction } from "babylonjs/Actions/action";
  24777. import { Nullable } from "babylonjs/types";
  24778. /**
  24779. * Abstract class used to decouple action Manager from scene and meshes.
  24780. * Do not instantiate.
  24781. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24782. */
  24783. export abstract class AbstractActionManager implements IDisposable {
  24784. /** Gets the list of active triggers */
  24785. static Triggers: {
  24786. [key: string]: number;
  24787. };
  24788. /** Gets the cursor to use when hovering items */
  24789. hoverCursor: string;
  24790. /** Gets the list of actions */
  24791. actions: IAction[];
  24792. /**
  24793. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  24794. */
  24795. isRecursive: boolean;
  24796. /**
  24797. * Releases all associated resources
  24798. */
  24799. abstract dispose(): void;
  24800. /**
  24801. * Does this action manager has pointer triggers
  24802. */
  24803. abstract readonly hasPointerTriggers: boolean;
  24804. /**
  24805. * Does this action manager has pick triggers
  24806. */
  24807. abstract readonly hasPickTriggers: boolean;
  24808. /**
  24809. * Process a specific trigger
  24810. * @param trigger defines the trigger to process
  24811. * @param evt defines the event details to be processed
  24812. */
  24813. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  24814. /**
  24815. * Does this action manager handles actions of any of the given triggers
  24816. * @param triggers defines the triggers to be tested
  24817. * @return a boolean indicating whether one (or more) of the triggers is handled
  24818. */
  24819. abstract hasSpecificTriggers(triggers: number[]): boolean;
  24820. /**
  24821. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  24822. * speed.
  24823. * @param triggerA defines the trigger to be tested
  24824. * @param triggerB defines the trigger to be tested
  24825. * @return a boolean indicating whether one (or more) of the triggers is handled
  24826. */
  24827. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  24828. /**
  24829. * Does this action manager handles actions of a given trigger
  24830. * @param trigger defines the trigger to be tested
  24831. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  24832. * @return whether the trigger is handled
  24833. */
  24834. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  24835. /**
  24836. * Serialize this manager to a JSON object
  24837. * @param name defines the property name to store this manager
  24838. * @returns a JSON representation of this manager
  24839. */
  24840. abstract serialize(name: string): any;
  24841. /**
  24842. * Registers an action to this action manager
  24843. * @param action defines the action to be registered
  24844. * @return the action amended (prepared) after registration
  24845. */
  24846. abstract registerAction(action: IAction): Nullable<IAction>;
  24847. /**
  24848. * Unregisters an action to this action manager
  24849. * @param action defines the action to be unregistered
  24850. * @return a boolean indicating whether the action has been unregistered
  24851. */
  24852. abstract unregisterAction(action: IAction): Boolean;
  24853. /**
  24854. * Does exist one action manager with at least one trigger
  24855. **/
  24856. static readonly HasTriggers: boolean;
  24857. /**
  24858. * Does exist one action manager with at least one pick trigger
  24859. **/
  24860. static readonly HasPickTriggers: boolean;
  24861. /**
  24862. * Does exist one action manager that handles actions of a given trigger
  24863. * @param trigger defines the trigger to be tested
  24864. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  24865. **/
  24866. static HasSpecificTrigger(trigger: number): boolean;
  24867. }
  24868. }
  24869. declare module "babylonjs/node" {
  24870. import { Scene } from "babylonjs/scene";
  24871. import { Nullable } from "babylonjs/types";
  24872. import { Matrix } from "babylonjs/Maths/math";
  24873. import { Engine } from "babylonjs/Engines/engine";
  24874. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  24875. import { Observable } from "babylonjs/Misc/observable";
  24876. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24877. import { Animatable } from "babylonjs/Animations/animatable";
  24878. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  24879. import { Animation } from "babylonjs/Animations/animation";
  24880. import { AnimationRange } from "babylonjs/Animations/animationRange";
  24881. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24882. /**
  24883. * Defines how a node can be built from a string name.
  24884. */
  24885. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24886. /**
  24887. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24888. */
  24889. export class Node implements IBehaviorAware<Node> {
  24890. /** @hidden */
  24891. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  24892. private static _NodeConstructors;
  24893. /**
  24894. * Add a new node constructor
  24895. * @param type defines the type name of the node to construct
  24896. * @param constructorFunc defines the constructor function
  24897. */
  24898. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24899. /**
  24900. * Returns a node constructor based on type name
  24901. * @param type defines the type name
  24902. * @param name defines the new node name
  24903. * @param scene defines the hosting scene
  24904. * @param options defines optional options to transmit to constructors
  24905. * @returns the new constructor or null
  24906. */
  24907. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24908. /**
  24909. * Gets or sets the name of the node
  24910. */
  24911. name: string;
  24912. /**
  24913. * Gets or sets the id of the node
  24914. */
  24915. id: string;
  24916. /**
  24917. * Gets or sets the unique id of the node
  24918. */
  24919. uniqueId: number;
  24920. /**
  24921. * Gets or sets a string used to store user defined state for the node
  24922. */
  24923. state: string;
  24924. /**
  24925. * Gets or sets an object used to store user defined information for the node
  24926. */
  24927. metadata: any;
  24928. /**
  24929. * For internal use only. Please do not use.
  24930. */
  24931. reservedDataStore: any;
  24932. /**
  24933. * Gets or sets a boolean used to define if the node must be serialized
  24934. */
  24935. doNotSerialize: boolean;
  24936. /** @hidden */
  24937. _isDisposed: boolean;
  24938. /**
  24939. * Gets a list of Animations associated with the node
  24940. */
  24941. animations: import("babylonjs/Animations/animation").Animation[];
  24942. protected _ranges: {
  24943. [name: string]: Nullable<AnimationRange>;
  24944. };
  24945. /**
  24946. * Callback raised when the node is ready to be used
  24947. */
  24948. onReady: (node: Node) => void;
  24949. private _isEnabled;
  24950. private _isParentEnabled;
  24951. private _isReady;
  24952. /** @hidden */
  24953. _currentRenderId: number;
  24954. private _parentRenderId;
  24955. protected _childRenderId: number;
  24956. /** @hidden */
  24957. _waitingParentId: Nullable<string>;
  24958. /** @hidden */
  24959. _scene: Scene;
  24960. /** @hidden */
  24961. _cache: any;
  24962. private _parentNode;
  24963. private _children;
  24964. /** @hidden */
  24965. _worldMatrix: Matrix;
  24966. /** @hidden */
  24967. _worldMatrixDeterminant: number;
  24968. /** @hidden */
  24969. private _sceneRootNodesIndex;
  24970. /**
  24971. * Gets a boolean indicating if the node has been disposed
  24972. * @returns true if the node was disposed
  24973. */
  24974. isDisposed(): boolean;
  24975. /**
  24976. * Gets or sets the parent of the node
  24977. */
  24978. parent: Nullable<Node>;
  24979. private addToSceneRootNodes;
  24980. private removeFromSceneRootNodes;
  24981. private _animationPropertiesOverride;
  24982. /**
  24983. * Gets or sets the animation properties override
  24984. */
  24985. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24986. /**
  24987. * Gets a string idenfifying the name of the class
  24988. * @returns "Node" string
  24989. */
  24990. getClassName(): string;
  24991. /** @hidden */
  24992. readonly _isNode: boolean;
  24993. /**
  24994. * An event triggered when the mesh is disposed
  24995. */
  24996. onDisposeObservable: Observable<Node>;
  24997. private _onDisposeObserver;
  24998. /**
  24999. * Sets a callback that will be raised when the node will be disposed
  25000. */
  25001. onDispose: () => void;
  25002. /**
  25003. * Creates a new Node
  25004. * @param name the name and id to be given to this node
  25005. * @param scene the scene this node will be added to
  25006. * @param addToRootNodes the node will be added to scene.rootNodes
  25007. */
  25008. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25009. /**
  25010. * Gets the scene of the node
  25011. * @returns a scene
  25012. */
  25013. getScene(): Scene;
  25014. /**
  25015. * Gets the engine of the node
  25016. * @returns a Engine
  25017. */
  25018. getEngine(): Engine;
  25019. private _behaviors;
  25020. /**
  25021. * Attach a behavior to the node
  25022. * @see http://doc.babylonjs.com/features/behaviour
  25023. * @param behavior defines the behavior to attach
  25024. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25025. * @returns the current Node
  25026. */
  25027. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25028. /**
  25029. * Remove an attached behavior
  25030. * @see http://doc.babylonjs.com/features/behaviour
  25031. * @param behavior defines the behavior to attach
  25032. * @returns the current Node
  25033. */
  25034. removeBehavior(behavior: Behavior<Node>): Node;
  25035. /**
  25036. * Gets the list of attached behaviors
  25037. * @see http://doc.babylonjs.com/features/behaviour
  25038. */
  25039. readonly behaviors: Behavior<Node>[];
  25040. /**
  25041. * Gets an attached behavior by name
  25042. * @param name defines the name of the behavior to look for
  25043. * @see http://doc.babylonjs.com/features/behaviour
  25044. * @returns null if behavior was not found else the requested behavior
  25045. */
  25046. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25047. /**
  25048. * Returns the latest update of the World matrix
  25049. * @returns a Matrix
  25050. */
  25051. getWorldMatrix(): Matrix;
  25052. /** @hidden */
  25053. _getWorldMatrixDeterminant(): number;
  25054. /**
  25055. * Returns directly the latest state of the mesh World matrix.
  25056. * A Matrix is returned.
  25057. */
  25058. readonly worldMatrixFromCache: Matrix;
  25059. /** @hidden */
  25060. _initCache(): void;
  25061. /** @hidden */
  25062. updateCache(force?: boolean): void;
  25063. /** @hidden */
  25064. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25065. /** @hidden */
  25066. _updateCache(ignoreParentClass?: boolean): void;
  25067. /** @hidden */
  25068. _isSynchronized(): boolean;
  25069. /** @hidden */
  25070. _markSyncedWithParent(): void;
  25071. /** @hidden */
  25072. isSynchronizedWithParent(): boolean;
  25073. /** @hidden */
  25074. isSynchronized(): boolean;
  25075. /**
  25076. * Is this node ready to be used/rendered
  25077. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25078. * @return true if the node is ready
  25079. */
  25080. isReady(completeCheck?: boolean): boolean;
  25081. /**
  25082. * Is this node enabled?
  25083. * 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
  25084. * @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
  25085. * @return whether this node (and its parent) is enabled
  25086. */
  25087. isEnabled(checkAncestors?: boolean): boolean;
  25088. /** @hidden */
  25089. protected _syncParentEnabledState(): void;
  25090. /**
  25091. * Set the enabled state of this node
  25092. * @param value defines the new enabled state
  25093. */
  25094. setEnabled(value: boolean): void;
  25095. /**
  25096. * Is this node a descendant of the given node?
  25097. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25098. * @param ancestor defines the parent node to inspect
  25099. * @returns a boolean indicating if this node is a descendant of the given node
  25100. */
  25101. isDescendantOf(ancestor: Node): boolean;
  25102. /** @hidden */
  25103. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25104. /**
  25105. * Will return all nodes that have this node as ascendant
  25106. * @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
  25107. * @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
  25108. * @return all children nodes of all types
  25109. */
  25110. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25111. /**
  25112. * Get all child-meshes of this node
  25113. * @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)
  25114. * @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
  25115. * @returns an array of AbstractMesh
  25116. */
  25117. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25118. /**
  25119. * Get all direct children of this node
  25120. * @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
  25121. * @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)
  25122. * @returns an array of Node
  25123. */
  25124. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25125. /** @hidden */
  25126. _setReady(state: boolean): void;
  25127. /**
  25128. * Get an animation by name
  25129. * @param name defines the name of the animation to look for
  25130. * @returns null if not found else the requested animation
  25131. */
  25132. getAnimationByName(name: string): Nullable<Animation>;
  25133. /**
  25134. * Creates an animation range for this node
  25135. * @param name defines the name of the range
  25136. * @param from defines the starting key
  25137. * @param to defines the end key
  25138. */
  25139. createAnimationRange(name: string, from: number, to: number): void;
  25140. /**
  25141. * Delete a specific animation range
  25142. * @param name defines the name of the range to delete
  25143. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25144. */
  25145. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25146. /**
  25147. * Get an animation range by name
  25148. * @param name defines the name of the animation range to look for
  25149. * @returns null if not found else the requested animation range
  25150. */
  25151. getAnimationRange(name: string): Nullable<AnimationRange>;
  25152. /**
  25153. * Gets the list of all animation ranges defined on this node
  25154. * @returns an array
  25155. */
  25156. getAnimationRanges(): Nullable<AnimationRange>[];
  25157. /**
  25158. * Will start the animation sequence
  25159. * @param name defines the range frames for animation sequence
  25160. * @param loop defines if the animation should loop (false by default)
  25161. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25162. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25163. * @returns the object created for this animation. If range does not exist, it will return null
  25164. */
  25165. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25166. /**
  25167. * Serialize animation ranges into a JSON compatible object
  25168. * @returns serialization object
  25169. */
  25170. serializeAnimationRanges(): any;
  25171. /**
  25172. * Computes the world matrix of the node
  25173. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25174. * @returns the world matrix
  25175. */
  25176. computeWorldMatrix(force?: boolean): Matrix;
  25177. /**
  25178. * Releases resources associated with this node.
  25179. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25180. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25181. */
  25182. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25183. /**
  25184. * Parse animation range data from a serialization object and store them into a given node
  25185. * @param node defines where to store the animation ranges
  25186. * @param parsedNode defines the serialization object to read data from
  25187. * @param scene defines the hosting scene
  25188. */
  25189. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25190. }
  25191. }
  25192. declare module "babylonjs/Animations/animation" {
  25193. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  25194. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  25195. import { Nullable } from "babylonjs/types";
  25196. import { Scene } from "babylonjs/scene";
  25197. import { IAnimatable } from "babylonjs/Misc/tools";
  25198. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  25199. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25200. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  25201. import { Node } from "babylonjs/node";
  25202. import { Animatable } from "babylonjs/Animations/animatable";
  25203. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  25204. /**
  25205. * Class used to store any kind of animation
  25206. */
  25207. export class Animation {
  25208. /**Name of the animation */
  25209. name: string;
  25210. /**Property to animate */
  25211. targetProperty: string;
  25212. /**The frames per second of the animation */
  25213. framePerSecond: number;
  25214. /**The data type of the animation */
  25215. dataType: number;
  25216. /**The loop mode of the animation */
  25217. loopMode?: number | undefined;
  25218. /**Specifies if blending should be enabled */
  25219. enableBlending?: boolean | undefined;
  25220. /**
  25221. * Use matrix interpolation instead of using direct key value when animating matrices
  25222. */
  25223. static AllowMatricesInterpolation: boolean;
  25224. /**
  25225. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25226. */
  25227. static AllowMatrixDecomposeForInterpolation: boolean;
  25228. /**
  25229. * Stores the key frames of the animation
  25230. */
  25231. private _keys;
  25232. /**
  25233. * Stores the easing function of the animation
  25234. */
  25235. private _easingFunction;
  25236. /**
  25237. * @hidden Internal use only
  25238. */
  25239. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  25240. /**
  25241. * The set of event that will be linked to this animation
  25242. */
  25243. private _events;
  25244. /**
  25245. * Stores an array of target property paths
  25246. */
  25247. targetPropertyPath: string[];
  25248. /**
  25249. * Stores the blending speed of the animation
  25250. */
  25251. blendingSpeed: number;
  25252. /**
  25253. * Stores the animation ranges for the animation
  25254. */
  25255. private _ranges;
  25256. /**
  25257. * @hidden Internal use
  25258. */
  25259. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25260. /**
  25261. * Sets up an animation
  25262. * @param property The property to animate
  25263. * @param animationType The animation type to apply
  25264. * @param framePerSecond The frames per second of the animation
  25265. * @param easingFunction The easing function used in the animation
  25266. * @returns The created animation
  25267. */
  25268. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25269. /**
  25270. * Create and start an animation on a node
  25271. * @param name defines the name of the global animation that will be run on all nodes
  25272. * @param node defines the root node where the animation will take place
  25273. * @param targetProperty defines property to animate
  25274. * @param framePerSecond defines the number of frame per second yo use
  25275. * @param totalFrame defines the number of frames in total
  25276. * @param from defines the initial value
  25277. * @param to defines the final value
  25278. * @param loopMode defines which loop mode you want to use (off by default)
  25279. * @param easingFunction defines the easing function to use (linear by default)
  25280. * @param onAnimationEnd defines the callback to call when animation end
  25281. * @returns the animatable created for this animation
  25282. */
  25283. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25284. /**
  25285. * Create and start an animation on a node and its descendants
  25286. * @param name defines the name of the global animation that will be run on all nodes
  25287. * @param node defines the root node where the animation will take place
  25288. * @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
  25289. * @param targetProperty defines property to animate
  25290. * @param framePerSecond defines the number of frame per second to use
  25291. * @param totalFrame defines the number of frames in total
  25292. * @param from defines the initial value
  25293. * @param to defines the final value
  25294. * @param loopMode defines which loop mode you want to use (off by default)
  25295. * @param easingFunction defines the easing function to use (linear by default)
  25296. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25297. * @returns the list of animatables created for all nodes
  25298. * @example https://www.babylonjs-playground.com/#MH0VLI
  25299. */
  25300. 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[]>;
  25301. /**
  25302. * Creates a new animation, merges it with the existing animations and starts it
  25303. * @param name Name of the animation
  25304. * @param node Node which contains the scene that begins the animations
  25305. * @param targetProperty Specifies which property to animate
  25306. * @param framePerSecond The frames per second of the animation
  25307. * @param totalFrame The total number of frames
  25308. * @param from The frame at the beginning of the animation
  25309. * @param to The frame at the end of the animation
  25310. * @param loopMode Specifies the loop mode of the animation
  25311. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25312. * @param onAnimationEnd Callback to run once the animation is complete
  25313. * @returns Nullable animation
  25314. */
  25315. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25316. /**
  25317. * Transition property of an host to the target Value
  25318. * @param property The property to transition
  25319. * @param targetValue The target Value of the property
  25320. * @param host The object where the property to animate belongs
  25321. * @param scene Scene used to run the animation
  25322. * @param frameRate Framerate (in frame/s) to use
  25323. * @param transition The transition type we want to use
  25324. * @param duration The duration of the animation, in milliseconds
  25325. * @param onAnimationEnd Callback trigger at the end of the animation
  25326. * @returns Nullable animation
  25327. */
  25328. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25329. /**
  25330. * Return the array of runtime animations currently using this animation
  25331. */
  25332. readonly runtimeAnimations: RuntimeAnimation[];
  25333. /**
  25334. * Specifies if any of the runtime animations are currently running
  25335. */
  25336. readonly hasRunningRuntimeAnimations: boolean;
  25337. /**
  25338. * Initializes the animation
  25339. * @param name Name of the animation
  25340. * @param targetProperty Property to animate
  25341. * @param framePerSecond The frames per second of the animation
  25342. * @param dataType The data type of the animation
  25343. * @param loopMode The loop mode of the animation
  25344. * @param enableBlending Specifies if blending should be enabled
  25345. */
  25346. constructor(
  25347. /**Name of the animation */
  25348. name: string,
  25349. /**Property to animate */
  25350. targetProperty: string,
  25351. /**The frames per second of the animation */
  25352. framePerSecond: number,
  25353. /**The data type of the animation */
  25354. dataType: number,
  25355. /**The loop mode of the animation */
  25356. loopMode?: number | undefined,
  25357. /**Specifies if blending should be enabled */
  25358. enableBlending?: boolean | undefined);
  25359. /**
  25360. * Converts the animation to a string
  25361. * @param fullDetails support for multiple levels of logging within scene loading
  25362. * @returns String form of the animation
  25363. */
  25364. toString(fullDetails?: boolean): string;
  25365. /**
  25366. * Add an event to this animation
  25367. * @param event Event to add
  25368. */
  25369. addEvent(event: AnimationEvent): void;
  25370. /**
  25371. * Remove all events found at the given frame
  25372. * @param frame The frame to remove events from
  25373. */
  25374. removeEvents(frame: number): void;
  25375. /**
  25376. * Retrieves all the events from the animation
  25377. * @returns Events from the animation
  25378. */
  25379. getEvents(): AnimationEvent[];
  25380. /**
  25381. * Creates an animation range
  25382. * @param name Name of the animation range
  25383. * @param from Starting frame of the animation range
  25384. * @param to Ending frame of the animation
  25385. */
  25386. createRange(name: string, from: number, to: number): void;
  25387. /**
  25388. * Deletes an animation range by name
  25389. * @param name Name of the animation range to delete
  25390. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25391. */
  25392. deleteRange(name: string, deleteFrames?: boolean): void;
  25393. /**
  25394. * Gets the animation range by name, or null if not defined
  25395. * @param name Name of the animation range
  25396. * @returns Nullable animation range
  25397. */
  25398. getRange(name: string): Nullable<AnimationRange>;
  25399. /**
  25400. * Gets the key frames from the animation
  25401. * @returns The key frames of the animation
  25402. */
  25403. getKeys(): Array<IAnimationKey>;
  25404. /**
  25405. * Gets the highest frame rate of the animation
  25406. * @returns Highest frame rate of the animation
  25407. */
  25408. getHighestFrame(): number;
  25409. /**
  25410. * Gets the easing function of the animation
  25411. * @returns Easing function of the animation
  25412. */
  25413. getEasingFunction(): IEasingFunction;
  25414. /**
  25415. * Sets the easing function of the animation
  25416. * @param easingFunction A custom mathematical formula for animation
  25417. */
  25418. setEasingFunction(easingFunction: EasingFunction): void;
  25419. /**
  25420. * Interpolates a scalar 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 scalar value
  25425. */
  25426. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25427. /**
  25428. * Interpolates a scalar cubically
  25429. * @param startValue Start value of the animation curve
  25430. * @param outTangent End tangent of the animation
  25431. * @param endValue End value of the animation curve
  25432. * @param inTangent Start tangent of the animation curve
  25433. * @param gradient Scalar amount to interpolate
  25434. * @returns Interpolated scalar value
  25435. */
  25436. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25437. /**
  25438. * Interpolates a quaternion using a spherical linear interpolation
  25439. * @param startValue Start value of the animation curve
  25440. * @param endValue End value of the animation curve
  25441. * @param gradient Scalar amount to interpolate
  25442. * @returns Interpolated quaternion value
  25443. */
  25444. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25445. /**
  25446. * Interpolates a quaternion cubically
  25447. * @param startValue Start value of the animation curve
  25448. * @param outTangent End tangent of the animation curve
  25449. * @param endValue End value of the animation curve
  25450. * @param inTangent Start tangent of the animation curve
  25451. * @param gradient Scalar amount to interpolate
  25452. * @returns Interpolated quaternion value
  25453. */
  25454. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25455. /**
  25456. * Interpolates a Vector3 linearl
  25457. * @param startValue Start value of the animation curve
  25458. * @param endValue End value of the animation curve
  25459. * @param gradient Scalar amount to interpolate
  25460. * @returns Interpolated scalar value
  25461. */
  25462. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25463. /**
  25464. * Interpolates a Vector3 cubically
  25465. * @param startValue Start value of the animation curve
  25466. * @param outTangent End tangent of the animation
  25467. * @param endValue End value of the animation curve
  25468. * @param inTangent Start tangent of the animation curve
  25469. * @param gradient Scalar amount to interpolate
  25470. * @returns InterpolatedVector3 value
  25471. */
  25472. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25473. /**
  25474. * Interpolates a Vector2 linearly
  25475. * @param startValue Start value of the animation curve
  25476. * @param endValue End value of the animation curve
  25477. * @param gradient Scalar amount to interpolate
  25478. * @returns Interpolated Vector2 value
  25479. */
  25480. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25481. /**
  25482. * Interpolates a Vector2 cubically
  25483. * @param startValue Start value of the animation curve
  25484. * @param outTangent End tangent of the animation
  25485. * @param endValue End value of the animation curve
  25486. * @param inTangent Start tangent of the animation curve
  25487. * @param gradient Scalar amount to interpolate
  25488. * @returns Interpolated Vector2 value
  25489. */
  25490. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25491. /**
  25492. * Interpolates a size linearly
  25493. * @param startValue Start value of the animation curve
  25494. * @param endValue End value of the animation curve
  25495. * @param gradient Scalar amount to interpolate
  25496. * @returns Interpolated Size value
  25497. */
  25498. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25499. /**
  25500. * Interpolates a Color3 linearly
  25501. * @param startValue Start value of the animation curve
  25502. * @param endValue End value of the animation curve
  25503. * @param gradient Scalar amount to interpolate
  25504. * @returns Interpolated Color3 value
  25505. */
  25506. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25507. /**
  25508. * @hidden Internal use only
  25509. */
  25510. _getKeyValue(value: any): any;
  25511. /**
  25512. * @hidden Internal use only
  25513. */
  25514. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  25515. /**
  25516. * Defines the function to use to interpolate matrices
  25517. * @param startValue defines the start matrix
  25518. * @param endValue defines the end matrix
  25519. * @param gradient defines the gradient between both matrices
  25520. * @param result defines an optional target matrix where to store the interpolation
  25521. * @returns the interpolated matrix
  25522. */
  25523. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25524. /**
  25525. * Makes a copy of the animation
  25526. * @returns Cloned animation
  25527. */
  25528. clone(): Animation;
  25529. /**
  25530. * Sets the key frames of the animation
  25531. * @param values The animation key frames to set
  25532. */
  25533. setKeys(values: Array<IAnimationKey>): void;
  25534. /**
  25535. * Serializes the animation to an object
  25536. * @returns Serialized object
  25537. */
  25538. serialize(): any;
  25539. /**
  25540. * Float animation type
  25541. */
  25542. private static _ANIMATIONTYPE_FLOAT;
  25543. /**
  25544. * Vector3 animation type
  25545. */
  25546. private static _ANIMATIONTYPE_VECTOR3;
  25547. /**
  25548. * Quaternion animation type
  25549. */
  25550. private static _ANIMATIONTYPE_QUATERNION;
  25551. /**
  25552. * Matrix animation type
  25553. */
  25554. private static _ANIMATIONTYPE_MATRIX;
  25555. /**
  25556. * Color3 animation type
  25557. */
  25558. private static _ANIMATIONTYPE_COLOR3;
  25559. /**
  25560. * Vector2 animation type
  25561. */
  25562. private static _ANIMATIONTYPE_VECTOR2;
  25563. /**
  25564. * Size animation type
  25565. */
  25566. private static _ANIMATIONTYPE_SIZE;
  25567. /**
  25568. * Relative Loop Mode
  25569. */
  25570. private static _ANIMATIONLOOPMODE_RELATIVE;
  25571. /**
  25572. * Cycle Loop Mode
  25573. */
  25574. private static _ANIMATIONLOOPMODE_CYCLE;
  25575. /**
  25576. * Constant Loop Mode
  25577. */
  25578. private static _ANIMATIONLOOPMODE_CONSTANT;
  25579. /**
  25580. * Get the float animation type
  25581. */
  25582. static readonly ANIMATIONTYPE_FLOAT: number;
  25583. /**
  25584. * Get the Vector3 animation type
  25585. */
  25586. static readonly ANIMATIONTYPE_VECTOR3: number;
  25587. /**
  25588. * Get the Vector2 animation type
  25589. */
  25590. static readonly ANIMATIONTYPE_VECTOR2: number;
  25591. /**
  25592. * Get the Size animation type
  25593. */
  25594. static readonly ANIMATIONTYPE_SIZE: number;
  25595. /**
  25596. * Get the Quaternion animation type
  25597. */
  25598. static readonly ANIMATIONTYPE_QUATERNION: number;
  25599. /**
  25600. * Get the Matrix animation type
  25601. */
  25602. static readonly ANIMATIONTYPE_MATRIX: number;
  25603. /**
  25604. * Get the Color3 animation type
  25605. */
  25606. static readonly ANIMATIONTYPE_COLOR3: number;
  25607. /**
  25608. * Get the Relative Loop Mode
  25609. */
  25610. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25611. /**
  25612. * Get the Cycle Loop Mode
  25613. */
  25614. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25615. /**
  25616. * Get the Constant Loop Mode
  25617. */
  25618. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25619. /** @hidden */
  25620. static _UniversalLerp(left: any, right: any, amount: number): any;
  25621. /**
  25622. * Parses an animation object and creates an animation
  25623. * @param parsedAnimation Parsed animation object
  25624. * @returns Animation object
  25625. */
  25626. static Parse(parsedAnimation: any): Animation;
  25627. /**
  25628. * Appends the serialized animations from the source animations
  25629. * @param source Source containing the animations
  25630. * @param destination Target to store the animations
  25631. */
  25632. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25633. }
  25634. }
  25635. declare module "babylonjs/Materials/Textures/baseTexture" {
  25636. import { Observable } from "babylonjs/Misc/observable";
  25637. import { IAnimatable } from "babylonjs/Misc/tools";
  25638. import { Nullable } from "babylonjs/types";
  25639. import { Scene } from "babylonjs/scene";
  25640. import { Matrix, ISize } from "babylonjs/Maths/math";
  25641. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  25642. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  25643. /**
  25644. * Base class of all the textures in babylon.
  25645. * It groups all the common properties the materials, post process, lights... might need
  25646. * in order to make a correct use of the texture.
  25647. */
  25648. export class BaseTexture implements IAnimatable {
  25649. /**
  25650. * Default anisotropic filtering level for the application.
  25651. * It is set to 4 as a good tradeoff between perf and quality.
  25652. */
  25653. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25654. /**
  25655. * Gets or sets the unique id of the texture
  25656. */
  25657. uniqueId: number;
  25658. /**
  25659. * Define the name of the texture.
  25660. */
  25661. name: string;
  25662. /**
  25663. * Gets or sets an object used to store user defined information.
  25664. */
  25665. metadata: any;
  25666. /**
  25667. * For internal use only. Please do not use.
  25668. */
  25669. reservedDataStore: any;
  25670. private _hasAlpha;
  25671. /**
  25672. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25673. */
  25674. hasAlpha: boolean;
  25675. /**
  25676. * Defines if the alpha value should be determined via the rgb values.
  25677. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25678. */
  25679. getAlphaFromRGB: boolean;
  25680. /**
  25681. * Intensity or strength of the texture.
  25682. * It is commonly used by materials to fine tune the intensity of the texture
  25683. */
  25684. level: number;
  25685. /**
  25686. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25687. * This is part of the texture as textures usually maps to one uv set.
  25688. */
  25689. coordinatesIndex: number;
  25690. private _coordinatesMode;
  25691. /**
  25692. * How a texture is mapped.
  25693. *
  25694. * | Value | Type | Description |
  25695. * | ----- | ----------------------------------- | ----------- |
  25696. * | 0 | EXPLICIT_MODE | |
  25697. * | 1 | SPHERICAL_MODE | |
  25698. * | 2 | PLANAR_MODE | |
  25699. * | 3 | CUBIC_MODE | |
  25700. * | 4 | PROJECTION_MODE | |
  25701. * | 5 | SKYBOX_MODE | |
  25702. * | 6 | INVCUBIC_MODE | |
  25703. * | 7 | EQUIRECTANGULAR_MODE | |
  25704. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25705. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25706. */
  25707. coordinatesMode: number;
  25708. /**
  25709. * | Value | Type | Description |
  25710. * | ----- | ------------------ | ----------- |
  25711. * | 0 | CLAMP_ADDRESSMODE | |
  25712. * | 1 | WRAP_ADDRESSMODE | |
  25713. * | 2 | MIRROR_ADDRESSMODE | |
  25714. */
  25715. wrapU: number;
  25716. /**
  25717. * | Value | Type | Description |
  25718. * | ----- | ------------------ | ----------- |
  25719. * | 0 | CLAMP_ADDRESSMODE | |
  25720. * | 1 | WRAP_ADDRESSMODE | |
  25721. * | 2 | MIRROR_ADDRESSMODE | |
  25722. */
  25723. wrapV: number;
  25724. /**
  25725. * | Value | Type | Description |
  25726. * | ----- | ------------------ | ----------- |
  25727. * | 0 | CLAMP_ADDRESSMODE | |
  25728. * | 1 | WRAP_ADDRESSMODE | |
  25729. * | 2 | MIRROR_ADDRESSMODE | |
  25730. */
  25731. wrapR: number;
  25732. /**
  25733. * With compliant hardware and browser (supporting anisotropic filtering)
  25734. * this defines the level of anisotropic filtering in the texture.
  25735. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25736. */
  25737. anisotropicFilteringLevel: number;
  25738. /**
  25739. * Define if the texture is a cube texture or if false a 2d texture.
  25740. */
  25741. isCube: boolean;
  25742. /**
  25743. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25744. */
  25745. is3D: boolean;
  25746. /**
  25747. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25748. * HDR texture are usually stored in linear space.
  25749. * This only impacts the PBR and Background materials
  25750. */
  25751. gammaSpace: boolean;
  25752. /**
  25753. * Gets whether or not the texture contains RGBD data.
  25754. */
  25755. readonly isRGBD: boolean;
  25756. /**
  25757. * Is Z inverted in the texture (useful in a cube texture).
  25758. */
  25759. invertZ: boolean;
  25760. /**
  25761. * Are mip maps generated for this texture or not.
  25762. */
  25763. readonly noMipmap: boolean;
  25764. /**
  25765. * @hidden
  25766. */
  25767. lodLevelInAlpha: boolean;
  25768. /**
  25769. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25770. */
  25771. lodGenerationOffset: number;
  25772. /**
  25773. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25774. */
  25775. lodGenerationScale: number;
  25776. /**
  25777. * Define if the texture is a render target.
  25778. */
  25779. isRenderTarget: boolean;
  25780. /**
  25781. * Define the unique id of the texture in the scene.
  25782. */
  25783. readonly uid: string;
  25784. /**
  25785. * Return a string representation of the texture.
  25786. * @returns the texture as a string
  25787. */
  25788. toString(): string;
  25789. /**
  25790. * Get the class name of the texture.
  25791. * @returns "BaseTexture"
  25792. */
  25793. getClassName(): string;
  25794. /**
  25795. * Define the list of animation attached to the texture.
  25796. */
  25797. animations: import("babylonjs/Animations/animation").Animation[];
  25798. /**
  25799. * An event triggered when the texture is disposed.
  25800. */
  25801. onDisposeObservable: Observable<BaseTexture>;
  25802. private _onDisposeObserver;
  25803. /**
  25804. * Callback triggered when the texture has been disposed.
  25805. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25806. */
  25807. onDispose: () => void;
  25808. /**
  25809. * Define the current state of the loading sequence when in delayed load mode.
  25810. */
  25811. delayLoadState: number;
  25812. private _scene;
  25813. /** @hidden */
  25814. _texture: Nullable<InternalTexture>;
  25815. private _uid;
  25816. /**
  25817. * Define if the texture is preventinga material to render or not.
  25818. * If not and the texture is not ready, the engine will use a default black texture instead.
  25819. */
  25820. readonly isBlocking: boolean;
  25821. /**
  25822. * Instantiates a new BaseTexture.
  25823. * Base class of all the textures in babylon.
  25824. * It groups all the common properties the materials, post process, lights... might need
  25825. * in order to make a correct use of the texture.
  25826. * @param scene Define the scene the texture blongs to
  25827. */
  25828. constructor(scene: Nullable<Scene>);
  25829. /**
  25830. * Get the scene the texture belongs to.
  25831. * @returns the scene or null if undefined
  25832. */
  25833. getScene(): Nullable<Scene>;
  25834. /**
  25835. * Get the texture transform matrix used to offset tile the texture for istance.
  25836. * @returns the transformation matrix
  25837. */
  25838. getTextureMatrix(): Matrix;
  25839. /**
  25840. * Get the texture reflection matrix used to rotate/transform the reflection.
  25841. * @returns the reflection matrix
  25842. */
  25843. getReflectionTextureMatrix(): Matrix;
  25844. /**
  25845. * Get the underlying lower level texture from Babylon.
  25846. * @returns the insternal texture
  25847. */
  25848. getInternalTexture(): Nullable<InternalTexture>;
  25849. /**
  25850. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25851. * @returns true if ready or not blocking
  25852. */
  25853. isReadyOrNotBlocking(): boolean;
  25854. /**
  25855. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25856. * @returns true if fully ready
  25857. */
  25858. isReady(): boolean;
  25859. private _cachedSize;
  25860. /**
  25861. * Get the size of the texture.
  25862. * @returns the texture size.
  25863. */
  25864. getSize(): ISize;
  25865. /**
  25866. * Get the base size of the texture.
  25867. * It can be different from the size if the texture has been resized for POT for instance
  25868. * @returns the base size
  25869. */
  25870. getBaseSize(): ISize;
  25871. /**
  25872. * Update the sampling mode of the texture.
  25873. * Default is Trilinear mode.
  25874. *
  25875. * | Value | Type | Description |
  25876. * | ----- | ------------------ | ----------- |
  25877. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25878. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25879. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25880. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25881. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25882. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25883. * | 7 | NEAREST_LINEAR | |
  25884. * | 8 | NEAREST_NEAREST | |
  25885. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25886. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25887. * | 11 | LINEAR_LINEAR | |
  25888. * | 12 | LINEAR_NEAREST | |
  25889. *
  25890. * > _mag_: magnification filter (close to the viewer)
  25891. * > _min_: minification filter (far from the viewer)
  25892. * > _mip_: filter used between mip map levels
  25893. *@param samplingMode Define the new sampling mode of the texture
  25894. */
  25895. updateSamplingMode(samplingMode: number): void;
  25896. /**
  25897. * Scales the texture if is `canRescale()`
  25898. * @param ratio the resize factor we want to use to rescale
  25899. */
  25900. scale(ratio: number): void;
  25901. /**
  25902. * Get if the texture can rescale.
  25903. */
  25904. readonly canRescale: boolean;
  25905. /** @hidden */
  25906. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  25907. /** @hidden */
  25908. _rebuild(): void;
  25909. /**
  25910. * Triggers the load sequence in delayed load mode.
  25911. */
  25912. delayLoad(): void;
  25913. /**
  25914. * Clones the texture.
  25915. * @returns the cloned texture
  25916. */
  25917. clone(): Nullable<BaseTexture>;
  25918. /**
  25919. * Get the texture underlying type (INT, FLOAT...)
  25920. */
  25921. readonly textureType: number;
  25922. /**
  25923. * Get the texture underlying format (RGB, RGBA...)
  25924. */
  25925. readonly textureFormat: number;
  25926. /**
  25927. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25928. * This will returns an RGBA array buffer containing either in values (0-255) or
  25929. * float values (0-1) depending of the underlying buffer type.
  25930. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25931. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25932. * @param buffer defines a user defined buffer to fill with data (can be null)
  25933. * @returns The Array buffer containing the pixels data.
  25934. */
  25935. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25936. /**
  25937. * Release and destroy the underlying lower level texture aka internalTexture.
  25938. */
  25939. releaseInternalTexture(): void;
  25940. /**
  25941. * Get the polynomial representation of the texture data.
  25942. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25943. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25944. */
  25945. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25946. /** @hidden */
  25947. readonly _lodTextureHigh: Nullable<BaseTexture>;
  25948. /** @hidden */
  25949. readonly _lodTextureMid: Nullable<BaseTexture>;
  25950. /** @hidden */
  25951. readonly _lodTextureLow: Nullable<BaseTexture>;
  25952. /**
  25953. * Dispose the texture and release its associated resources.
  25954. */
  25955. dispose(): void;
  25956. /**
  25957. * Serialize the texture into a JSON representation that can be parsed later on.
  25958. * @returns the JSON representation of the texture
  25959. */
  25960. serialize(): any;
  25961. /**
  25962. * Helper function to be called back once a list of texture contains only ready textures.
  25963. * @param textures Define the list of textures to wait for
  25964. * @param callback Define the callback triggered once the entire list will be ready
  25965. */
  25966. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25967. }
  25968. }
  25969. declare module "babylonjs/Materials/uniformBuffer" {
  25970. import { Nullable, FloatArray } from "babylonjs/types";
  25971. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  25972. import { Engine } from "babylonjs/Engines/engine";
  25973. import { Effect } from "babylonjs/Materials/effect";
  25974. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25975. /**
  25976. * Uniform buffer objects.
  25977. *
  25978. * Handles blocks of uniform on the GPU.
  25979. *
  25980. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25981. *
  25982. * For more information, please refer to :
  25983. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25984. */
  25985. export class UniformBuffer {
  25986. private _engine;
  25987. private _buffer;
  25988. private _data;
  25989. private _bufferData;
  25990. private _dynamic?;
  25991. private _uniformLocations;
  25992. private _uniformSizes;
  25993. private _uniformLocationPointer;
  25994. private _needSync;
  25995. private _noUBO;
  25996. private _currentEffect;
  25997. private static _MAX_UNIFORM_SIZE;
  25998. private static _tempBuffer;
  25999. /**
  26000. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26001. * This is dynamic to allow compat with webgl 1 and 2.
  26002. * You will need to pass the name of the uniform as well as the value.
  26003. */
  26004. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26005. /**
  26006. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26007. * This is dynamic to allow compat with webgl 1 and 2.
  26008. * You will need to pass the name of the uniform as well as the value.
  26009. */
  26010. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26011. /**
  26012. * Lambda to Update a single float in a uniform buffer.
  26013. * This is dynamic to allow compat with webgl 1 and 2.
  26014. * You will need to pass the name of the uniform as well as the value.
  26015. */
  26016. updateFloat: (name: string, x: number) => void;
  26017. /**
  26018. * Lambda to Update a vec2 of float in a uniform buffer.
  26019. * This is dynamic to allow compat with webgl 1 and 2.
  26020. * You will need to pass the name of the uniform as well as the value.
  26021. */
  26022. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26023. /**
  26024. * Lambda to Update a vec3 of float in a uniform buffer.
  26025. * This is dynamic to allow compat with webgl 1 and 2.
  26026. * You will need to pass the name of the uniform as well as the value.
  26027. */
  26028. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26029. /**
  26030. * Lambda to Update a vec4 of float in a uniform buffer.
  26031. * This is dynamic to allow compat with webgl 1 and 2.
  26032. * You will need to pass the name of the uniform as well as the value.
  26033. */
  26034. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26035. /**
  26036. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26037. * This is dynamic to allow compat with webgl 1 and 2.
  26038. * You will need to pass the name of the uniform as well as the value.
  26039. */
  26040. updateMatrix: (name: string, mat: Matrix) => void;
  26041. /**
  26042. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26043. * This is dynamic to allow compat with webgl 1 and 2.
  26044. * You will need to pass the name of the uniform as well as the value.
  26045. */
  26046. updateVector3: (name: string, vector: Vector3) => void;
  26047. /**
  26048. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26049. * This is dynamic to allow compat with webgl 1 and 2.
  26050. * You will need to pass the name of the uniform as well as the value.
  26051. */
  26052. updateVector4: (name: string, vector: Vector4) => void;
  26053. /**
  26054. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26055. * This is dynamic to allow compat with webgl 1 and 2.
  26056. * You will need to pass the name of the uniform as well as the value.
  26057. */
  26058. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26059. /**
  26060. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26061. * This is dynamic to allow compat with webgl 1 and 2.
  26062. * You will need to pass the name of the uniform as well as the value.
  26063. */
  26064. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26065. /**
  26066. * Instantiates a new Uniform buffer objects.
  26067. *
  26068. * Handles blocks of uniform on the GPU.
  26069. *
  26070. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26071. *
  26072. * For more information, please refer to :
  26073. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26074. * @param engine Define the engine the buffer is associated with
  26075. * @param data Define the data contained in the buffer
  26076. * @param dynamic Define if the buffer is updatable
  26077. */
  26078. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26079. /**
  26080. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26081. * or just falling back on setUniformXXX calls.
  26082. */
  26083. readonly useUbo: boolean;
  26084. /**
  26085. * Indicates if the WebGL underlying uniform buffer is in sync
  26086. * with the javascript cache data.
  26087. */
  26088. readonly isSync: boolean;
  26089. /**
  26090. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26091. * Also, a dynamic UniformBuffer will disable cache verification and always
  26092. * update the underlying WebGL uniform buffer to the GPU.
  26093. * @returns if Dynamic, otherwise false
  26094. */
  26095. isDynamic(): boolean;
  26096. /**
  26097. * The data cache on JS side.
  26098. * @returns the underlying data as a float array
  26099. */
  26100. getData(): Float32Array;
  26101. /**
  26102. * The underlying WebGL Uniform buffer.
  26103. * @returns the webgl buffer
  26104. */
  26105. getBuffer(): Nullable<WebGLBuffer>;
  26106. /**
  26107. * std140 layout specifies how to align data within an UBO structure.
  26108. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26109. * for specs.
  26110. */
  26111. private _fillAlignment;
  26112. /**
  26113. * Adds an uniform in the buffer.
  26114. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26115. * for the layout to be correct !
  26116. * @param name Name of the uniform, as used in the uniform block in the shader.
  26117. * @param size Data size, or data directly.
  26118. */
  26119. addUniform(name: string, size: number | number[]): void;
  26120. /**
  26121. * Adds a Matrix 4x4 to the uniform buffer.
  26122. * @param name Name of the uniform, as used in the uniform block in the shader.
  26123. * @param mat A 4x4 matrix.
  26124. */
  26125. addMatrix(name: string, mat: Matrix): void;
  26126. /**
  26127. * Adds a vec2 to the uniform buffer.
  26128. * @param name Name of the uniform, as used in the uniform block in the shader.
  26129. * @param x Define the x component value of the vec2
  26130. * @param y Define the y component value of the vec2
  26131. */
  26132. addFloat2(name: string, x: number, y: number): void;
  26133. /**
  26134. * Adds a vec3 to the uniform buffer.
  26135. * @param name Name of the uniform, as used in the uniform block in the shader.
  26136. * @param x Define the x component value of the vec3
  26137. * @param y Define the y component value of the vec3
  26138. * @param z Define the z component value of the vec3
  26139. */
  26140. addFloat3(name: string, x: number, y: number, z: number): void;
  26141. /**
  26142. * Adds a vec3 to the uniform buffer.
  26143. * @param name Name of the uniform, as used in the uniform block in the shader.
  26144. * @param color Define the vec3 from a Color
  26145. */
  26146. addColor3(name: string, color: Color3): void;
  26147. /**
  26148. * Adds a vec4 to the uniform buffer.
  26149. * @param name Name of the uniform, as used in the uniform block in the shader.
  26150. * @param color Define the rgb components from a Color
  26151. * @param alpha Define the a component of the vec4
  26152. */
  26153. addColor4(name: string, color: Color3, alpha: number): void;
  26154. /**
  26155. * Adds a vec3 to the uniform buffer.
  26156. * @param name Name of the uniform, as used in the uniform block in the shader.
  26157. * @param vector Define the vec3 components from a Vector
  26158. */
  26159. addVector3(name: string, vector: Vector3): void;
  26160. /**
  26161. * Adds a Matrix 3x3 to the uniform buffer.
  26162. * @param name Name of the uniform, as used in the uniform block in the shader.
  26163. */
  26164. addMatrix3x3(name: string): void;
  26165. /**
  26166. * Adds a Matrix 2x2 to the uniform buffer.
  26167. * @param name Name of the uniform, as used in the uniform block in the shader.
  26168. */
  26169. addMatrix2x2(name: string): void;
  26170. /**
  26171. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26172. */
  26173. create(): void;
  26174. /** @hidden */
  26175. _rebuild(): void;
  26176. /**
  26177. * Updates the WebGL Uniform Buffer on the GPU.
  26178. * If the `dynamic` flag is set to true, no cache comparison is done.
  26179. * Otherwise, the buffer will be updated only if the cache differs.
  26180. */
  26181. update(): void;
  26182. /**
  26183. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26184. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26185. * @param data Define the flattened data
  26186. * @param size Define the size of the data.
  26187. */
  26188. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26189. private _updateMatrix3x3ForUniform;
  26190. private _updateMatrix3x3ForEffect;
  26191. private _updateMatrix2x2ForEffect;
  26192. private _updateMatrix2x2ForUniform;
  26193. private _updateFloatForEffect;
  26194. private _updateFloatForUniform;
  26195. private _updateFloat2ForEffect;
  26196. private _updateFloat2ForUniform;
  26197. private _updateFloat3ForEffect;
  26198. private _updateFloat3ForUniform;
  26199. private _updateFloat4ForEffect;
  26200. private _updateFloat4ForUniform;
  26201. private _updateMatrixForEffect;
  26202. private _updateMatrixForUniform;
  26203. private _updateVector3ForEffect;
  26204. private _updateVector3ForUniform;
  26205. private _updateVector4ForEffect;
  26206. private _updateVector4ForUniform;
  26207. private _updateColor3ForEffect;
  26208. private _updateColor3ForUniform;
  26209. private _updateColor4ForEffect;
  26210. private _updateColor4ForUniform;
  26211. /**
  26212. * Sets a sampler uniform on the effect.
  26213. * @param name Define the name of the sampler.
  26214. * @param texture Define the texture to set in the sampler
  26215. */
  26216. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26217. /**
  26218. * Directly updates the value of the uniform in the cache AND on the GPU.
  26219. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26220. * @param data Define the flattened data
  26221. */
  26222. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26223. /**
  26224. * Binds this uniform buffer to an effect.
  26225. * @param effect Define the effect to bind the buffer to
  26226. * @param name Name of the uniform block in the shader.
  26227. */
  26228. bindToEffect(effect: Effect, name: string): void;
  26229. /**
  26230. * Disposes the uniform buffer.
  26231. */
  26232. dispose(): void;
  26233. }
  26234. }
  26235. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  26236. import { Nullable } from "babylonjs/types";
  26237. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26238. /**
  26239. * This represents the required contract to create a new type of texture loader.
  26240. */
  26241. export interface IInternalTextureLoader {
  26242. /**
  26243. * Defines wether the loader supports cascade loading the different faces.
  26244. */
  26245. supportCascades: boolean;
  26246. /**
  26247. * This returns if the loader support the current file information.
  26248. * @param extension defines the file extension of the file being loaded
  26249. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26250. * @param fallback defines the fallback internal texture if any
  26251. * @param isBase64 defines whether the texture is encoded as a base64
  26252. * @param isBuffer defines whether the texture data are stored as a buffer
  26253. * @returns true if the loader can load the specified file
  26254. */
  26255. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  26256. /**
  26257. * Transform the url before loading if required.
  26258. * @param rootUrl the url of the texture
  26259. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26260. * @returns the transformed texture
  26261. */
  26262. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  26263. /**
  26264. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  26265. * @param rootUrl the url of the texture
  26266. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26267. * @returns the fallback texture
  26268. */
  26269. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  26270. /**
  26271. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  26272. * @param data contains the texture data
  26273. * @param texture defines the BabylonJS internal texture
  26274. * @param createPolynomials will be true if polynomials have been requested
  26275. * @param onLoad defines the callback to trigger once the texture is ready
  26276. * @param onError defines the callback to trigger in case of error
  26277. */
  26278. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  26279. /**
  26280. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  26281. * @param data contains the texture data
  26282. * @param texture defines the BabylonJS internal texture
  26283. * @param callback defines the method to call once ready to upload
  26284. */
  26285. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  26286. }
  26287. }
  26288. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  26289. import { Scene } from "babylonjs/scene";
  26290. import { Engine } from "babylonjs/Engines/engine";
  26291. import { Texture } from "babylonjs/Materials/Textures/texture";
  26292. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26293. /**
  26294. * Creation options of the multi render target texture.
  26295. */
  26296. export interface IMultiRenderTargetOptions {
  26297. /**
  26298. * Define if the texture needs to create mip maps after render.
  26299. */
  26300. generateMipMaps?: boolean;
  26301. /**
  26302. * Define the types of all the draw buffers we want to create
  26303. */
  26304. types?: number[];
  26305. /**
  26306. * Define the sampling modes of all the draw buffers we want to create
  26307. */
  26308. samplingModes?: number[];
  26309. /**
  26310. * Define if a depth buffer is required
  26311. */
  26312. generateDepthBuffer?: boolean;
  26313. /**
  26314. * Define if a stencil buffer is required
  26315. */
  26316. generateStencilBuffer?: boolean;
  26317. /**
  26318. * Define if a depth texture is required instead of a depth buffer
  26319. */
  26320. generateDepthTexture?: boolean;
  26321. /**
  26322. * Define the number of desired draw buffers
  26323. */
  26324. textureCount?: number;
  26325. /**
  26326. * Define if aspect ratio should be adapted to the texture or stay the scene one
  26327. */
  26328. doNotChangeAspectRatio?: boolean;
  26329. /**
  26330. * Define the default type of the buffers we are creating
  26331. */
  26332. defaultType?: number;
  26333. }
  26334. /**
  26335. * A multi render target, like a render target provides the ability to render to a texture.
  26336. * Unlike the render target, it can render to several draw buffers in one draw.
  26337. * This is specially interesting in deferred rendering or for any effects requiring more than
  26338. * just one color from a single pass.
  26339. */
  26340. export class MultiRenderTarget extends RenderTargetTexture {
  26341. private _internalTextures;
  26342. private _textures;
  26343. private _multiRenderTargetOptions;
  26344. /**
  26345. * Get if draw buffers are currently supported by the used hardware and browser.
  26346. */
  26347. readonly isSupported: boolean;
  26348. /**
  26349. * Get the list of textures generated by the multi render target.
  26350. */
  26351. readonly textures: Texture[];
  26352. /**
  26353. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26354. */
  26355. readonly depthTexture: Texture;
  26356. /**
  26357. * Set the wrapping mode on U of all the textures we are rendering to.
  26358. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26359. */
  26360. wrapU: number;
  26361. /**
  26362. * Set the wrapping mode on V of all the textures we are rendering to.
  26363. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26364. */
  26365. wrapV: number;
  26366. /**
  26367. * Instantiate a new multi render target texture.
  26368. * A multi render target, like a render target provides the ability to render to a texture.
  26369. * Unlike the render target, it can render to several draw buffers in one draw.
  26370. * This is specially interesting in deferred rendering or for any effects requiring more than
  26371. * just one color from a single pass.
  26372. * @param name Define the name of the texture
  26373. * @param size Define the size of the buffers to render to
  26374. * @param count Define the number of target we are rendering into
  26375. * @param scene Define the scene the texture belongs to
  26376. * @param options Define the options used to create the multi render target
  26377. */
  26378. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26379. /** @hidden */
  26380. _rebuild(): void;
  26381. private _createInternalTextures;
  26382. private _createTextures;
  26383. /**
  26384. * Define the number of samples used if MSAA is enabled.
  26385. */
  26386. samples: number;
  26387. /**
  26388. * Resize all the textures in the multi render target.
  26389. * Be carrefull as it will recreate all the data in the new texture.
  26390. * @param size Define the new size
  26391. */
  26392. resize(size: any): void;
  26393. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26394. /**
  26395. * Dispose the render targets and their associated resources
  26396. */
  26397. dispose(): void;
  26398. /**
  26399. * Release all the underlying texture used as draw buffers.
  26400. */
  26401. releaseInternalTextures(): void;
  26402. }
  26403. }
  26404. declare module "babylonjs/Audio/analyser" {
  26405. import { Scene } from "babylonjs/scene";
  26406. /**
  26407. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26408. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26409. */
  26410. export class Analyser {
  26411. /**
  26412. * Gets or sets the smoothing
  26413. * @ignorenaming
  26414. */
  26415. SMOOTHING: number;
  26416. /**
  26417. * Gets or sets the FFT table size
  26418. * @ignorenaming
  26419. */
  26420. FFT_SIZE: number;
  26421. /**
  26422. * Gets or sets the bar graph amplitude
  26423. * @ignorenaming
  26424. */
  26425. BARGRAPHAMPLITUDE: number;
  26426. /**
  26427. * Gets or sets the position of the debug canvas
  26428. * @ignorenaming
  26429. */
  26430. DEBUGCANVASPOS: {
  26431. x: number;
  26432. y: number;
  26433. };
  26434. /**
  26435. * Gets or sets the debug canvas size
  26436. * @ignorenaming
  26437. */
  26438. DEBUGCANVASSIZE: {
  26439. width: number;
  26440. height: number;
  26441. };
  26442. private _byteFreqs;
  26443. private _byteTime;
  26444. private _floatFreqs;
  26445. private _webAudioAnalyser;
  26446. private _debugCanvas;
  26447. private _debugCanvasContext;
  26448. private _scene;
  26449. private _registerFunc;
  26450. private _audioEngine;
  26451. /**
  26452. * Creates a new analyser
  26453. * @param scene defines hosting scene
  26454. */
  26455. constructor(scene: Scene);
  26456. /**
  26457. * Get the number of data values you will have to play with for the visualization
  26458. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26459. * @returns a number
  26460. */
  26461. getFrequencyBinCount(): number;
  26462. /**
  26463. * Gets the current frequency data as a byte array
  26464. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26465. * @returns a Uint8Array
  26466. */
  26467. getByteFrequencyData(): Uint8Array;
  26468. /**
  26469. * Gets the current waveform as a byte array
  26470. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26471. * @returns a Uint8Array
  26472. */
  26473. getByteTimeDomainData(): Uint8Array;
  26474. /**
  26475. * Gets the current frequency data as a float array
  26476. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26477. * @returns a Float32Array
  26478. */
  26479. getFloatFrequencyData(): Float32Array;
  26480. /**
  26481. * Renders the debug canvas
  26482. */
  26483. drawDebugCanvas(): void;
  26484. /**
  26485. * Stops rendering the debug canvas and removes it
  26486. */
  26487. stopDebugCanvas(): void;
  26488. /**
  26489. * Connects two audio nodes
  26490. * @param inputAudioNode defines first node to connect
  26491. * @param outputAudioNode defines second node to connect
  26492. */
  26493. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26494. /**
  26495. * Releases all associated resources
  26496. */
  26497. dispose(): void;
  26498. }
  26499. }
  26500. declare module "babylonjs/Audio/audioEngine" {
  26501. import { IDisposable } from "babylonjs/scene";
  26502. import { Analyser } from "babylonjs/Audio/analyser";
  26503. import { Nullable } from "babylonjs/types";
  26504. import { Observable } from "babylonjs/Misc/observable";
  26505. /**
  26506. * This represents an audio engine and it is responsible
  26507. * to play, synchronize and analyse sounds throughout the application.
  26508. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26509. */
  26510. export interface IAudioEngine extends IDisposable {
  26511. /**
  26512. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26513. */
  26514. readonly canUseWebAudio: boolean;
  26515. /**
  26516. * Gets the current AudioContext if available.
  26517. */
  26518. readonly audioContext: Nullable<AudioContext>;
  26519. /**
  26520. * The master gain node defines the global audio volume of your audio engine.
  26521. */
  26522. readonly masterGain: GainNode;
  26523. /**
  26524. * Gets whether or not mp3 are supported by your browser.
  26525. */
  26526. readonly isMP3supported: boolean;
  26527. /**
  26528. * Gets whether or not ogg are supported by your browser.
  26529. */
  26530. readonly isOGGsupported: boolean;
  26531. /**
  26532. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26533. * @ignoreNaming
  26534. */
  26535. WarnedWebAudioUnsupported: boolean;
  26536. /**
  26537. * Defines if the audio engine relies on a custom unlocked button.
  26538. * In this case, the embedded button will not be displayed.
  26539. */
  26540. useCustomUnlockedButton: boolean;
  26541. /**
  26542. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26543. */
  26544. readonly unlocked: boolean;
  26545. /**
  26546. * Event raised when audio has been unlocked on the browser.
  26547. */
  26548. onAudioUnlockedObservable: Observable<AudioEngine>;
  26549. /**
  26550. * Event raised when audio has been locked on the browser.
  26551. */
  26552. onAudioLockedObservable: Observable<AudioEngine>;
  26553. /**
  26554. * Flags the audio engine in Locked state.
  26555. * This happens due to new browser policies preventing audio to autoplay.
  26556. */
  26557. lock(): void;
  26558. /**
  26559. * Unlocks the audio engine once a user action has been done on the dom.
  26560. * This is helpful to resume play once browser policies have been satisfied.
  26561. */
  26562. unlock(): void;
  26563. }
  26564. /**
  26565. * This represents the default audio engine used in babylon.
  26566. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26567. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26568. */
  26569. export class AudioEngine implements IAudioEngine {
  26570. private _audioContext;
  26571. private _audioContextInitialized;
  26572. private _muteButton;
  26573. private _hostElement;
  26574. /**
  26575. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26576. */
  26577. canUseWebAudio: boolean;
  26578. /**
  26579. * The master gain node defines the global audio volume of your audio engine.
  26580. */
  26581. masterGain: GainNode;
  26582. /**
  26583. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26584. * @ignoreNaming
  26585. */
  26586. WarnedWebAudioUnsupported: boolean;
  26587. /**
  26588. * Gets whether or not mp3 are supported by your browser.
  26589. */
  26590. isMP3supported: boolean;
  26591. /**
  26592. * Gets whether or not ogg are supported by your browser.
  26593. */
  26594. isOGGsupported: boolean;
  26595. /**
  26596. * Gets whether audio has been unlocked on the device.
  26597. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26598. * a user interaction has happened.
  26599. */
  26600. unlocked: boolean;
  26601. /**
  26602. * Defines if the audio engine relies on a custom unlocked button.
  26603. * In this case, the embedded button will not be displayed.
  26604. */
  26605. useCustomUnlockedButton: boolean;
  26606. /**
  26607. * Event raised when audio has been unlocked on the browser.
  26608. */
  26609. onAudioUnlockedObservable: Observable<AudioEngine>;
  26610. /**
  26611. * Event raised when audio has been locked on the browser.
  26612. */
  26613. onAudioLockedObservable: Observable<AudioEngine>;
  26614. /**
  26615. * Gets the current AudioContext if available.
  26616. */
  26617. readonly audioContext: Nullable<AudioContext>;
  26618. private _connectedAnalyser;
  26619. /**
  26620. * Instantiates a new audio engine.
  26621. *
  26622. * There should be only one per page as some browsers restrict the number
  26623. * of audio contexts you can create.
  26624. * @param hostElement defines the host element where to display the mute icon if necessary
  26625. */
  26626. constructor(hostElement?: Nullable<HTMLElement>);
  26627. /**
  26628. * Flags the audio engine in Locked state.
  26629. * This happens due to new browser policies preventing audio to autoplay.
  26630. */
  26631. lock(): void;
  26632. /**
  26633. * Unlocks the audio engine once a user action has been done on the dom.
  26634. * This is helpful to resume play once browser policies have been satisfied.
  26635. */
  26636. unlock(): void;
  26637. private _resumeAudioContext;
  26638. private _initializeAudioContext;
  26639. private _tryToRun;
  26640. private _triggerRunningState;
  26641. private _triggerSuspendedState;
  26642. private _displayMuteButton;
  26643. private _moveButtonToTopLeft;
  26644. private _onResize;
  26645. private _hideMuteButton;
  26646. /**
  26647. * Destroy and release the resources associated with the audio ccontext.
  26648. */
  26649. dispose(): void;
  26650. /**
  26651. * Gets the global volume sets on the master gain.
  26652. * @returns the global volume if set or -1 otherwise
  26653. */
  26654. getGlobalVolume(): number;
  26655. /**
  26656. * Sets the global volume of your experience (sets on the master gain).
  26657. * @param newVolume Defines the new global volume of the application
  26658. */
  26659. setGlobalVolume(newVolume: number): void;
  26660. /**
  26661. * Connect the audio engine to an audio analyser allowing some amazing
  26662. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26663. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26664. * @param analyser The analyser to connect to the engine
  26665. */
  26666. connectToAnalyser(analyser: Analyser): void;
  26667. }
  26668. }
  26669. declare module "babylonjs/Loading/loadingScreen" {
  26670. /**
  26671. * Interface used to present a loading screen while loading a scene
  26672. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26673. */
  26674. export interface ILoadingScreen {
  26675. /**
  26676. * Function called to display the loading screen
  26677. */
  26678. displayLoadingUI: () => void;
  26679. /**
  26680. * Function called to hide the loading screen
  26681. */
  26682. hideLoadingUI: () => void;
  26683. /**
  26684. * Gets or sets the color to use for the background
  26685. */
  26686. loadingUIBackgroundColor: string;
  26687. /**
  26688. * Gets or sets the text to display while loading
  26689. */
  26690. loadingUIText: string;
  26691. }
  26692. /**
  26693. * Class used for the default loading screen
  26694. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26695. */
  26696. export class DefaultLoadingScreen implements ILoadingScreen {
  26697. private _renderingCanvas;
  26698. private _loadingText;
  26699. private _loadingDivBackgroundColor;
  26700. private _loadingDiv;
  26701. private _loadingTextDiv;
  26702. /**
  26703. * Creates a new default loading screen
  26704. * @param _renderingCanvas defines the canvas used to render the scene
  26705. * @param _loadingText defines the default text to display
  26706. * @param _loadingDivBackgroundColor defines the default background color
  26707. */
  26708. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26709. /**
  26710. * Function called to display the loading screen
  26711. */
  26712. displayLoadingUI(): void;
  26713. /**
  26714. * Function called to hide the loading screen
  26715. */
  26716. hideLoadingUI(): void;
  26717. /**
  26718. * Gets or sets the text to display while loading
  26719. */
  26720. loadingUIText: string;
  26721. /**
  26722. * Gets or sets the color to use for the background
  26723. */
  26724. loadingUIBackgroundColor: string;
  26725. private _resizeLoadingUI;
  26726. }
  26727. }
  26728. declare module "babylonjs/Materials/Textures/videoTexture" {
  26729. import { Observable } from "babylonjs/Misc/observable";
  26730. import { Nullable } from "babylonjs/types";
  26731. import { Scene } from "babylonjs/scene";
  26732. import { Texture } from "babylonjs/Materials/Textures/texture";
  26733. /**
  26734. * Settings for finer control over video usage
  26735. */
  26736. export interface VideoTextureSettings {
  26737. /**
  26738. * Applies `autoplay` to video, if specified
  26739. */
  26740. autoPlay?: boolean;
  26741. /**
  26742. * Applies `loop` to video, if specified
  26743. */
  26744. loop?: boolean;
  26745. /**
  26746. * Automatically updates internal texture from video at every frame in the render loop
  26747. */
  26748. autoUpdateTexture: boolean;
  26749. /**
  26750. * Image src displayed during the video loading or until the user interacts with the video.
  26751. */
  26752. poster?: string;
  26753. }
  26754. /**
  26755. * If you want to display a video in your scene, this is the special texture for that.
  26756. * This special texture works similar to other textures, with the exception of a few parameters.
  26757. * @see https://doc.babylonjs.com/how_to/video_texture
  26758. */
  26759. export class VideoTexture extends Texture {
  26760. /**
  26761. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26762. */
  26763. readonly autoUpdateTexture: boolean;
  26764. /**
  26765. * The video instance used by the texture internally
  26766. */
  26767. readonly video: HTMLVideoElement;
  26768. private _onUserActionRequestedObservable;
  26769. /**
  26770. * Event triggerd when a dom action is required by the user to play the video.
  26771. * This happens due to recent changes in browser policies preventing video to auto start.
  26772. */
  26773. readonly onUserActionRequestedObservable: Observable<Texture>;
  26774. private _generateMipMaps;
  26775. private _engine;
  26776. private _stillImageCaptured;
  26777. private _displayingPosterTexture;
  26778. private _settings;
  26779. private _createInternalTextureOnEvent;
  26780. /**
  26781. * Creates a video texture.
  26782. * If you want to display a video in your scene, this is the special texture for that.
  26783. * This special texture works similar to other textures, with the exception of a few parameters.
  26784. * @see https://doc.babylonjs.com/how_to/video_texture
  26785. * @param name optional name, will detect from video source, if not defined
  26786. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26787. * @param scene is obviously the current scene.
  26788. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26789. * @param invertY is false by default but can be used to invert video on Y axis
  26790. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26791. * @param settings allows finer control over video usage
  26792. */
  26793. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26794. private _getName;
  26795. private _getVideo;
  26796. private _createInternalTexture;
  26797. private reset;
  26798. /**
  26799. * @hidden Internal method to initiate `update`.
  26800. */
  26801. _rebuild(): void;
  26802. /**
  26803. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26804. */
  26805. update(): void;
  26806. /**
  26807. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26808. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26809. */
  26810. updateTexture(isVisible: boolean): void;
  26811. protected _updateInternalTexture: () => void;
  26812. /**
  26813. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26814. * @param url New url.
  26815. */
  26816. updateURL(url: string): void;
  26817. /**
  26818. * Dispose the texture and release its associated resources.
  26819. */
  26820. dispose(): void;
  26821. /**
  26822. * Creates a video texture straight from a stream.
  26823. * @param scene Define the scene the texture should be created in
  26824. * @param stream Define the stream the texture should be created from
  26825. * @returns The created video texture as a promise
  26826. */
  26827. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  26828. /**
  26829. * Creates a video texture straight from your WebCam video feed.
  26830. * @param scene Define the scene the texture should be created in
  26831. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26832. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26833. * @returns The created video texture as a promise
  26834. */
  26835. static CreateFromWebCamAsync(scene: Scene, constraints: {
  26836. minWidth: number;
  26837. maxWidth: number;
  26838. minHeight: number;
  26839. maxHeight: number;
  26840. deviceId: string;
  26841. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  26842. /**
  26843. * Creates a video texture straight from your WebCam video feed.
  26844. * @param scene Define the scene the texture should be created in
  26845. * @param onReady Define a callback to triggered once the texture will be ready
  26846. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26847. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26848. */
  26849. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26850. minWidth: number;
  26851. maxWidth: number;
  26852. minHeight: number;
  26853. maxHeight: number;
  26854. deviceId: string;
  26855. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  26856. }
  26857. }
  26858. declare module "babylonjs/Engines/engine" {
  26859. import { Observable } from "babylonjs/Misc/observable";
  26860. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  26861. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  26862. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26863. import { Camera } from "babylonjs/Cameras/camera";
  26864. import { Scene } from "babylonjs/scene";
  26865. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  26866. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  26867. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26868. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  26869. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  26870. import { Material } from "babylonjs/Materials/material";
  26871. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  26872. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26873. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26874. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  26875. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  26876. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  26877. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  26878. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  26879. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  26880. import { WebRequest } from "babylonjs/Misc/webRequest";
  26881. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26882. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26883. /**
  26884. * Interface for attribute information associated with buffer instanciation
  26885. */
  26886. export class InstancingAttributeInfo {
  26887. /**
  26888. * Index/offset of the attribute in the vertex shader
  26889. */
  26890. index: number;
  26891. /**
  26892. * size of the attribute, 1, 2, 3 or 4
  26893. */
  26894. attributeSize: number;
  26895. /**
  26896. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26897. * default is FLOAT
  26898. */
  26899. attribyteType: number;
  26900. /**
  26901. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26902. */
  26903. normalized: boolean;
  26904. /**
  26905. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26906. */
  26907. offset: number;
  26908. /**
  26909. * Name of the GLSL attribute, for debugging purpose only
  26910. */
  26911. attributeName: string;
  26912. }
  26913. /**
  26914. * Define options used to create a depth texture
  26915. */
  26916. export class DepthTextureCreationOptions {
  26917. /** Specifies whether or not a stencil should be allocated in the texture */
  26918. generateStencil?: boolean;
  26919. /** Specifies whether or not bilinear filtering is enable on the texture */
  26920. bilinearFiltering?: boolean;
  26921. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26922. comparisonFunction?: number;
  26923. /** Specifies if the created texture is a cube texture */
  26924. isCube?: boolean;
  26925. }
  26926. /**
  26927. * Class used to describe the capabilities of the engine relatively to the current browser
  26928. */
  26929. export class EngineCapabilities {
  26930. /** Maximum textures units per fragment shader */
  26931. maxTexturesImageUnits: number;
  26932. /** Maximum texture units per vertex shader */
  26933. maxVertexTextureImageUnits: number;
  26934. /** Maximum textures units in the entire pipeline */
  26935. maxCombinedTexturesImageUnits: number;
  26936. /** Maximum texture size */
  26937. maxTextureSize: number;
  26938. /** Maximum cube texture size */
  26939. maxCubemapTextureSize: number;
  26940. /** Maximum render texture size */
  26941. maxRenderTextureSize: number;
  26942. /** Maximum number of vertex attributes */
  26943. maxVertexAttribs: number;
  26944. /** Maximum number of varyings */
  26945. maxVaryingVectors: number;
  26946. /** Maximum number of uniforms per vertex shader */
  26947. maxVertexUniformVectors: number;
  26948. /** Maximum number of uniforms per fragment shader */
  26949. maxFragmentUniformVectors: number;
  26950. /** Defines if standard derivates (dx/dy) are supported */
  26951. standardDerivatives: boolean;
  26952. /** Defines if s3tc texture compression is supported */
  26953. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26954. /** Defines if pvrtc texture compression is supported */
  26955. pvrtc: any;
  26956. /** Defines if etc1 texture compression is supported */
  26957. etc1: any;
  26958. /** Defines if etc2 texture compression is supported */
  26959. etc2: any;
  26960. /** Defines if astc texture compression is supported */
  26961. astc: any;
  26962. /** Defines if float textures are supported */
  26963. textureFloat: boolean;
  26964. /** Defines if vertex array objects are supported */
  26965. vertexArrayObject: boolean;
  26966. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26967. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26968. /** Gets the maximum level of anisotropy supported */
  26969. maxAnisotropy: number;
  26970. /** Defines if instancing is supported */
  26971. instancedArrays: boolean;
  26972. /** Defines if 32 bits indices are supported */
  26973. uintIndices: boolean;
  26974. /** Defines if high precision shaders are supported */
  26975. highPrecisionShaderSupported: boolean;
  26976. /** Defines if depth reading in the fragment shader is supported */
  26977. fragmentDepthSupported: boolean;
  26978. /** Defines if float texture linear filtering is supported*/
  26979. textureFloatLinearFiltering: boolean;
  26980. /** Defines if rendering to float textures is supported */
  26981. textureFloatRender: boolean;
  26982. /** Defines if half float textures are supported*/
  26983. textureHalfFloat: boolean;
  26984. /** Defines if half float texture linear filtering is supported*/
  26985. textureHalfFloatLinearFiltering: boolean;
  26986. /** Defines if rendering to half float textures is supported */
  26987. textureHalfFloatRender: boolean;
  26988. /** Defines if textureLOD shader command is supported */
  26989. textureLOD: boolean;
  26990. /** Defines if draw buffers extension is supported */
  26991. drawBuffersExtension: boolean;
  26992. /** Defines if depth textures are supported */
  26993. depthTextureExtension: boolean;
  26994. /** Defines if float color buffer are supported */
  26995. colorBufferFloat: boolean;
  26996. /** Gets disjoint timer query extension (null if not supported) */
  26997. timerQuery: EXT_disjoint_timer_query;
  26998. /** Defines if timestamp can be used with timer query */
  26999. canUseTimestampForTimerQuery: boolean;
  27000. /** Function used to let the system compiles shaders in background */
  27001. parallelShaderCompile: {
  27002. MAX_SHADER_COMPILER_THREADS_KHR: number;
  27003. maxShaderCompilerThreadsKHR: (thread: number) => void;
  27004. COMPLETION_STATUS_KHR: number;
  27005. };
  27006. }
  27007. /** Interface defining initialization parameters for Engine class */
  27008. export interface EngineOptions extends WebGLContextAttributes {
  27009. /**
  27010. * Defines if the engine should no exceed a specified device ratio
  27011. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27012. */
  27013. limitDeviceRatio?: number;
  27014. /**
  27015. * Defines if webvr should be enabled automatically
  27016. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27017. */
  27018. autoEnableWebVR?: boolean;
  27019. /**
  27020. * Defines if webgl2 should be turned off even if supported
  27021. * @see http://doc.babylonjs.com/features/webgl2
  27022. */
  27023. disableWebGL2Support?: boolean;
  27024. /**
  27025. * Defines if webaudio should be initialized as well
  27026. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27027. */
  27028. audioEngine?: boolean;
  27029. /**
  27030. * Defines if animations should run using a deterministic lock step
  27031. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27032. */
  27033. deterministicLockstep?: boolean;
  27034. /** Defines the maximum steps to use with deterministic lock step mode */
  27035. lockstepMaxSteps?: number;
  27036. /**
  27037. * Defines that engine should ignore context lost events
  27038. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27039. */
  27040. doNotHandleContextLost?: boolean;
  27041. /**
  27042. * Defines that engine should ignore modifying touch action attribute and style
  27043. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27044. */
  27045. doNotHandleTouchAction?: boolean;
  27046. /**
  27047. * Defines that engine should compile shaders with high precision floats (if supported). False by default
  27048. */
  27049. useHighPrecisionFloats?: boolean;
  27050. }
  27051. /**
  27052. * Defines the interface used by display changed events
  27053. */
  27054. export interface IDisplayChangedEventArgs {
  27055. /** Gets the vrDisplay object (if any) */
  27056. vrDisplay: Nullable<any>;
  27057. /** Gets a boolean indicating if webVR is supported */
  27058. vrSupported: boolean;
  27059. }
  27060. /**
  27061. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27062. */
  27063. export class Engine {
  27064. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27065. static ExceptionList: ({
  27066. key: string;
  27067. capture: string;
  27068. captureConstraint: number;
  27069. targets: string[];
  27070. } | {
  27071. key: string;
  27072. capture: null;
  27073. captureConstraint: null;
  27074. targets: string[];
  27075. })[];
  27076. /** Gets the list of created engines */
  27077. static readonly Instances: Engine[];
  27078. /**
  27079. * Gets the latest created engine
  27080. */
  27081. static readonly LastCreatedEngine: Nullable<Engine>;
  27082. /**
  27083. * Gets the latest created scene
  27084. */
  27085. static readonly LastCreatedScene: Nullable<Scene>;
  27086. /**
  27087. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27088. * @param flag defines which part of the materials must be marked as dirty
  27089. * @param predicate defines a predicate used to filter which materials should be affected
  27090. */
  27091. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27092. /**
  27093. * Hidden
  27094. */
  27095. static _TextureLoaders: IInternalTextureLoader[];
  27096. /** Defines that alpha blending is disabled */
  27097. static readonly ALPHA_DISABLE: number;
  27098. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27099. static readonly ALPHA_ADD: number;
  27100. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27101. static readonly ALPHA_COMBINE: number;
  27102. /** Defines that alpha blending to DEST - SRC * DEST */
  27103. static readonly ALPHA_SUBTRACT: number;
  27104. /** Defines that alpha blending to SRC * DEST */
  27105. static readonly ALPHA_MULTIPLY: number;
  27106. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27107. static readonly ALPHA_MAXIMIZED: number;
  27108. /** Defines that alpha blending to SRC + DEST */
  27109. static readonly ALPHA_ONEONE: number;
  27110. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27111. static readonly ALPHA_PREMULTIPLIED: number;
  27112. /**
  27113. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27114. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27115. */
  27116. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27117. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27118. static readonly ALPHA_INTERPOLATE: number;
  27119. /**
  27120. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27121. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27122. */
  27123. static readonly ALPHA_SCREENMODE: number;
  27124. /** Defines that the ressource is not delayed*/
  27125. static readonly DELAYLOADSTATE_NONE: number;
  27126. /** Defines that the ressource was successfully delay loaded */
  27127. static readonly DELAYLOADSTATE_LOADED: number;
  27128. /** Defines that the ressource is currently delay loading */
  27129. static readonly DELAYLOADSTATE_LOADING: number;
  27130. /** Defines that the ressource is delayed and has not started loading */
  27131. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27132. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27133. static readonly NEVER: number;
  27134. /** 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 */
  27135. static readonly ALWAYS: number;
  27136. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27137. static readonly LESS: number;
  27138. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27139. static readonly EQUAL: number;
  27140. /** 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 */
  27141. static readonly LEQUAL: number;
  27142. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27143. static readonly GREATER: number;
  27144. /** 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 */
  27145. static readonly GEQUAL: number;
  27146. /** 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 */
  27147. static readonly NOTEQUAL: number;
  27148. /** Passed to stencilOperation to specify that stencil value must be kept */
  27149. static readonly KEEP: number;
  27150. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27151. static readonly REPLACE: number;
  27152. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27153. static readonly INCR: number;
  27154. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27155. static readonly DECR: number;
  27156. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27157. static readonly INVERT: number;
  27158. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27159. static readonly INCR_WRAP: number;
  27160. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27161. static readonly DECR_WRAP: number;
  27162. /** Texture is not repeating outside of 0..1 UVs */
  27163. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27164. /** Texture is repeating outside of 0..1 UVs */
  27165. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27166. /** Texture is repeating and mirrored */
  27167. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27168. /** ALPHA */
  27169. static readonly TEXTUREFORMAT_ALPHA: number;
  27170. /** LUMINANCE */
  27171. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27172. /** LUMINANCE_ALPHA */
  27173. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27174. /** RGB */
  27175. static readonly TEXTUREFORMAT_RGB: number;
  27176. /** RGBA */
  27177. static readonly TEXTUREFORMAT_RGBA: number;
  27178. /** RED */
  27179. static readonly TEXTUREFORMAT_RED: number;
  27180. /** RED (2nd reference) */
  27181. static readonly TEXTUREFORMAT_R: number;
  27182. /** RG */
  27183. static readonly TEXTUREFORMAT_RG: number;
  27184. /** RED_INTEGER */
  27185. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27186. /** RED_INTEGER (2nd reference) */
  27187. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27188. /** RG_INTEGER */
  27189. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27190. /** RGB_INTEGER */
  27191. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27192. /** RGBA_INTEGER */
  27193. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27194. /** UNSIGNED_BYTE */
  27195. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27196. /** UNSIGNED_BYTE (2nd reference) */
  27197. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27198. /** FLOAT */
  27199. static readonly TEXTURETYPE_FLOAT: number;
  27200. /** HALF_FLOAT */
  27201. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27202. /** BYTE */
  27203. static readonly TEXTURETYPE_BYTE: number;
  27204. /** SHORT */
  27205. static readonly TEXTURETYPE_SHORT: number;
  27206. /** UNSIGNED_SHORT */
  27207. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27208. /** INT */
  27209. static readonly TEXTURETYPE_INT: number;
  27210. /** UNSIGNED_INT */
  27211. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27212. /** UNSIGNED_SHORT_4_4_4_4 */
  27213. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27214. /** UNSIGNED_SHORT_5_5_5_1 */
  27215. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27216. /** UNSIGNED_SHORT_5_6_5 */
  27217. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27218. /** UNSIGNED_INT_2_10_10_10_REV */
  27219. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27220. /** UNSIGNED_INT_24_8 */
  27221. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27222. /** UNSIGNED_INT_10F_11F_11F_REV */
  27223. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27224. /** UNSIGNED_INT_5_9_9_9_REV */
  27225. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27226. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27227. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27228. /** nearest is mag = nearest and min = nearest and mip = linear */
  27229. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27230. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27231. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27232. /** Trilinear is mag = linear and min = linear and mip = linear */
  27233. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27234. /** nearest is mag = nearest and min = nearest and mip = linear */
  27235. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27236. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27237. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27238. /** Trilinear is mag = linear and min = linear and mip = linear */
  27239. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27240. /** mag = nearest and min = nearest and mip = nearest */
  27241. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27242. /** mag = nearest and min = linear and mip = nearest */
  27243. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27244. /** mag = nearest and min = linear and mip = linear */
  27245. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27246. /** mag = nearest and min = linear and mip = none */
  27247. static readonly TEXTURE_NEAREST_LINEAR: number;
  27248. /** mag = nearest and min = nearest and mip = none */
  27249. static readonly TEXTURE_NEAREST_NEAREST: number;
  27250. /** mag = linear and min = nearest and mip = nearest */
  27251. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27252. /** mag = linear and min = nearest and mip = linear */
  27253. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27254. /** mag = linear and min = linear and mip = none */
  27255. static readonly TEXTURE_LINEAR_LINEAR: number;
  27256. /** mag = linear and min = nearest and mip = none */
  27257. static readonly TEXTURE_LINEAR_NEAREST: number;
  27258. /** Explicit coordinates mode */
  27259. static readonly TEXTURE_EXPLICIT_MODE: number;
  27260. /** Spherical coordinates mode */
  27261. static readonly TEXTURE_SPHERICAL_MODE: number;
  27262. /** Planar coordinates mode */
  27263. static readonly TEXTURE_PLANAR_MODE: number;
  27264. /** Cubic coordinates mode */
  27265. static readonly TEXTURE_CUBIC_MODE: number;
  27266. /** Projection coordinates mode */
  27267. static readonly TEXTURE_PROJECTION_MODE: number;
  27268. /** Skybox coordinates mode */
  27269. static readonly TEXTURE_SKYBOX_MODE: number;
  27270. /** Inverse Cubic coordinates mode */
  27271. static readonly TEXTURE_INVCUBIC_MODE: number;
  27272. /** Equirectangular coordinates mode */
  27273. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27274. /** Equirectangular Fixed coordinates mode */
  27275. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27276. /** Equirectangular Fixed Mirrored coordinates mode */
  27277. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27278. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27279. static readonly SCALEMODE_FLOOR: number;
  27280. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27281. static readonly SCALEMODE_NEAREST: number;
  27282. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27283. static readonly SCALEMODE_CEILING: number;
  27284. /**
  27285. * Returns the current version of the framework
  27286. */
  27287. static readonly Version: string;
  27288. /**
  27289. * Returns a string describing the current engine
  27290. */
  27291. readonly description: string;
  27292. /**
  27293. * Gets or sets the epsilon value used by collision engine
  27294. */
  27295. static CollisionsEpsilon: number;
  27296. /**
  27297. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27298. */
  27299. static ShadersRepository: string;
  27300. /**
  27301. * Method called to create the default loading screen.
  27302. * This can be overriden in your own app.
  27303. * @param canvas The rendering canvas element
  27304. * @returns The loading screen
  27305. */
  27306. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27307. /**
  27308. * Method called to create the default rescale post process on each engine.
  27309. */
  27310. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27311. /**
  27312. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27313. */
  27314. forcePOTTextures: boolean;
  27315. /**
  27316. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27317. */
  27318. isFullscreen: boolean;
  27319. /**
  27320. * Gets a boolean indicating if the pointer is currently locked
  27321. */
  27322. isPointerLock: boolean;
  27323. /**
  27324. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27325. */
  27326. cullBackFaces: boolean;
  27327. /**
  27328. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27329. */
  27330. renderEvenInBackground: boolean;
  27331. /**
  27332. * Gets or sets a boolean indicating that cache can be kept between frames
  27333. */
  27334. preventCacheWipeBetweenFrames: boolean;
  27335. /**
  27336. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27337. **/
  27338. enableOfflineSupport: boolean;
  27339. /**
  27340. * 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)
  27341. **/
  27342. disableManifestCheck: boolean;
  27343. /**
  27344. * Gets the list of created scenes
  27345. */
  27346. scenes: Scene[];
  27347. /**
  27348. * Event raised when a new scene is created
  27349. */
  27350. onNewSceneAddedObservable: Observable<Scene>;
  27351. /**
  27352. * Gets the list of created postprocesses
  27353. */
  27354. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  27355. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27356. validateShaderPrograms: boolean;
  27357. /**
  27358. * Observable event triggered each time the rendering canvas is resized
  27359. */
  27360. onResizeObservable: Observable<Engine>;
  27361. /**
  27362. * Observable event triggered each time the canvas loses focus
  27363. */
  27364. onCanvasBlurObservable: Observable<Engine>;
  27365. /**
  27366. * Observable event triggered each time the canvas gains focus
  27367. */
  27368. onCanvasFocusObservable: Observable<Engine>;
  27369. /**
  27370. * Observable event triggered each time the canvas receives pointerout event
  27371. */
  27372. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27373. /**
  27374. * Observable event triggered before each texture is initialized
  27375. */
  27376. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  27377. private _vrDisplay;
  27378. private _vrSupported;
  27379. private _oldSize;
  27380. private _oldHardwareScaleFactor;
  27381. private _vrExclusivePointerMode;
  27382. private _webVRInitPromise;
  27383. /**
  27384. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27385. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27386. */
  27387. readonly isInVRExclusivePointerMode: boolean;
  27388. /**
  27389. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27390. */
  27391. disableUniformBuffers: boolean;
  27392. /** @hidden */
  27393. _uniformBuffers: UniformBuffer[];
  27394. /**
  27395. * Gets a boolean indicating that the engine supports uniform buffers
  27396. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27397. */
  27398. readonly supportsUniformBuffers: boolean;
  27399. /**
  27400. * Observable raised when the engine begins a new frame
  27401. */
  27402. onBeginFrameObservable: Observable<Engine>;
  27403. /**
  27404. * If set, will be used to request the next animation frame for the render loop
  27405. */
  27406. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27407. /**
  27408. * Observable raised when the engine ends the current frame
  27409. */
  27410. onEndFrameObservable: Observable<Engine>;
  27411. /**
  27412. * Observable raised when the engine is about to compile a shader
  27413. */
  27414. onBeforeShaderCompilationObservable: Observable<Engine>;
  27415. /**
  27416. * Observable raised when the engine has jsut compiled a shader
  27417. */
  27418. onAfterShaderCompilationObservable: Observable<Engine>;
  27419. /** @hidden */
  27420. _gl: WebGLRenderingContext;
  27421. private _renderingCanvas;
  27422. private _windowIsBackground;
  27423. private _webGLVersion;
  27424. private _highPrecisionShadersAllowed;
  27425. /** @hidden */
  27426. readonly _shouldUseHighPrecisionShader: boolean;
  27427. /**
  27428. * Gets a boolean indicating that only power of 2 textures are supported
  27429. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27430. */
  27431. readonly needPOTTextures: boolean;
  27432. /** @hidden */
  27433. _badOS: boolean;
  27434. /** @hidden */
  27435. _badDesktopOS: boolean;
  27436. /**
  27437. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27438. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27439. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27440. */
  27441. disableTextureBindingOptimization: boolean;
  27442. /**
  27443. * Gets the audio engine
  27444. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27445. * @ignorenaming
  27446. */
  27447. static audioEngine: IAudioEngine;
  27448. /**
  27449. * Default AudioEngine factory responsible of creating the Audio Engine.
  27450. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27451. */
  27452. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27453. /**
  27454. * Default offline support factory responsible of creating a tool used to store data locally.
  27455. * By default, this will create a Database object if the workload has been embedded.
  27456. */
  27457. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27458. private _onFocus;
  27459. private _onBlur;
  27460. private _onCanvasPointerOut;
  27461. private _onCanvasBlur;
  27462. private _onCanvasFocus;
  27463. private _onFullscreenChange;
  27464. private _onPointerLockChange;
  27465. private _onVRDisplayPointerRestricted;
  27466. private _onVRDisplayPointerUnrestricted;
  27467. private _onVrDisplayConnect;
  27468. private _onVrDisplayDisconnect;
  27469. private _onVrDisplayPresentChange;
  27470. /**
  27471. * Observable signaled when VR display mode changes
  27472. */
  27473. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27474. /**
  27475. * Observable signaled when VR request present is complete
  27476. */
  27477. onVRRequestPresentComplete: Observable<boolean>;
  27478. /**
  27479. * Observable signaled when VR request present starts
  27480. */
  27481. onVRRequestPresentStart: Observable<Engine>;
  27482. private _hardwareScalingLevel;
  27483. /** @hidden */
  27484. protected _caps: EngineCapabilities;
  27485. private _pointerLockRequested;
  27486. private _isStencilEnable;
  27487. private _colorWrite;
  27488. private _loadingScreen;
  27489. /** @hidden */
  27490. _drawCalls: PerfCounter;
  27491. /** @hidden */
  27492. _textureCollisions: PerfCounter;
  27493. private _glVersion;
  27494. private _glRenderer;
  27495. private _glVendor;
  27496. private _videoTextureSupported;
  27497. private _renderingQueueLaunched;
  27498. private _activeRenderLoops;
  27499. private _deterministicLockstep;
  27500. private _lockstepMaxSteps;
  27501. /**
  27502. * Observable signaled when a context lost event is raised
  27503. */
  27504. onContextLostObservable: Observable<Engine>;
  27505. /**
  27506. * Observable signaled when a context restored event is raised
  27507. */
  27508. onContextRestoredObservable: Observable<Engine>;
  27509. private _onContextLost;
  27510. private _onContextRestored;
  27511. private _contextWasLost;
  27512. private _doNotHandleContextLost;
  27513. /**
  27514. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27515. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27516. */
  27517. doNotHandleContextLost: boolean;
  27518. private _performanceMonitor;
  27519. private _fps;
  27520. private _deltaTime;
  27521. /**
  27522. * Turn this value on if you want to pause FPS computation when in background
  27523. */
  27524. disablePerformanceMonitorInBackground: boolean;
  27525. /**
  27526. * Gets the performance monitor attached to this engine
  27527. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27528. */
  27529. readonly performanceMonitor: PerformanceMonitor;
  27530. /** @hidden */
  27531. protected _depthCullingState: _DepthCullingState;
  27532. /** @hidden */
  27533. protected _stencilState: _StencilState;
  27534. /** @hidden */
  27535. protected _alphaState: _AlphaState;
  27536. /** @hidden */
  27537. protected _alphaMode: number;
  27538. protected _internalTexturesCache: InternalTexture[];
  27539. /** @hidden */
  27540. protected _activeChannel: number;
  27541. private _currentTextureChannel;
  27542. /** @hidden */
  27543. protected _boundTexturesCache: {
  27544. [key: string]: Nullable<InternalTexture>;
  27545. };
  27546. /** @hidden */
  27547. protected _currentEffect: Nullable<Effect>;
  27548. /** @hidden */
  27549. protected _currentProgram: Nullable<WebGLProgram>;
  27550. private _compiledEffects;
  27551. private _vertexAttribArraysEnabled;
  27552. /** @hidden */
  27553. protected _cachedViewport: Nullable<Viewport>;
  27554. private _cachedVertexArrayObject;
  27555. /** @hidden */
  27556. protected _cachedVertexBuffers: any;
  27557. /** @hidden */
  27558. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  27559. /** @hidden */
  27560. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27561. /** @hidden */
  27562. protected _currentRenderTarget: Nullable<InternalTexture>;
  27563. private _uintIndicesCurrentlySet;
  27564. private _currentBoundBuffer;
  27565. /** @hidden */
  27566. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27567. private _currentBufferPointers;
  27568. private _currentInstanceLocations;
  27569. private _currentInstanceBuffers;
  27570. private _textureUnits;
  27571. private _firstBoundInternalTextureTracker;
  27572. private _lastBoundInternalTextureTracker;
  27573. private _workingCanvas;
  27574. private _workingContext;
  27575. private _rescalePostProcess;
  27576. private _dummyFramebuffer;
  27577. private _externalData;
  27578. private _bindedRenderFunction;
  27579. private _vaoRecordInProgress;
  27580. private _mustWipeVertexAttributes;
  27581. private _emptyTexture;
  27582. private _emptyCubeTexture;
  27583. private _emptyTexture3D;
  27584. /** @hidden */
  27585. _frameHandler: number;
  27586. private _nextFreeTextureSlots;
  27587. private _maxSimultaneousTextures;
  27588. private _activeRequests;
  27589. private _texturesSupported;
  27590. private _textureFormatInUse;
  27591. /**
  27592. * Gets the list of texture formats supported
  27593. */
  27594. readonly texturesSupported: Array<string>;
  27595. /**
  27596. * Gets the list of texture formats in use
  27597. */
  27598. readonly textureFormatInUse: Nullable<string>;
  27599. /**
  27600. * Gets the current viewport
  27601. */
  27602. readonly currentViewport: Nullable<Viewport>;
  27603. /**
  27604. * Gets the default empty texture
  27605. */
  27606. readonly emptyTexture: InternalTexture;
  27607. /**
  27608. * Gets the default empty 3D texture
  27609. */
  27610. readonly emptyTexture3D: InternalTexture;
  27611. /**
  27612. * Gets the default empty cube texture
  27613. */
  27614. readonly emptyCubeTexture: InternalTexture;
  27615. /**
  27616. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27617. */
  27618. readonly premultipliedAlpha: boolean;
  27619. /**
  27620. * Creates a new engine
  27621. * @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
  27622. * @param antialias defines enable antialiasing (default: false)
  27623. * @param options defines further options to be sent to the getContext() function
  27624. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27625. */
  27626. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27627. private _disableTouchAction;
  27628. private _rebuildInternalTextures;
  27629. private _rebuildEffects;
  27630. /**
  27631. * Gets a boolean indicating if all created effects are ready
  27632. * @returns true if all effects are ready
  27633. */
  27634. areAllEffectsReady(): boolean;
  27635. private _rebuildBuffers;
  27636. private _initGLContext;
  27637. /**
  27638. * Gets version of the current webGL context
  27639. */
  27640. readonly webGLVersion: number;
  27641. /**
  27642. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27643. */
  27644. readonly isStencilEnable: boolean;
  27645. private _prepareWorkingCanvas;
  27646. /**
  27647. * Reset the texture cache to empty state
  27648. */
  27649. resetTextureCache(): void;
  27650. /**
  27651. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27652. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27653. * @returns true if engine is in deterministic lock step mode
  27654. */
  27655. isDeterministicLockStep(): boolean;
  27656. /**
  27657. * Gets the max steps when engine is running in deterministic lock step
  27658. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27659. * @returns the max steps
  27660. */
  27661. getLockstepMaxSteps(): number;
  27662. /**
  27663. * Gets an object containing information about the current webGL context
  27664. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27665. */
  27666. getGlInfo(): {
  27667. vendor: string;
  27668. renderer: string;
  27669. version: string;
  27670. };
  27671. /**
  27672. * Gets current aspect ratio
  27673. * @param camera defines the camera to use to get the aspect ratio
  27674. * @param useScreen defines if screen size must be used (or the current render target if any)
  27675. * @returns a number defining the aspect ratio
  27676. */
  27677. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27678. /**
  27679. * Gets current screen aspect ratio
  27680. * @returns a number defining the aspect ratio
  27681. */
  27682. getScreenAspectRatio(): number;
  27683. /**
  27684. * Gets the current render width
  27685. * @param useScreen defines if screen size must be used (or the current render target if any)
  27686. * @returns a number defining the current render width
  27687. */
  27688. getRenderWidth(useScreen?: boolean): number;
  27689. /**
  27690. * Gets the current render height
  27691. * @param useScreen defines if screen size must be used (or the current render target if any)
  27692. * @returns a number defining the current render height
  27693. */
  27694. getRenderHeight(useScreen?: boolean): number;
  27695. /**
  27696. * Gets the HTML canvas attached with the current webGL context
  27697. * @returns a HTML canvas
  27698. */
  27699. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27700. /**
  27701. * Gets the client rect of the HTML canvas attached with the current webGL context
  27702. * @returns a client rectanglee
  27703. */
  27704. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27705. /**
  27706. * Defines the hardware scaling level.
  27707. * By default the hardware scaling level is computed from the window device ratio.
  27708. * 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.
  27709. * @param level defines the level to use
  27710. */
  27711. setHardwareScalingLevel(level: number): void;
  27712. /**
  27713. * Gets the current hardware scaling level.
  27714. * By default the hardware scaling level is computed from the window device ratio.
  27715. * 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.
  27716. * @returns a number indicating the current hardware scaling level
  27717. */
  27718. getHardwareScalingLevel(): number;
  27719. /**
  27720. * Gets the list of loaded textures
  27721. * @returns an array containing all loaded textures
  27722. */
  27723. getLoadedTexturesCache(): InternalTexture[];
  27724. /**
  27725. * Gets the object containing all engine capabilities
  27726. * @returns the EngineCapabilities object
  27727. */
  27728. getCaps(): EngineCapabilities;
  27729. /**
  27730. * Gets the current depth function
  27731. * @returns a number defining the depth function
  27732. */
  27733. getDepthFunction(): Nullable<number>;
  27734. /**
  27735. * Sets the current depth function
  27736. * @param depthFunc defines the function to use
  27737. */
  27738. setDepthFunction(depthFunc: number): void;
  27739. /**
  27740. * Sets the current depth function to GREATER
  27741. */
  27742. setDepthFunctionToGreater(): void;
  27743. /**
  27744. * Sets the current depth function to GEQUAL
  27745. */
  27746. setDepthFunctionToGreaterOrEqual(): void;
  27747. /**
  27748. * Sets the current depth function to LESS
  27749. */
  27750. setDepthFunctionToLess(): void;
  27751. /**
  27752. * Sets the current depth function to LEQUAL
  27753. */
  27754. setDepthFunctionToLessOrEqual(): void;
  27755. /**
  27756. * Gets a boolean indicating if stencil buffer is enabled
  27757. * @returns the current stencil buffer state
  27758. */
  27759. getStencilBuffer(): boolean;
  27760. /**
  27761. * Enable or disable the stencil buffer
  27762. * @param enable defines if the stencil buffer must be enabled or disabled
  27763. */
  27764. setStencilBuffer(enable: boolean): void;
  27765. /**
  27766. * Gets the current stencil mask
  27767. * @returns a number defining the new stencil mask to use
  27768. */
  27769. getStencilMask(): number;
  27770. /**
  27771. * Sets the current stencil mask
  27772. * @param mask defines the new stencil mask to use
  27773. */
  27774. setStencilMask(mask: number): void;
  27775. /**
  27776. * Gets the current stencil function
  27777. * @returns a number defining the stencil function to use
  27778. */
  27779. getStencilFunction(): number;
  27780. /**
  27781. * Gets the current stencil reference value
  27782. * @returns a number defining the stencil reference value to use
  27783. */
  27784. getStencilFunctionReference(): number;
  27785. /**
  27786. * Gets the current stencil mask
  27787. * @returns a number defining the stencil mask to use
  27788. */
  27789. getStencilFunctionMask(): number;
  27790. /**
  27791. * Sets the current stencil function
  27792. * @param stencilFunc defines the new stencil function to use
  27793. */
  27794. setStencilFunction(stencilFunc: number): void;
  27795. /**
  27796. * Sets the current stencil reference
  27797. * @param reference defines the new stencil reference to use
  27798. */
  27799. setStencilFunctionReference(reference: number): void;
  27800. /**
  27801. * Sets the current stencil mask
  27802. * @param mask defines the new stencil mask to use
  27803. */
  27804. setStencilFunctionMask(mask: number): void;
  27805. /**
  27806. * Gets the current stencil operation when stencil fails
  27807. * @returns a number defining stencil operation to use when stencil fails
  27808. */
  27809. getStencilOperationFail(): number;
  27810. /**
  27811. * Gets the current stencil operation when depth fails
  27812. * @returns a number defining stencil operation to use when depth fails
  27813. */
  27814. getStencilOperationDepthFail(): number;
  27815. /**
  27816. * Gets the current stencil operation when stencil passes
  27817. * @returns a number defining stencil operation to use when stencil passes
  27818. */
  27819. getStencilOperationPass(): number;
  27820. /**
  27821. * Sets the stencil operation to use when stencil fails
  27822. * @param operation defines the stencil operation to use when stencil fails
  27823. */
  27824. setStencilOperationFail(operation: number): void;
  27825. /**
  27826. * Sets the stencil operation to use when depth fails
  27827. * @param operation defines the stencil operation to use when depth fails
  27828. */
  27829. setStencilOperationDepthFail(operation: number): void;
  27830. /**
  27831. * Sets the stencil operation to use when stencil passes
  27832. * @param operation defines the stencil operation to use when stencil passes
  27833. */
  27834. setStencilOperationPass(operation: number): void;
  27835. /**
  27836. * Sets a boolean indicating if the dithering state is enabled or disabled
  27837. * @param value defines the dithering state
  27838. */
  27839. setDitheringState(value: boolean): void;
  27840. /**
  27841. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27842. * @param value defines the rasterizer state
  27843. */
  27844. setRasterizerState(value: boolean): void;
  27845. /**
  27846. * stop executing a render loop function and remove it from the execution array
  27847. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27848. */
  27849. stopRenderLoop(renderFunction?: () => void): void;
  27850. /** @hidden */
  27851. _renderLoop(): void;
  27852. /**
  27853. * Register and execute a render loop. The engine can have more than one render function
  27854. * @param renderFunction defines the function to continuously execute
  27855. */
  27856. runRenderLoop(renderFunction: () => void): void;
  27857. /**
  27858. * Toggle full screen mode
  27859. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27860. */
  27861. switchFullscreen(requestPointerLock: boolean): void;
  27862. /**
  27863. * Enters full screen mode
  27864. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27865. */
  27866. enterFullscreen(requestPointerLock: boolean): void;
  27867. /**
  27868. * Exits full screen mode
  27869. */
  27870. exitFullscreen(): void;
  27871. /**
  27872. * Clear the current render buffer or the current render target (if any is set up)
  27873. * @param color defines the color to use
  27874. * @param backBuffer defines if the back buffer must be cleared
  27875. * @param depth defines if the depth buffer must be cleared
  27876. * @param stencil defines if the stencil buffer must be cleared
  27877. */
  27878. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27879. /**
  27880. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27881. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27882. * @param y defines the y-coordinate of the corner of the clear rectangle
  27883. * @param width defines the width of the clear rectangle
  27884. * @param height defines the height of the clear rectangle
  27885. * @param clearColor defines the clear color
  27886. */
  27887. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27888. /**
  27889. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27890. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27891. * @param y defines the y-coordinate of the corner of the clear rectangle
  27892. * @param width defines the width of the clear rectangle
  27893. * @param height defines the height of the clear rectangle
  27894. */
  27895. enableScissor(x: number, y: number, width: number, height: number): void;
  27896. /**
  27897. * Disable previously set scissor test rectangle
  27898. */
  27899. disableScissor(): void;
  27900. private _viewportCached;
  27901. /** @hidden */
  27902. _viewport(x: number, y: number, width: number, height: number): void;
  27903. /**
  27904. * Set the WebGL's viewport
  27905. * @param viewport defines the viewport element to be used
  27906. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27907. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27908. */
  27909. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27910. /**
  27911. * Directly set the WebGL Viewport
  27912. * @param x defines the x coordinate of the viewport (in screen space)
  27913. * @param y defines the y coordinate of the viewport (in screen space)
  27914. * @param width defines the width of the viewport (in screen space)
  27915. * @param height defines the height of the viewport (in screen space)
  27916. * @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
  27917. */
  27918. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27919. /**
  27920. * Begin a new frame
  27921. */
  27922. beginFrame(): void;
  27923. /**
  27924. * Enf the current frame
  27925. */
  27926. endFrame(): void;
  27927. /**
  27928. * Resize the view according to the canvas' size
  27929. */
  27930. resize(): void;
  27931. /**
  27932. * Force a specific size of the canvas
  27933. * @param width defines the new canvas' width
  27934. * @param height defines the new canvas' height
  27935. */
  27936. setSize(width: number, height: number): void;
  27937. /**
  27938. * Gets a boolean indicating if a webVR device was detected
  27939. * @returns true if a webVR device was detected
  27940. */
  27941. isVRDevicePresent(): boolean;
  27942. /**
  27943. * Gets the current webVR device
  27944. * @returns the current webVR device (or null)
  27945. */
  27946. getVRDevice(): any;
  27947. /**
  27948. * Initializes a webVR display and starts listening to display change events
  27949. * The onVRDisplayChangedObservable will be notified upon these changes
  27950. * @returns The onVRDisplayChangedObservable
  27951. */
  27952. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27953. /**
  27954. * Initializes a webVR display and starts listening to display change events
  27955. * The onVRDisplayChangedObservable will be notified upon these changes
  27956. * @returns A promise containing a VRDisplay and if vr is supported
  27957. */
  27958. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27959. /**
  27960. * Call this function to switch to webVR mode
  27961. * Will do nothing if webVR is not supported or if there is no webVR device
  27962. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27963. */
  27964. enableVR(): void;
  27965. /**
  27966. * Call this function to leave webVR mode
  27967. * Will do nothing if webVR is not supported or if there is no webVR device
  27968. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27969. */
  27970. disableVR(): void;
  27971. private _onVRFullScreenTriggered;
  27972. private _getVRDisplaysAsync;
  27973. /**
  27974. * Binds the frame buffer to the specified texture.
  27975. * @param texture The texture to render to or null for the default canvas
  27976. * @param faceIndex The face of the texture to render to in case of cube texture
  27977. * @param requiredWidth The width of the target to render to
  27978. * @param requiredHeight The height of the target to render to
  27979. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27980. * @param depthStencilTexture The depth stencil texture to use to render
  27981. * @param lodLevel defines le lod level to bind to the frame buffer
  27982. */
  27983. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27984. private bindUnboundFramebuffer;
  27985. /**
  27986. * Unbind the current render target texture from the webGL context
  27987. * @param texture defines the render target texture to unbind
  27988. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27989. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27990. */
  27991. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27992. /**
  27993. * Unbind a list of render target textures from the webGL context
  27994. * This is used only when drawBuffer extension or webGL2 are active
  27995. * @param textures defines the render target textures to unbind
  27996. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27997. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27998. */
  27999. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28000. /**
  28001. * Force the mipmap generation for the given render target texture
  28002. * @param texture defines the render target texture to use
  28003. */
  28004. generateMipMapsForCubemap(texture: InternalTexture): void;
  28005. /**
  28006. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28007. */
  28008. flushFramebuffer(): void;
  28009. /**
  28010. * Unbind the current render target and bind the default framebuffer
  28011. */
  28012. restoreDefaultFramebuffer(): void;
  28013. /**
  28014. * Create an uniform buffer
  28015. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28016. * @param elements defines the content of the uniform buffer
  28017. * @returns the webGL uniform buffer
  28018. */
  28019. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  28020. /**
  28021. * Create a dynamic uniform buffer
  28022. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28023. * @param elements defines the content of the uniform buffer
  28024. * @returns the webGL uniform buffer
  28025. */
  28026. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  28027. /**
  28028. * Update an existing uniform buffer
  28029. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28030. * @param uniformBuffer defines the target uniform buffer
  28031. * @param elements defines the content to update
  28032. * @param offset defines the offset in the uniform buffer where update should start
  28033. * @param count defines the size of the data to update
  28034. */
  28035. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28036. private _resetVertexBufferBinding;
  28037. /**
  28038. * Creates a vertex buffer
  28039. * @param data the data for the vertex buffer
  28040. * @returns the new WebGL static buffer
  28041. */
  28042. createVertexBuffer(data: DataArray): WebGLBuffer;
  28043. /**
  28044. * Creates a dynamic vertex buffer
  28045. * @param data the data for the dynamic vertex buffer
  28046. * @returns the new WebGL dynamic buffer
  28047. */
  28048. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  28049. /**
  28050. * Update a dynamic index buffer
  28051. * @param indexBuffer defines the target index buffer
  28052. * @param indices defines the data to update
  28053. * @param offset defines the offset in the target index buffer where update should start
  28054. */
  28055. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  28056. /**
  28057. * Updates a dynamic vertex buffer.
  28058. * @param vertexBuffer the vertex buffer to update
  28059. * @param data the data used to update the vertex buffer
  28060. * @param byteOffset the byte offset of the data
  28061. * @param byteLength the byte length of the data
  28062. */
  28063. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28064. private _resetIndexBufferBinding;
  28065. /**
  28066. * Creates a new index buffer
  28067. * @param indices defines the content of the index buffer
  28068. * @param updatable defines if the index buffer must be updatable
  28069. * @returns a new webGL buffer
  28070. */
  28071. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  28072. /**
  28073. * Bind a webGL buffer to the webGL context
  28074. * @param buffer defines the buffer to bind
  28075. */
  28076. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  28077. /**
  28078. * Bind an uniform buffer to the current webGL context
  28079. * @param buffer defines the buffer to bind
  28080. */
  28081. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  28082. /**
  28083. * Bind a buffer to the current webGL context at a given location
  28084. * @param buffer defines the buffer to bind
  28085. * @param location defines the index where to bind the buffer
  28086. */
  28087. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  28088. /**
  28089. * Bind a specific block at a given index in a specific shader program
  28090. * @param shaderProgram defines the shader program
  28091. * @param blockName defines the block name
  28092. * @param index defines the index where to bind the block
  28093. */
  28094. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  28095. private bindIndexBuffer;
  28096. private bindBuffer;
  28097. /**
  28098. * update the bound buffer with the given data
  28099. * @param data defines the data to update
  28100. */
  28101. updateArrayBuffer(data: Float32Array): void;
  28102. private _vertexAttribPointer;
  28103. private _bindIndexBufferWithCache;
  28104. private _bindVertexBuffersAttributes;
  28105. /**
  28106. * Records a vertex array object
  28107. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28108. * @param vertexBuffers defines the list of vertex buffers to store
  28109. * @param indexBuffer defines the index buffer to store
  28110. * @param effect defines the effect to store
  28111. * @returns the new vertex array object
  28112. */
  28113. recordVertexArrayObject(vertexBuffers: {
  28114. [key: string]: VertexBuffer;
  28115. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  28116. /**
  28117. * Bind a specific vertex array object
  28118. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28119. * @param vertexArrayObject defines the vertex array object to bind
  28120. * @param indexBuffer defines the index buffer to bind
  28121. */
  28122. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  28123. /**
  28124. * Bind webGl buffers directly to the webGL context
  28125. * @param vertexBuffer defines the vertex buffer to bind
  28126. * @param indexBuffer defines the index buffer to bind
  28127. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28128. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28129. * @param effect defines the effect associated with the vertex buffer
  28130. */
  28131. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28132. private _unbindVertexArrayObject;
  28133. /**
  28134. * Bind a list of vertex buffers to the webGL context
  28135. * @param vertexBuffers defines the list of vertex buffers to bind
  28136. * @param indexBuffer defines the index buffer to bind
  28137. * @param effect defines the effect associated with the vertex buffers
  28138. */
  28139. bindBuffers(vertexBuffers: {
  28140. [key: string]: Nullable<VertexBuffer>;
  28141. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  28142. /**
  28143. * Unbind all instance attributes
  28144. */
  28145. unbindInstanceAttributes(): void;
  28146. /**
  28147. * Release and free the memory of a vertex array object
  28148. * @param vao defines the vertex array object to delete
  28149. */
  28150. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28151. /** @hidden */
  28152. _releaseBuffer(buffer: WebGLBuffer): boolean;
  28153. /**
  28154. * Creates a webGL buffer to use with instanciation
  28155. * @param capacity defines the size of the buffer
  28156. * @returns the webGL buffer
  28157. */
  28158. createInstancesBuffer(capacity: number): WebGLBuffer;
  28159. /**
  28160. * Delete a webGL buffer used with instanciation
  28161. * @param buffer defines the webGL buffer to delete
  28162. */
  28163. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28164. /**
  28165. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28166. * @param instancesBuffer defines the webGL buffer to update and bind
  28167. * @param data defines the data to store in the buffer
  28168. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28169. */
  28170. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28171. /**
  28172. * Apply all cached states (depth, culling, stencil and alpha)
  28173. */
  28174. applyStates(): void;
  28175. /**
  28176. * Send a draw order
  28177. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28178. * @param indexStart defines the starting index
  28179. * @param indexCount defines the number of index to draw
  28180. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28181. */
  28182. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28183. /**
  28184. * Draw a list of points
  28185. * @param verticesStart defines the index of first vertex to draw
  28186. * @param verticesCount defines the count of vertices to draw
  28187. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28188. */
  28189. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28190. /**
  28191. * Draw a list of unindexed primitives
  28192. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28193. * @param verticesStart defines the index of first vertex to draw
  28194. * @param verticesCount defines the count of vertices to draw
  28195. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28196. */
  28197. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28198. /**
  28199. * Draw a list of indexed primitives
  28200. * @param fillMode defines the primitive to use
  28201. * @param indexStart defines the starting index
  28202. * @param indexCount defines the number of index to draw
  28203. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28204. */
  28205. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28206. /**
  28207. * Draw a list of unindexed primitives
  28208. * @param fillMode defines the primitive to use
  28209. * @param verticesStart defines the index of first vertex to draw
  28210. * @param verticesCount defines the count of vertices to draw
  28211. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28212. */
  28213. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28214. private _drawMode;
  28215. /** @hidden */
  28216. _releaseEffect(effect: Effect): void;
  28217. /** @hidden */
  28218. _deleteProgram(program: WebGLProgram): void;
  28219. /**
  28220. * Create a new effect (used to store vertex/fragment shaders)
  28221. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28222. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28223. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28224. * @param samplers defines an array of string used to represent textures
  28225. * @param defines defines the string containing the defines to use to compile the shaders
  28226. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28227. * @param onCompiled defines a function to call when the effect creation is successful
  28228. * @param onError defines a function to call when the effect creation has failed
  28229. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28230. * @returns the new Effect
  28231. */
  28232. 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;
  28233. private _compileShader;
  28234. private _compileRawShader;
  28235. /**
  28236. * Directly creates a webGL program
  28237. * @param vertexCode defines the vertex shader code to use
  28238. * @param fragmentCode defines the fragment shader code to use
  28239. * @param context defines the webGL context to use (if not set, the current one will be used)
  28240. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28241. * @returns the new webGL program
  28242. */
  28243. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28244. /**
  28245. * Creates a webGL program
  28246. * @param vertexCode defines the vertex shader code to use
  28247. * @param fragmentCode defines the fragment shader code to use
  28248. * @param defines defines the string containing the defines to use to compile the shaders
  28249. * @param context defines the webGL context to use (if not set, the current one will be used)
  28250. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28251. * @returns the new webGL program
  28252. */
  28253. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28254. private _createShaderProgram;
  28255. private _finalizeProgram;
  28256. /** @hidden */
  28257. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28258. /** @hidden */
  28259. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28260. /**
  28261. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28262. * @param shaderProgram defines the webGL program to use
  28263. * @param uniformsNames defines the list of uniform names
  28264. * @returns an array of webGL uniform locations
  28265. */
  28266. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28267. /**
  28268. * Gets the lsit of active attributes for a given webGL program
  28269. * @param shaderProgram defines the webGL program to use
  28270. * @param attributesNames defines the list of attribute names to get
  28271. * @returns an array of indices indicating the offset of each attribute
  28272. */
  28273. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28274. /**
  28275. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28276. * @param effect defines the effect to activate
  28277. */
  28278. enableEffect(effect: Nullable<Effect>): void;
  28279. /**
  28280. * Set the value of an uniform to an array of int32
  28281. * @param uniform defines the webGL uniform location where to store the value
  28282. * @param array defines the array of int32 to store
  28283. */
  28284. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28285. /**
  28286. * Set the value of an uniform to an array of int32 (stored as vec2)
  28287. * @param uniform defines the webGL uniform location where to store the value
  28288. * @param array defines the array of int32 to store
  28289. */
  28290. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28291. /**
  28292. * Set the value of an uniform to an array of int32 (stored as vec3)
  28293. * @param uniform defines the webGL uniform location where to store the value
  28294. * @param array defines the array of int32 to store
  28295. */
  28296. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28297. /**
  28298. * Set the value of an uniform to an array of int32 (stored as vec4)
  28299. * @param uniform defines the webGL uniform location where to store the value
  28300. * @param array defines the array of int32 to store
  28301. */
  28302. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28303. /**
  28304. * Set the value of an uniform to an array of float32
  28305. * @param uniform defines the webGL uniform location where to store the value
  28306. * @param array defines the array of float32 to store
  28307. */
  28308. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28309. /**
  28310. * Set the value of an uniform to an array of float32 (stored as vec2)
  28311. * @param uniform defines the webGL uniform location where to store the value
  28312. * @param array defines the array of float32 to store
  28313. */
  28314. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28315. /**
  28316. * Set the value of an uniform to an array of float32 (stored as vec3)
  28317. * @param uniform defines the webGL uniform location where to store the value
  28318. * @param array defines the array of float32 to store
  28319. */
  28320. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28321. /**
  28322. * Set the value of an uniform to an array of float32 (stored as vec4)
  28323. * @param uniform defines the webGL uniform location where to store the value
  28324. * @param array defines the array of float32 to store
  28325. */
  28326. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28327. /**
  28328. * Set the value of an uniform to an array of number
  28329. * @param uniform defines the webGL uniform location where to store the value
  28330. * @param array defines the array of number to store
  28331. */
  28332. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28333. /**
  28334. * Set the value of an uniform to an array of number (stored as vec2)
  28335. * @param uniform defines the webGL uniform location where to store the value
  28336. * @param array defines the array of number to store
  28337. */
  28338. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28339. /**
  28340. * Set the value of an uniform to an array of number (stored as vec3)
  28341. * @param uniform defines the webGL uniform location where to store the value
  28342. * @param array defines the array of number to store
  28343. */
  28344. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28345. /**
  28346. * Set the value of an uniform to an array of number (stored as vec4)
  28347. * @param uniform defines the webGL uniform location where to store the value
  28348. * @param array defines the array of number to store
  28349. */
  28350. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28351. /**
  28352. * Set the value of an uniform to an array of float32 (stored as matrices)
  28353. * @param uniform defines the webGL uniform location where to store the value
  28354. * @param matrices defines the array of float32 to store
  28355. */
  28356. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28357. /**
  28358. * Set the value of an uniform to a matrix
  28359. * @param uniform defines the webGL uniform location where to store the value
  28360. * @param matrix defines the matrix to store
  28361. */
  28362. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28363. /**
  28364. * Set the value of an uniform to a matrix (3x3)
  28365. * @param uniform defines the webGL uniform location where to store the value
  28366. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28367. */
  28368. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28369. /**
  28370. * Set the value of an uniform to a matrix (2x2)
  28371. * @param uniform defines the webGL uniform location where to store the value
  28372. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28373. */
  28374. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28375. /**
  28376. * Set the value of an uniform to a number (int)
  28377. * @param uniform defines the webGL uniform location where to store the value
  28378. * @param value defines the int number to store
  28379. */
  28380. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28381. /**
  28382. * Set the value of an uniform to a number (float)
  28383. * @param uniform defines the webGL uniform location where to store the value
  28384. * @param value defines the float number to store
  28385. */
  28386. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28387. /**
  28388. * Set the value of an uniform to a vec2
  28389. * @param uniform defines the webGL uniform location where to store the value
  28390. * @param x defines the 1st component of the value
  28391. * @param y defines the 2nd component of the value
  28392. */
  28393. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28394. /**
  28395. * Set the value of an uniform to a vec3
  28396. * @param uniform defines the webGL uniform location where to store the value
  28397. * @param x defines the 1st component of the value
  28398. * @param y defines the 2nd component of the value
  28399. * @param z defines the 3rd component of the value
  28400. */
  28401. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28402. /**
  28403. * Set the value of an uniform to a boolean
  28404. * @param uniform defines the webGL uniform location where to store the value
  28405. * @param bool defines the boolean to store
  28406. */
  28407. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28408. /**
  28409. * Set the value of an uniform to a vec4
  28410. * @param uniform defines the webGL uniform location where to store the value
  28411. * @param x defines the 1st component of the value
  28412. * @param y defines the 2nd component of the value
  28413. * @param z defines the 3rd component of the value
  28414. * @param w defines the 4th component of the value
  28415. */
  28416. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28417. /**
  28418. * Set the value of an uniform to a Color3
  28419. * @param uniform defines the webGL uniform location where to store the value
  28420. * @param color3 defines the color to store
  28421. */
  28422. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28423. /**
  28424. * Set the value of an uniform to a Color3 and an alpha value
  28425. * @param uniform defines the webGL uniform location where to store the value
  28426. * @param color3 defines the color to store
  28427. * @param alpha defines the alpha component to store
  28428. */
  28429. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28430. /**
  28431. * Sets a Color4 on a uniform variable
  28432. * @param uniform defines the uniform location
  28433. * @param color4 defines the value to be set
  28434. */
  28435. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28436. /**
  28437. * Set various states to the webGL context
  28438. * @param culling defines backface culling state
  28439. * @param zOffset defines the value to apply to zOffset (0 by default)
  28440. * @param force defines if states must be applied even if cache is up to date
  28441. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28442. */
  28443. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28444. /**
  28445. * Set the z offset to apply to current rendering
  28446. * @param value defines the offset to apply
  28447. */
  28448. setZOffset(value: number): void;
  28449. /**
  28450. * Gets the current value of the zOffset
  28451. * @returns the current zOffset state
  28452. */
  28453. getZOffset(): number;
  28454. /**
  28455. * Enable or disable depth buffering
  28456. * @param enable defines the state to set
  28457. */
  28458. setDepthBuffer(enable: boolean): void;
  28459. /**
  28460. * Gets a boolean indicating if depth writing is enabled
  28461. * @returns the current depth writing state
  28462. */
  28463. getDepthWrite(): boolean;
  28464. /**
  28465. * Enable or disable depth writing
  28466. * @param enable defines the state to set
  28467. */
  28468. setDepthWrite(enable: boolean): void;
  28469. /**
  28470. * Enable or disable color writing
  28471. * @param enable defines the state to set
  28472. */
  28473. setColorWrite(enable: boolean): void;
  28474. /**
  28475. * Gets a boolean indicating if color writing is enabled
  28476. * @returns the current color writing state
  28477. */
  28478. getColorWrite(): boolean;
  28479. /**
  28480. * Sets alpha constants used by some alpha blending modes
  28481. * @param r defines the red component
  28482. * @param g defines the green component
  28483. * @param b defines the blue component
  28484. * @param a defines the alpha component
  28485. */
  28486. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28487. /**
  28488. * Sets the current alpha mode
  28489. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28490. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28491. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28492. */
  28493. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28494. /**
  28495. * Gets the current alpha mode
  28496. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28497. * @returns the current alpha mode
  28498. */
  28499. getAlphaMode(): number;
  28500. /**
  28501. * Clears the list of texture accessible through engine.
  28502. * This can help preventing texture load conflict due to name collision.
  28503. */
  28504. clearInternalTexturesCache(): void;
  28505. /**
  28506. * Force the entire cache to be cleared
  28507. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28508. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28509. */
  28510. wipeCaches(bruteForce?: boolean): void;
  28511. /**
  28512. * Set the compressed texture format to use, based on the formats you have, and the formats
  28513. * supported by the hardware / browser.
  28514. *
  28515. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28516. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28517. * to API arguments needed to compressed textures. This puts the burden on the container
  28518. * generator to house the arcane code for determining these for current & future formats.
  28519. *
  28520. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28521. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28522. *
  28523. * Note: The result of this call is not taken into account when a texture is base64.
  28524. *
  28525. * @param formatsAvailable defines the list of those format families you have created
  28526. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28527. *
  28528. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28529. * @returns The extension selected.
  28530. */
  28531. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28532. private _getSamplingParameters;
  28533. private _partialLoadImg;
  28534. private _cascadeLoadImgs;
  28535. /** @hidden */
  28536. _createTexture(): WebGLTexture;
  28537. /**
  28538. * Usually called from Texture.ts.
  28539. * Passed information to create a WebGLTexture
  28540. * @param urlArg defines a value which contains one of the following:
  28541. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28542. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28543. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28544. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28545. * @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)
  28546. * @param scene needed for loading to the correct scene
  28547. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28548. * @param onLoad optional callback to be called upon successful completion
  28549. * @param onError optional callback to be called upon failure
  28550. * @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
  28551. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28552. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28553. * @param forcedExtension defines the extension to use to pick the right loader
  28554. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28555. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28556. */
  28557. 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;
  28558. private _rescaleTexture;
  28559. /**
  28560. * Update a raw texture
  28561. * @param texture defines the texture to update
  28562. * @param data defines the data to store in the texture
  28563. * @param format defines the format of the data
  28564. * @param invertY defines if data must be stored with Y axis inverted
  28565. * @param compression defines the compression used (null by default)
  28566. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28567. */
  28568. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  28569. /**
  28570. * Creates a raw texture
  28571. * @param data defines the data to store in the texture
  28572. * @param width defines the width of the texture
  28573. * @param height defines the height of the texture
  28574. * @param format defines the format of the data
  28575. * @param generateMipMaps defines if the engine should generate the mip levels
  28576. * @param invertY defines if data must be stored with Y axis inverted
  28577. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28578. * @param compression defines the compression used (null by default)
  28579. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28580. * @returns the raw texture inside an InternalTexture
  28581. */
  28582. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  28583. private _unpackFlipYCached;
  28584. /**
  28585. * In case you are sharing the context with other applications, it might
  28586. * be interested to not cache the unpack flip y state to ensure a consistent
  28587. * value would be set.
  28588. */
  28589. enableUnpackFlipYCached: boolean;
  28590. /** @hidden */
  28591. _unpackFlipY(value: boolean): void;
  28592. /** @hidden */
  28593. _getUnpackAlignement(): number;
  28594. /**
  28595. * Creates a dynamic texture
  28596. * @param width defines the width of the texture
  28597. * @param height defines the height of the texture
  28598. * @param generateMipMaps defines if the engine should generate the mip levels
  28599. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28600. * @returns the dynamic texture inside an InternalTexture
  28601. */
  28602. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28603. /**
  28604. * Update the sampling mode of a given texture
  28605. * @param samplingMode defines the required sampling mode
  28606. * @param texture defines the texture to update
  28607. */
  28608. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28609. /**
  28610. * Update the content of a dynamic texture
  28611. * @param texture defines the texture to update
  28612. * @param canvas defines the canvas containing the source
  28613. * @param invertY defines if data must be stored with Y axis inverted
  28614. * @param premulAlpha defines if alpha is stored as premultiplied
  28615. * @param format defines the format of the data
  28616. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28617. */
  28618. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28619. /**
  28620. * Update a video texture
  28621. * @param texture defines the texture to update
  28622. * @param video defines the video element to use
  28623. * @param invertY defines if data must be stored with Y axis inverted
  28624. */
  28625. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28626. /**
  28627. * Updates a depth texture Comparison Mode and Function.
  28628. * If the comparison Function is equal to 0, the mode will be set to none.
  28629. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28630. * @param texture The texture to set the comparison function for
  28631. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28632. */
  28633. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28634. private _setupDepthStencilTexture;
  28635. /**
  28636. * Creates a depth stencil texture.
  28637. * This is only available in WebGL 2 or with the depth texture extension available.
  28638. * @param size The size of face edge in the texture.
  28639. * @param options The options defining the texture.
  28640. * @returns The texture
  28641. */
  28642. createDepthStencilTexture(size: number | {
  28643. width: number;
  28644. height: number;
  28645. }, options: DepthTextureCreationOptions): InternalTexture;
  28646. /**
  28647. * Creates a depth stencil texture.
  28648. * This is only available in WebGL 2 or with the depth texture extension available.
  28649. * @param size The size of face edge in the texture.
  28650. * @param options The options defining the texture.
  28651. * @returns The texture
  28652. */
  28653. private _createDepthStencilTexture;
  28654. /**
  28655. * Creates a depth stencil cube texture.
  28656. * This is only available in WebGL 2.
  28657. * @param size The size of face edge in the cube texture.
  28658. * @param options The options defining the cube texture.
  28659. * @returns The cube texture
  28660. */
  28661. private _createDepthStencilCubeTexture;
  28662. /**
  28663. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28664. * @param renderTarget The render target to set the frame buffer for
  28665. */
  28666. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28667. /**
  28668. * Creates a new render target texture
  28669. * @param size defines the size of the texture
  28670. * @param options defines the options used to create the texture
  28671. * @returns a new render target texture stored in an InternalTexture
  28672. */
  28673. createRenderTargetTexture(size: number | {
  28674. width: number;
  28675. height: number;
  28676. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28677. /**
  28678. * Create a multi render target texture
  28679. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  28680. * @param size defines the size of the texture
  28681. * @param options defines the creation options
  28682. * @returns the cube texture as an InternalTexture
  28683. */
  28684. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  28685. private _setupFramebufferDepthAttachments;
  28686. /**
  28687. * Updates the sample count of a render target texture
  28688. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28689. * @param texture defines the texture to update
  28690. * @param samples defines the sample count to set
  28691. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28692. */
  28693. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28694. /**
  28695. * Update the sample count for a given multiple render target texture
  28696. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28697. * @param textures defines the textures to update
  28698. * @param samples defines the sample count to set
  28699. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28700. */
  28701. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  28702. /** @hidden */
  28703. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28704. /** @hidden */
  28705. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28706. /** @hidden */
  28707. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28708. /** @hidden */
  28709. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28710. /**
  28711. * Creates a new render target cube texture
  28712. * @param size defines the size of the texture
  28713. * @param options defines the options used to create the texture
  28714. * @returns a new render target cube texture stored in an InternalTexture
  28715. */
  28716. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  28717. /**
  28718. * Creates a cube texture
  28719. * @param rootUrl defines the url where the files to load is located
  28720. * @param scene defines the current scene
  28721. * @param files defines the list of files to load (1 per face)
  28722. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  28723. * @param onLoad defines an optional callback raised when the texture is loaded
  28724. * @param onError defines an optional callback raised if there is an issue to load the texture
  28725. * @param format defines the format of the data
  28726. * @param forcedExtension defines the extension to use to pick the right loader
  28727. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  28728. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  28729. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  28730. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  28731. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  28732. * @returns the cube texture as an InternalTexture
  28733. */
  28734. 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;
  28735. /**
  28736. * @hidden
  28737. */
  28738. _setCubeMapTextureParams(loadMipmap: boolean): void;
  28739. /**
  28740. * Update a raw cube texture
  28741. * @param texture defines the texture to udpdate
  28742. * @param data defines the data to store
  28743. * @param format defines the data format
  28744. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28745. * @param invertY defines if data must be stored with Y axis inverted
  28746. * @param compression defines the compression used (null by default)
  28747. * @param level defines which level of the texture to update
  28748. */
  28749. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  28750. /**
  28751. * Creates a new raw cube texture
  28752. * @param data defines the array of data to use to create each face
  28753. * @param size defines the size of the textures
  28754. * @param format defines the format of the data
  28755. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28756. * @param generateMipMaps defines if the engine should generate the mip levels
  28757. * @param invertY defines if data must be stored with Y axis inverted
  28758. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28759. * @param compression defines the compression used (null by default)
  28760. * @returns the cube texture as an InternalTexture
  28761. */
  28762. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  28763. /**
  28764. * Creates a new raw cube texture from a specified url
  28765. * @param url defines the url where the data is located
  28766. * @param scene defines the current scene
  28767. * @param size defines the size of the textures
  28768. * @param format defines the format of the data
  28769. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28770. * @param noMipmap defines if the engine should avoid generating the mip levels
  28771. * @param callback defines a callback used to extract texture data from loaded data
  28772. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  28773. * @param onLoad defines a callback called when texture is loaded
  28774. * @param onError defines a callback called if there is an error
  28775. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28776. * @param invertY defines if data must be stored with Y axis inverted
  28777. * @returns the cube texture as an InternalTexture
  28778. */
  28779. 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;
  28780. /**
  28781. * Update a raw 3D texture
  28782. * @param texture defines the texture to update
  28783. * @param data defines the data to store
  28784. * @param format defines the data format
  28785. * @param invertY defines if data must be stored with Y axis inverted
  28786. * @param compression defines the used compression (can be null)
  28787. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  28788. */
  28789. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  28790. /**
  28791. * Creates a new raw 3D texture
  28792. * @param data defines the data used to create the texture
  28793. * @param width defines the width of the texture
  28794. * @param height defines the height of the texture
  28795. * @param depth defines the depth of the texture
  28796. * @param format defines the format of the texture
  28797. * @param generateMipMaps defines if the engine must generate mip levels
  28798. * @param invertY defines if data must be stored with Y axis inverted
  28799. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28800. * @param compression defines the compressed used (can be null)
  28801. * @param textureType defines the compressed used (can be null)
  28802. * @returns a new raw 3D texture (stored in an InternalTexture)
  28803. */
  28804. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  28805. private _prepareWebGLTextureContinuation;
  28806. private _prepareWebGLTexture;
  28807. private _convertRGBtoRGBATextureData;
  28808. /** @hidden */
  28809. _releaseFramebufferObjects(texture: InternalTexture): void;
  28810. /** @hidden */
  28811. _releaseTexture(texture: InternalTexture): void;
  28812. private setProgram;
  28813. private _boundUniforms;
  28814. /**
  28815. * Binds an effect to the webGL context
  28816. * @param effect defines the effect to bind
  28817. */
  28818. bindSamplers(effect: Effect): void;
  28819. private _moveBoundTextureOnTop;
  28820. private _getCorrectTextureChannel;
  28821. private _linkTrackers;
  28822. private _removeDesignatedSlot;
  28823. private _activateCurrentTexture;
  28824. /** @hidden */
  28825. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28826. /** @hidden */
  28827. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28828. /**
  28829. * Sets a texture to the webGL context from a postprocess
  28830. * @param channel defines the channel to use
  28831. * @param postProcess defines the source postprocess
  28832. */
  28833. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28834. /**
  28835. * Binds the output of the passed in post process to the texture channel specified
  28836. * @param channel The channel the texture should be bound to
  28837. * @param postProcess The post process which's output should be bound
  28838. */
  28839. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28840. /**
  28841. * Unbind all textures from the webGL context
  28842. */
  28843. unbindAllTextures(): void;
  28844. /**
  28845. * Sets a texture to the according uniform.
  28846. * @param channel The texture channel
  28847. * @param uniform The uniform to set
  28848. * @param texture The texture to apply
  28849. */
  28850. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28851. /**
  28852. * Sets a depth stencil texture from a render target to the according uniform.
  28853. * @param channel The texture channel
  28854. * @param uniform The uniform to set
  28855. * @param texture The render target texture containing the depth stencil texture to apply
  28856. */
  28857. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28858. private _bindSamplerUniformToChannel;
  28859. private _getTextureWrapMode;
  28860. private _setTexture;
  28861. /**
  28862. * Sets an array of texture to the webGL context
  28863. * @param channel defines the channel where the texture array must be set
  28864. * @param uniform defines the associated uniform location
  28865. * @param textures defines the array of textures to bind
  28866. */
  28867. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28868. /** @hidden */
  28869. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28870. private _setTextureParameterFloat;
  28871. private _setTextureParameterInteger;
  28872. /**
  28873. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28874. * @param x defines the x coordinate of the rectangle where pixels must be read
  28875. * @param y defines the y coordinate of the rectangle where pixels must be read
  28876. * @param width defines the width of the rectangle where pixels must be read
  28877. * @param height defines the height of the rectangle where pixels must be read
  28878. * @returns a Uint8Array containing RGBA colors
  28879. */
  28880. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28881. /**
  28882. * Add an externaly attached data from its key.
  28883. * This method call will fail and return false, if such key already exists.
  28884. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28885. * @param key the unique key that identifies the data
  28886. * @param data the data object to associate to the key for this Engine instance
  28887. * @return true if no such key were already present and the data was added successfully, false otherwise
  28888. */
  28889. addExternalData<T>(key: string, data: T): boolean;
  28890. /**
  28891. * Get an externaly attached data from its key
  28892. * @param key the unique key that identifies the data
  28893. * @return the associated data, if present (can be null), or undefined if not present
  28894. */
  28895. getExternalData<T>(key: string): T;
  28896. /**
  28897. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28898. * @param key the unique key that identifies the data
  28899. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28900. * @return the associated data, can be null if the factory returned null.
  28901. */
  28902. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28903. /**
  28904. * Remove an externaly attached data from the Engine instance
  28905. * @param key the unique key that identifies the data
  28906. * @return true if the data was successfully removed, false if it doesn't exist
  28907. */
  28908. removeExternalData(key: string): boolean;
  28909. /**
  28910. * Unbind all vertex attributes from the webGL context
  28911. */
  28912. unbindAllAttributes(): void;
  28913. /**
  28914. * 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
  28915. */
  28916. releaseEffects(): void;
  28917. /**
  28918. * Dispose and release all associated resources
  28919. */
  28920. dispose(): void;
  28921. /**
  28922. * Display the loading screen
  28923. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28924. */
  28925. displayLoadingUI(): void;
  28926. /**
  28927. * Hide the loading screen
  28928. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28929. */
  28930. hideLoadingUI(): void;
  28931. /**
  28932. * Gets the current loading screen object
  28933. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28934. */
  28935. /**
  28936. * Sets the current loading screen object
  28937. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28938. */
  28939. loadingScreen: ILoadingScreen;
  28940. /**
  28941. * Sets the current loading screen text
  28942. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28943. */
  28944. loadingUIText: string;
  28945. /**
  28946. * Sets the current loading screen background color
  28947. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28948. */
  28949. loadingUIBackgroundColor: string;
  28950. /**
  28951. * Attach a new callback raised when context lost event is fired
  28952. * @param callback defines the callback to call
  28953. */
  28954. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28955. /**
  28956. * Attach a new callback raised when context restored event is fired
  28957. * @param callback defines the callback to call
  28958. */
  28959. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28960. /**
  28961. * Gets the source code of the vertex shader associated with a specific webGL program
  28962. * @param program defines the program to use
  28963. * @returns a string containing the source code of the vertex shader associated with the program
  28964. */
  28965. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28966. /**
  28967. * Gets the source code of the fragment shader associated with a specific webGL program
  28968. * @param program defines the program to use
  28969. * @returns a string containing the source code of the fragment shader associated with the program
  28970. */
  28971. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28972. /**
  28973. * Get the current error code of the webGL context
  28974. * @returns the error code
  28975. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28976. */
  28977. getError(): number;
  28978. /**
  28979. * Gets the current framerate
  28980. * @returns a number representing the framerate
  28981. */
  28982. getFps(): number;
  28983. /**
  28984. * Gets the time spent between current and previous frame
  28985. * @returns a number representing the delta time in ms
  28986. */
  28987. getDeltaTime(): number;
  28988. private _measureFps;
  28989. /** @hidden */
  28990. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28991. private _canRenderToFloatFramebuffer;
  28992. private _canRenderToHalfFloatFramebuffer;
  28993. private _canRenderToFramebuffer;
  28994. /** @hidden */
  28995. _getWebGLTextureType(type: number): number;
  28996. private _getInternalFormat;
  28997. /** @hidden */
  28998. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28999. /** @hidden */
  29000. _getRGBAMultiSampleBufferFormat(type: number): number;
  29001. /** @hidden */
  29002. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  29003. /** @hidden */
  29004. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29005. private _partialLoadFile;
  29006. private _cascadeLoadFiles;
  29007. /**
  29008. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29009. * @returns true if the engine can be created
  29010. * @ignorenaming
  29011. */
  29012. static isSupported(): boolean;
  29013. }
  29014. }
  29015. declare module "babylonjs/Materials/effect" {
  29016. import { Observable } from "babylonjs/Misc/observable";
  29017. import { Nullable } from "babylonjs/types";
  29018. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  29019. import { Engine } from "babylonjs/Engines/engine";
  29020. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29021. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29022. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29023. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29024. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29025. /**
  29026. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29027. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29028. */
  29029. export class EffectFallbacks {
  29030. private _defines;
  29031. private _currentRank;
  29032. private _maxRank;
  29033. private _mesh;
  29034. /**
  29035. * Removes the fallback from the bound mesh.
  29036. */
  29037. unBindMesh(): void;
  29038. /**
  29039. * Adds a fallback on the specified property.
  29040. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29041. * @param define The name of the define in the shader
  29042. */
  29043. addFallback(rank: number, define: string): void;
  29044. /**
  29045. * Sets the mesh to use CPU skinning when needing to fallback.
  29046. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29047. * @param mesh The mesh to use the fallbacks.
  29048. */
  29049. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29050. /**
  29051. * Checks to see if more fallbacks are still availible.
  29052. */
  29053. readonly isMoreFallbacks: boolean;
  29054. /**
  29055. * Removes the defines that shoould be removed when falling back.
  29056. * @param currentDefines defines the current define statements for the shader.
  29057. * @param effect defines the current effect we try to compile
  29058. * @returns The resulting defines with defines of the current rank removed.
  29059. */
  29060. reduce(currentDefines: string, effect: Effect): string;
  29061. }
  29062. /**
  29063. * Options to be used when creating an effect.
  29064. */
  29065. export class EffectCreationOptions {
  29066. /**
  29067. * Atrributes that will be used in the shader.
  29068. */
  29069. attributes: string[];
  29070. /**
  29071. * Uniform varible names that will be set in the shader.
  29072. */
  29073. uniformsNames: string[];
  29074. /**
  29075. * Uniform buffer varible names that will be set in the shader.
  29076. */
  29077. uniformBuffersNames: string[];
  29078. /**
  29079. * Sampler texture variable names that will be set in the shader.
  29080. */
  29081. samplers: string[];
  29082. /**
  29083. * Define statements that will be set in the shader.
  29084. */
  29085. defines: any;
  29086. /**
  29087. * Possible fallbacks for this effect to improve performance when needed.
  29088. */
  29089. fallbacks: Nullable<EffectFallbacks>;
  29090. /**
  29091. * Callback that will be called when the shader is compiled.
  29092. */
  29093. onCompiled: Nullable<(effect: Effect) => void>;
  29094. /**
  29095. * Callback that will be called if an error occurs during shader compilation.
  29096. */
  29097. onError: Nullable<(effect: Effect, errors: string) => void>;
  29098. /**
  29099. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29100. */
  29101. indexParameters: any;
  29102. /**
  29103. * Max number of lights that can be used in the shader.
  29104. */
  29105. maxSimultaneousLights: number;
  29106. /**
  29107. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29108. */
  29109. transformFeedbackVaryings: Nullable<string[]>;
  29110. }
  29111. /**
  29112. * Effect containing vertex and fragment shader that can be executed on an object.
  29113. */
  29114. export class Effect {
  29115. /**
  29116. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29117. */
  29118. static ShadersRepository: string;
  29119. /**
  29120. * Name of the effect.
  29121. */
  29122. name: any;
  29123. /**
  29124. * String container all the define statements that should be set on the shader.
  29125. */
  29126. defines: string;
  29127. /**
  29128. * Callback that will be called when the shader is compiled.
  29129. */
  29130. onCompiled: Nullable<(effect: Effect) => void>;
  29131. /**
  29132. * Callback that will be called if an error occurs during shader compilation.
  29133. */
  29134. onError: Nullable<(effect: Effect, errors: string) => void>;
  29135. /**
  29136. * Callback that will be called when effect is bound.
  29137. */
  29138. onBind: Nullable<(effect: Effect) => void>;
  29139. /**
  29140. * Unique ID of the effect.
  29141. */
  29142. uniqueId: number;
  29143. /**
  29144. * Observable that will be called when the shader is compiled.
  29145. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29146. */
  29147. onCompileObservable: Observable<Effect>;
  29148. /**
  29149. * Observable that will be called if an error occurs during shader compilation.
  29150. */
  29151. onErrorObservable: Observable<Effect>;
  29152. /** @hidden */
  29153. _onBindObservable: Nullable<Observable<Effect>>;
  29154. /**
  29155. * Observable that will be called when effect is bound.
  29156. */
  29157. readonly onBindObservable: Observable<Effect>;
  29158. /** @hidden */
  29159. _bonesComputationForcedToCPU: boolean;
  29160. private static _uniqueIdSeed;
  29161. private _engine;
  29162. private _uniformBuffersNames;
  29163. private _uniformsNames;
  29164. private _samplers;
  29165. private _isReady;
  29166. private _compilationError;
  29167. private _attributesNames;
  29168. private _attributes;
  29169. private _uniforms;
  29170. /**
  29171. * Key for the effect.
  29172. * @hidden
  29173. */
  29174. _key: string;
  29175. private _indexParameters;
  29176. private _fallbacks;
  29177. private _vertexSourceCode;
  29178. private _fragmentSourceCode;
  29179. private _vertexSourceCodeOverride;
  29180. private _fragmentSourceCodeOverride;
  29181. private _transformFeedbackVaryings;
  29182. /**
  29183. * Compiled shader to webGL program.
  29184. * @hidden
  29185. */
  29186. _program: WebGLProgram;
  29187. private _valueCache;
  29188. private static _baseCache;
  29189. /**
  29190. * Instantiates an effect.
  29191. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29192. * @param baseName Name of the effect.
  29193. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29194. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29195. * @param samplers List of sampler variables that will be passed to the shader.
  29196. * @param engine Engine to be used to render the effect
  29197. * @param defines Define statements to be added to the shader.
  29198. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29199. * @param onCompiled Callback that will be called when the shader is compiled.
  29200. * @param onError Callback that will be called if an error occurs during shader compilation.
  29201. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29202. */
  29203. 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);
  29204. /**
  29205. * Unique key for this effect
  29206. */
  29207. readonly key: string;
  29208. /**
  29209. * If the effect has been compiled and prepared.
  29210. * @returns if the effect is compiled and prepared.
  29211. */
  29212. isReady(): boolean;
  29213. /**
  29214. * The engine the effect was initialized with.
  29215. * @returns the engine.
  29216. */
  29217. getEngine(): Engine;
  29218. /**
  29219. * The compiled webGL program for the effect
  29220. * @returns the webGL program.
  29221. */
  29222. getProgram(): WebGLProgram;
  29223. /**
  29224. * The set of names of attribute variables for the shader.
  29225. * @returns An array of attribute names.
  29226. */
  29227. getAttributesNames(): string[];
  29228. /**
  29229. * Returns the attribute at the given index.
  29230. * @param index The index of the attribute.
  29231. * @returns The location of the attribute.
  29232. */
  29233. getAttributeLocation(index: number): number;
  29234. /**
  29235. * Returns the attribute based on the name of the variable.
  29236. * @param name of the attribute to look up.
  29237. * @returns the attribute location.
  29238. */
  29239. getAttributeLocationByName(name: string): number;
  29240. /**
  29241. * The number of attributes.
  29242. * @returns the numnber of attributes.
  29243. */
  29244. getAttributesCount(): number;
  29245. /**
  29246. * Gets the index of a uniform variable.
  29247. * @param uniformName of the uniform to look up.
  29248. * @returns the index.
  29249. */
  29250. getUniformIndex(uniformName: string): number;
  29251. /**
  29252. * Returns the attribute based on the name of the variable.
  29253. * @param uniformName of the uniform to look up.
  29254. * @returns the location of the uniform.
  29255. */
  29256. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29257. /**
  29258. * Returns an array of sampler variable names
  29259. * @returns The array of sampler variable neames.
  29260. */
  29261. getSamplers(): string[];
  29262. /**
  29263. * The error from the last compilation.
  29264. * @returns the error string.
  29265. */
  29266. getCompilationError(): string;
  29267. /**
  29268. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29269. * @param func The callback to be used.
  29270. */
  29271. executeWhenCompiled(func: (effect: Effect) => void): void;
  29272. private _checkIsReady;
  29273. /** @hidden */
  29274. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29275. /** @hidden */
  29276. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29277. /** @hidden */
  29278. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29279. private _processShaderConversion;
  29280. private _processIncludes;
  29281. private _processPrecision;
  29282. /**
  29283. * Recompiles the webGL program
  29284. * @param vertexSourceCode The source code for the vertex shader.
  29285. * @param fragmentSourceCode The source code for the fragment shader.
  29286. * @param onCompiled Callback called when completed.
  29287. * @param onError Callback called on error.
  29288. * @hidden
  29289. */
  29290. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29291. /**
  29292. * Gets the uniform locations of the the specified variable names
  29293. * @param names THe names of the variables to lookup.
  29294. * @returns Array of locations in the same order as variable names.
  29295. */
  29296. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29297. /**
  29298. * Prepares the effect
  29299. * @hidden
  29300. */
  29301. _prepareEffect(): void;
  29302. /**
  29303. * Checks if the effect is supported. (Must be called after compilation)
  29304. */
  29305. readonly isSupported: boolean;
  29306. /**
  29307. * Binds a texture to the engine to be used as output of the shader.
  29308. * @param channel Name of the output variable.
  29309. * @param texture Texture to bind.
  29310. * @hidden
  29311. */
  29312. _bindTexture(channel: string, texture: InternalTexture): void;
  29313. /**
  29314. * Sets a texture on the engine to be used in the shader.
  29315. * @param channel Name of the sampler variable.
  29316. * @param texture Texture to set.
  29317. */
  29318. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29319. /**
  29320. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29321. * @param channel Name of the sampler variable.
  29322. * @param texture Texture to set.
  29323. */
  29324. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29325. /**
  29326. * Sets an array of textures on the engine to be used in the shader.
  29327. * @param channel Name of the variable.
  29328. * @param textures Textures to set.
  29329. */
  29330. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29331. /**
  29332. * 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)
  29333. * @param channel Name of the sampler variable.
  29334. * @param postProcess Post process to get the input texture from.
  29335. */
  29336. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29337. /**
  29338. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29339. * 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)
  29340. * @param channel Name of the sampler variable.
  29341. * @param postProcess Post process to get the output texture from.
  29342. */
  29343. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29344. /** @hidden */
  29345. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29346. /** @hidden */
  29347. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29348. /** @hidden */
  29349. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29350. /** @hidden */
  29351. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29352. /**
  29353. * Binds a buffer to a uniform.
  29354. * @param buffer Buffer to bind.
  29355. * @param name Name of the uniform variable to bind to.
  29356. */
  29357. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29358. /**
  29359. * Binds block to a uniform.
  29360. * @param blockName Name of the block to bind.
  29361. * @param index Index to bind.
  29362. */
  29363. bindUniformBlock(blockName: string, index: number): void;
  29364. /**
  29365. * Sets an interger value on a uniform variable.
  29366. * @param uniformName Name of the variable.
  29367. * @param value Value to be set.
  29368. * @returns this effect.
  29369. */
  29370. setInt(uniformName: string, value: number): Effect;
  29371. /**
  29372. * Sets an int array on a uniform variable.
  29373. * @param uniformName Name of the variable.
  29374. * @param array array to be set.
  29375. * @returns this effect.
  29376. */
  29377. setIntArray(uniformName: string, array: Int32Array): Effect;
  29378. /**
  29379. * 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)
  29380. * @param uniformName Name of the variable.
  29381. * @param array array to be set.
  29382. * @returns this effect.
  29383. */
  29384. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29385. /**
  29386. * 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)
  29387. * @param uniformName Name of the variable.
  29388. * @param array array to be set.
  29389. * @returns this effect.
  29390. */
  29391. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29392. /**
  29393. * 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)
  29394. * @param uniformName Name of the variable.
  29395. * @param array array to be set.
  29396. * @returns this effect.
  29397. */
  29398. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29399. /**
  29400. * Sets an float array on a uniform variable.
  29401. * @param uniformName Name of the variable.
  29402. * @param array array to be set.
  29403. * @returns this effect.
  29404. */
  29405. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29406. /**
  29407. * 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)
  29408. * @param uniformName Name of the variable.
  29409. * @param array array to be set.
  29410. * @returns this effect.
  29411. */
  29412. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29413. /**
  29414. * 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)
  29415. * @param uniformName Name of the variable.
  29416. * @param array array to be set.
  29417. * @returns this effect.
  29418. */
  29419. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29420. /**
  29421. * 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)
  29422. * @param uniformName Name of the variable.
  29423. * @param array array to be set.
  29424. * @returns this effect.
  29425. */
  29426. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29427. /**
  29428. * Sets an array on a uniform variable.
  29429. * @param uniformName Name of the variable.
  29430. * @param array array to be set.
  29431. * @returns this effect.
  29432. */
  29433. setArray(uniformName: string, array: number[]): Effect;
  29434. /**
  29435. * 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)
  29436. * @param uniformName Name of the variable.
  29437. * @param array array to be set.
  29438. * @returns this effect.
  29439. */
  29440. setArray2(uniformName: string, array: number[]): Effect;
  29441. /**
  29442. * 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)
  29443. * @param uniformName Name of the variable.
  29444. * @param array array to be set.
  29445. * @returns this effect.
  29446. */
  29447. setArray3(uniformName: string, array: number[]): Effect;
  29448. /**
  29449. * 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)
  29450. * @param uniformName Name of the variable.
  29451. * @param array array to be set.
  29452. * @returns this effect.
  29453. */
  29454. setArray4(uniformName: string, array: number[]): Effect;
  29455. /**
  29456. * Sets matrices on a uniform variable.
  29457. * @param uniformName Name of the variable.
  29458. * @param matrices matrices to be set.
  29459. * @returns this effect.
  29460. */
  29461. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29462. /**
  29463. * Sets matrix on a uniform variable.
  29464. * @param uniformName Name of the variable.
  29465. * @param matrix matrix to be set.
  29466. * @returns this effect.
  29467. */
  29468. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29469. /**
  29470. * 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)
  29471. * @param uniformName Name of the variable.
  29472. * @param matrix matrix to be set.
  29473. * @returns this effect.
  29474. */
  29475. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29476. /**
  29477. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29478. * @param uniformName Name of the variable.
  29479. * @param matrix matrix to be set.
  29480. * @returns this effect.
  29481. */
  29482. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29483. /**
  29484. * Sets a float on a uniform variable.
  29485. * @param uniformName Name of the variable.
  29486. * @param value value to be set.
  29487. * @returns this effect.
  29488. */
  29489. setFloat(uniformName: string, value: number): Effect;
  29490. /**
  29491. * Sets a boolean on a uniform variable.
  29492. * @param uniformName Name of the variable.
  29493. * @param bool value to be set.
  29494. * @returns this effect.
  29495. */
  29496. setBool(uniformName: string, bool: boolean): Effect;
  29497. /**
  29498. * Sets a Vector2 on a uniform variable.
  29499. * @param uniformName Name of the variable.
  29500. * @param vector2 vector2 to be set.
  29501. * @returns this effect.
  29502. */
  29503. setVector2(uniformName: string, vector2: Vector2): Effect;
  29504. /**
  29505. * Sets a float2 on a uniform variable.
  29506. * @param uniformName Name of the variable.
  29507. * @param x First float in float2.
  29508. * @param y Second float in float2.
  29509. * @returns this effect.
  29510. */
  29511. setFloat2(uniformName: string, x: number, y: number): Effect;
  29512. /**
  29513. * Sets a Vector3 on a uniform variable.
  29514. * @param uniformName Name of the variable.
  29515. * @param vector3 Value to be set.
  29516. * @returns this effect.
  29517. */
  29518. setVector3(uniformName: string, vector3: Vector3): Effect;
  29519. /**
  29520. * Sets a float3 on a uniform variable.
  29521. * @param uniformName Name of the variable.
  29522. * @param x First float in float3.
  29523. * @param y Second float in float3.
  29524. * @param z Third float in float3.
  29525. * @returns this effect.
  29526. */
  29527. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29528. /**
  29529. * Sets a Vector4 on a uniform variable.
  29530. * @param uniformName Name of the variable.
  29531. * @param vector4 Value to be set.
  29532. * @returns this effect.
  29533. */
  29534. setVector4(uniformName: string, vector4: Vector4): Effect;
  29535. /**
  29536. * Sets a float4 on a uniform variable.
  29537. * @param uniformName Name of the variable.
  29538. * @param x First float in float4.
  29539. * @param y Second float in float4.
  29540. * @param z Third float in float4.
  29541. * @param w Fourth float in float4.
  29542. * @returns this effect.
  29543. */
  29544. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29545. /**
  29546. * Sets a Color3 on a uniform variable.
  29547. * @param uniformName Name of the variable.
  29548. * @param color3 Value to be set.
  29549. * @returns this effect.
  29550. */
  29551. setColor3(uniformName: string, color3: Color3): Effect;
  29552. /**
  29553. * Sets a Color4 on a uniform variable.
  29554. * @param uniformName Name of the variable.
  29555. * @param color3 Value to be set.
  29556. * @param alpha Alpha value to be set.
  29557. * @returns this effect.
  29558. */
  29559. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29560. /**
  29561. * Sets a Color4 on a uniform variable
  29562. * @param uniformName defines the name of the variable
  29563. * @param color4 defines the value to be set
  29564. * @returns this effect.
  29565. */
  29566. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29567. /**
  29568. * This function will add a new shader to the shader store
  29569. * @param name the name of the shader
  29570. * @param pixelShader optional pixel shader content
  29571. * @param vertexShader optional vertex shader content
  29572. */
  29573. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29574. /**
  29575. * Store of each shader (The can be looked up using effect.key)
  29576. */
  29577. static ShadersStore: {
  29578. [key: string]: string;
  29579. };
  29580. /**
  29581. * Store of each included file for a shader (The can be looked up using effect.key)
  29582. */
  29583. static IncludesShadersStore: {
  29584. [key: string]: string;
  29585. };
  29586. /**
  29587. * Resets the cache of effects.
  29588. */
  29589. static ResetCache(): void;
  29590. }
  29591. }
  29592. declare module "babylonjs/Materials/colorCurves" {
  29593. import { Effect } from "babylonjs/Materials/effect";
  29594. /**
  29595. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29596. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29597. * 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;
  29598. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29599. */
  29600. export class ColorCurves {
  29601. private _dirty;
  29602. private _tempColor;
  29603. private _globalCurve;
  29604. private _highlightsCurve;
  29605. private _midtonesCurve;
  29606. private _shadowsCurve;
  29607. private _positiveCurve;
  29608. private _negativeCurve;
  29609. private _globalHue;
  29610. private _globalDensity;
  29611. private _globalSaturation;
  29612. private _globalExposure;
  29613. /**
  29614. * Gets the global Hue value.
  29615. * 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).
  29616. */
  29617. /**
  29618. * Sets the global 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. globalHue: number;
  29622. /**
  29623. * Gets the global Density value.
  29624. * 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.
  29625. * Values less than zero provide a filter of opposite hue.
  29626. */
  29627. /**
  29628. * Sets the global Density value.
  29629. * 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.
  29630. * Values less than zero provide a filter of opposite hue.
  29631. */
  29632. globalDensity: number;
  29633. /**
  29634. * Gets the global Saturation value.
  29635. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  29636. */
  29637. /**
  29638. * Sets the global 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. globalSaturation: number;
  29642. /**
  29643. * Gets the global Exposure value.
  29644. * 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.
  29645. */
  29646. /**
  29647. * Sets the global 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. globalExposure: number;
  29651. private _highlightsHue;
  29652. private _highlightsDensity;
  29653. private _highlightsSaturation;
  29654. private _highlightsExposure;
  29655. /**
  29656. * Gets the highlights Hue value.
  29657. * 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).
  29658. */
  29659. /**
  29660. * Sets the highlights 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. highlightsHue: number;
  29664. /**
  29665. * Gets the highlights Density value.
  29666. * 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.
  29667. * Values less than zero provide a filter of opposite hue.
  29668. */
  29669. /**
  29670. * Sets the highlights Density value.
  29671. * 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.
  29672. * Values less than zero provide a filter of opposite hue.
  29673. */
  29674. highlightsDensity: number;
  29675. /**
  29676. * Gets the highlights Saturation value.
  29677. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  29678. */
  29679. /**
  29680. * Sets the highlights 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. highlightsSaturation: number;
  29684. /**
  29685. * Gets the highlights Exposure value.
  29686. * 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.
  29687. */
  29688. /**
  29689. * Sets the highlights 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. highlightsExposure: number;
  29693. private _midtonesHue;
  29694. private _midtonesDensity;
  29695. private _midtonesSaturation;
  29696. private _midtonesExposure;
  29697. /**
  29698. * Gets the midtones Hue value.
  29699. * 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).
  29700. */
  29701. /**
  29702. * Sets the midtones Hue value.
  29703. * 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).
  29704. */
  29705. midtonesHue: number;
  29706. /**
  29707. * Gets the midtones Density value.
  29708. * 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.
  29709. * Values less than zero provide a filter of opposite hue.
  29710. */
  29711. /**
  29712. * Sets the midtones Density value.
  29713. * 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.
  29714. * Values less than zero provide a filter of opposite hue.
  29715. */
  29716. midtonesDensity: number;
  29717. /**
  29718. * Gets the midtones Saturation value.
  29719. * 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.
  29720. */
  29721. /**
  29722. * Sets the midtones Saturation value.
  29723. * 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.
  29724. */
  29725. midtonesSaturation: number;
  29726. /**
  29727. * Gets the midtones Exposure value.
  29728. * 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.
  29729. */
  29730. /**
  29731. * Sets the midtones Exposure value.
  29732. * 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.
  29733. */
  29734. midtonesExposure: number;
  29735. private _shadowsHue;
  29736. private _shadowsDensity;
  29737. private _shadowsSaturation;
  29738. private _shadowsExposure;
  29739. /**
  29740. * Gets the shadows Hue value.
  29741. * 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).
  29742. */
  29743. /**
  29744. * Sets the shadows Hue value.
  29745. * 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).
  29746. */
  29747. shadowsHue: number;
  29748. /**
  29749. * Gets the shadows Density value.
  29750. * 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.
  29751. * Values less than zero provide a filter of opposite hue.
  29752. */
  29753. /**
  29754. * Sets the shadows Density value.
  29755. * 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.
  29756. * Values less than zero provide a filter of opposite hue.
  29757. */
  29758. shadowsDensity: number;
  29759. /**
  29760. * Gets the shadows Saturation value.
  29761. * 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.
  29762. */
  29763. /**
  29764. * Sets the shadows Saturation value.
  29765. * 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.
  29766. */
  29767. shadowsSaturation: number;
  29768. /**
  29769. * Gets the shadows Exposure value.
  29770. * 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.
  29771. */
  29772. /**
  29773. * Sets the shadows Exposure value.
  29774. * 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.
  29775. */
  29776. shadowsExposure: number;
  29777. /**
  29778. * Returns the class name
  29779. * @returns The class name
  29780. */
  29781. getClassName(): string;
  29782. /**
  29783. * Binds the color curves to the shader.
  29784. * @param colorCurves The color curve to bind
  29785. * @param effect The effect to bind to
  29786. * @param positiveUniform The positive uniform shader parameter
  29787. * @param neutralUniform The neutral uniform shader parameter
  29788. * @param negativeUniform The negative uniform shader parameter
  29789. */
  29790. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29791. /**
  29792. * Prepare the list of uniforms associated with the ColorCurves effects.
  29793. * @param uniformsList The list of uniforms used in the effect
  29794. */
  29795. static PrepareUniforms(uniformsList: string[]): void;
  29796. /**
  29797. * Returns color grading data based on a hue, density, saturation and exposure value.
  29798. * @param filterHue The hue of the color filter.
  29799. * @param filterDensity The density of the color filter.
  29800. * @param saturation The saturation.
  29801. * @param exposure The exposure.
  29802. * @param result The result data container.
  29803. */
  29804. private getColorGradingDataToRef;
  29805. /**
  29806. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29807. * @param value The input slider value in range [-100,100].
  29808. * @returns Adjusted value.
  29809. */
  29810. private static applyColorGradingSliderNonlinear;
  29811. /**
  29812. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29813. * @param hue The hue (H) input.
  29814. * @param saturation The saturation (S) input.
  29815. * @param brightness The brightness (B) input.
  29816. * @result An RGBA color represented as Vector4.
  29817. */
  29818. private static fromHSBToRef;
  29819. /**
  29820. * Returns a value clamped between min and max
  29821. * @param value The value to clamp
  29822. * @param min The minimum of value
  29823. * @param max The maximum of value
  29824. * @returns The clamped value.
  29825. */
  29826. private static clamp;
  29827. /**
  29828. * Clones the current color curve instance.
  29829. * @return The cloned curves
  29830. */
  29831. clone(): ColorCurves;
  29832. /**
  29833. * Serializes the current color curve instance to a json representation.
  29834. * @return a JSON representation
  29835. */
  29836. serialize(): any;
  29837. /**
  29838. * Parses the color curve from a json representation.
  29839. * @param source the JSON source to parse
  29840. * @return The parsed curves
  29841. */
  29842. static Parse(source: any): ColorCurves;
  29843. }
  29844. }
  29845. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  29846. import { Observable } from "babylonjs/Misc/observable";
  29847. import { Nullable } from "babylonjs/types";
  29848. import { Color4 } from "babylonjs/Maths/math";
  29849. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  29850. import { Effect } from "babylonjs/Materials/effect";
  29851. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29852. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  29853. /**
  29854. * Interface to follow in your material defines to integrate easily the
  29855. * Image proccessing functions.
  29856. * @hidden
  29857. */
  29858. export interface IImageProcessingConfigurationDefines {
  29859. IMAGEPROCESSING: boolean;
  29860. VIGNETTE: boolean;
  29861. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29862. VIGNETTEBLENDMODEOPAQUE: boolean;
  29863. TONEMAPPING: boolean;
  29864. TONEMAPPING_ACES: boolean;
  29865. CONTRAST: boolean;
  29866. EXPOSURE: boolean;
  29867. COLORCURVES: boolean;
  29868. COLORGRADING: boolean;
  29869. COLORGRADING3D: boolean;
  29870. SAMPLER3DGREENDEPTH: boolean;
  29871. SAMPLER3DBGRMAP: boolean;
  29872. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29873. }
  29874. /**
  29875. * @hidden
  29876. */
  29877. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29878. IMAGEPROCESSING: boolean;
  29879. VIGNETTE: boolean;
  29880. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29881. VIGNETTEBLENDMODEOPAQUE: boolean;
  29882. TONEMAPPING: boolean;
  29883. TONEMAPPING_ACES: boolean;
  29884. CONTRAST: boolean;
  29885. COLORCURVES: boolean;
  29886. COLORGRADING: boolean;
  29887. COLORGRADING3D: boolean;
  29888. SAMPLER3DGREENDEPTH: boolean;
  29889. SAMPLER3DBGRMAP: boolean;
  29890. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29891. EXPOSURE: boolean;
  29892. constructor();
  29893. }
  29894. /**
  29895. * This groups together the common properties used for image processing either in direct forward pass
  29896. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29897. * or not.
  29898. */
  29899. export class ImageProcessingConfiguration {
  29900. /**
  29901. * Default tone mapping applied in BabylonJS.
  29902. */
  29903. static readonly TONEMAPPING_STANDARD: number;
  29904. /**
  29905. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29906. * to other engines rendering to increase portability.
  29907. */
  29908. static readonly TONEMAPPING_ACES: number;
  29909. /**
  29910. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29911. */
  29912. colorCurves: Nullable<ColorCurves>;
  29913. private _colorCurvesEnabled;
  29914. /**
  29915. * Gets wether the color curves effect is enabled.
  29916. */
  29917. /**
  29918. * Sets wether the color curves effect is enabled.
  29919. */
  29920. colorCurvesEnabled: boolean;
  29921. private _colorGradingTexture;
  29922. /**
  29923. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29924. */
  29925. /**
  29926. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29927. */
  29928. colorGradingTexture: Nullable<BaseTexture>;
  29929. private _colorGradingEnabled;
  29930. /**
  29931. * Gets wether the color grading effect is enabled.
  29932. */
  29933. /**
  29934. * Sets wether the color grading effect is enabled.
  29935. */
  29936. colorGradingEnabled: boolean;
  29937. private _colorGradingWithGreenDepth;
  29938. /**
  29939. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29940. */
  29941. /**
  29942. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29943. */
  29944. colorGradingWithGreenDepth: boolean;
  29945. private _colorGradingBGR;
  29946. /**
  29947. * Gets wether the color grading texture contains BGR values.
  29948. */
  29949. /**
  29950. * Sets wether the color grading texture contains BGR values.
  29951. */
  29952. colorGradingBGR: boolean;
  29953. /** @hidden */
  29954. _exposure: number;
  29955. /**
  29956. * Gets the Exposure used in the effect.
  29957. */
  29958. /**
  29959. * Sets the Exposure used in the effect.
  29960. */
  29961. exposure: number;
  29962. private _toneMappingEnabled;
  29963. /**
  29964. * Gets wether the tone mapping effect is enabled.
  29965. */
  29966. /**
  29967. * Sets wether the tone mapping effect is enabled.
  29968. */
  29969. toneMappingEnabled: boolean;
  29970. private _toneMappingType;
  29971. /**
  29972. * Gets the type of tone mapping effect.
  29973. */
  29974. /**
  29975. * Sets the type of tone mapping effect used in BabylonJS.
  29976. */
  29977. toneMappingType: number;
  29978. protected _contrast: number;
  29979. /**
  29980. * Gets the contrast used in the effect.
  29981. */
  29982. /**
  29983. * Sets the contrast used in the effect.
  29984. */
  29985. contrast: number;
  29986. /**
  29987. * Vignette stretch size.
  29988. */
  29989. vignetteStretch: number;
  29990. /**
  29991. * Vignette centre X Offset.
  29992. */
  29993. vignetteCentreX: number;
  29994. /**
  29995. * Vignette centre Y Offset.
  29996. */
  29997. vignetteCentreY: number;
  29998. /**
  29999. * Vignette weight or intensity of the vignette effect.
  30000. */
  30001. vignetteWeight: number;
  30002. /**
  30003. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30004. * if vignetteEnabled is set to true.
  30005. */
  30006. vignetteColor: Color4;
  30007. /**
  30008. * Camera field of view used by the Vignette effect.
  30009. */
  30010. vignetteCameraFov: number;
  30011. private _vignetteBlendMode;
  30012. /**
  30013. * Gets the vignette blend mode allowing different kind of effect.
  30014. */
  30015. /**
  30016. * Sets the vignette blend mode allowing different kind of effect.
  30017. */
  30018. vignetteBlendMode: number;
  30019. private _vignetteEnabled;
  30020. /**
  30021. * Gets wether the vignette effect is enabled.
  30022. */
  30023. /**
  30024. * Sets wether the vignette effect is enabled.
  30025. */
  30026. vignetteEnabled: boolean;
  30027. private _applyByPostProcess;
  30028. /**
  30029. * Gets wether the image processing is applied through a post process or not.
  30030. */
  30031. /**
  30032. * Sets wether the image processing is applied through a post process or not.
  30033. */
  30034. applyByPostProcess: boolean;
  30035. private _isEnabled;
  30036. /**
  30037. * Gets wether the image processing is enabled or not.
  30038. */
  30039. /**
  30040. * Sets wether the image processing is enabled or not.
  30041. */
  30042. isEnabled: boolean;
  30043. /**
  30044. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30045. */
  30046. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30047. /**
  30048. * Method called each time the image processing information changes requires to recompile the effect.
  30049. */
  30050. protected _updateParameters(): void;
  30051. /**
  30052. * Gets the current class name.
  30053. * @return "ImageProcessingConfiguration"
  30054. */
  30055. getClassName(): string;
  30056. /**
  30057. * Prepare the list of uniforms associated with the Image Processing effects.
  30058. * @param uniforms The list of uniforms used in the effect
  30059. * @param defines the list of defines currently in use
  30060. */
  30061. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30062. /**
  30063. * Prepare the list of samplers associated with the Image Processing effects.
  30064. * @param samplersList The list of uniforms used in the effect
  30065. * @param defines the list of defines currently in use
  30066. */
  30067. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30068. /**
  30069. * Prepare the list of defines associated to the shader.
  30070. * @param defines the list of defines to complete
  30071. * @param forPostProcess Define if we are currently in post process mode or not
  30072. */
  30073. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30074. /**
  30075. * Returns true if all the image processing information are ready.
  30076. * @returns True if ready, otherwise, false
  30077. */
  30078. isReady(): boolean;
  30079. /**
  30080. * Binds the image processing to the shader.
  30081. * @param effect The effect to bind to
  30082. * @param aspectRatio Define the current aspect ratio of the effect
  30083. */
  30084. bind(effect: Effect, aspectRatio?: number): void;
  30085. /**
  30086. * Clones the current image processing instance.
  30087. * @return The cloned image processing
  30088. */
  30089. clone(): ImageProcessingConfiguration;
  30090. /**
  30091. * Serializes the current image processing instance to a json representation.
  30092. * @return a JSON representation
  30093. */
  30094. serialize(): any;
  30095. /**
  30096. * Parses the image processing from a json representation.
  30097. * @param source the JSON source to parse
  30098. * @return The parsed image processing
  30099. */
  30100. static Parse(source: any): ImageProcessingConfiguration;
  30101. private static _VIGNETTEMODE_MULTIPLY;
  30102. private static _VIGNETTEMODE_OPAQUE;
  30103. /**
  30104. * Used to apply the vignette as a mix with the pixel color.
  30105. */
  30106. static readonly VIGNETTEMODE_MULTIPLY: number;
  30107. /**
  30108. * Used to apply the vignette as a replacement of the pixel color.
  30109. */
  30110. static readonly VIGNETTEMODE_OPAQUE: number;
  30111. }
  30112. }
  30113. declare module "babylonjs/Materials/fresnelParameters" {
  30114. import { Color3 } from "babylonjs/Maths/math";
  30115. /**
  30116. * This represents all the required information to add a fresnel effect on a material:
  30117. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30118. */
  30119. export class FresnelParameters {
  30120. private _isEnabled;
  30121. /**
  30122. * Define if the fresnel effect is enable or not.
  30123. */
  30124. isEnabled: boolean;
  30125. /**
  30126. * Define the color used on edges (grazing angle)
  30127. */
  30128. leftColor: Color3;
  30129. /**
  30130. * Define the color used on center
  30131. */
  30132. rightColor: Color3;
  30133. /**
  30134. * Define bias applied to computed fresnel term
  30135. */
  30136. bias: number;
  30137. /**
  30138. * Defined the power exponent applied to fresnel term
  30139. */
  30140. power: number;
  30141. /**
  30142. * Clones the current fresnel and its valuues
  30143. * @returns a clone fresnel configuration
  30144. */
  30145. clone(): FresnelParameters;
  30146. /**
  30147. * Serializes the current fresnel parameters to a JSON representation.
  30148. * @return the JSON serialization
  30149. */
  30150. serialize(): any;
  30151. /**
  30152. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30153. * @param parsedFresnelParameters Define the JSON representation
  30154. * @returns the parsed parameters
  30155. */
  30156. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30157. }
  30158. }
  30159. declare module "babylonjs/Misc/decorators" {
  30160. import { Nullable } from "babylonjs/types";
  30161. import { Scene } from "babylonjs/scene";
  30162. import { IAnimatable } from "babylonjs/Misc/tools";
  30163. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30164. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30165. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30166. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30167. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30168. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30169. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30170. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30171. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30172. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30173. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30174. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30175. /**
  30176. * Decorator used to define property that can be serialized as reference to a camera
  30177. * @param sourceName defines the name of the property to decorate
  30178. */
  30179. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30180. /**
  30181. * Class used to help serialization objects
  30182. */
  30183. export class SerializationHelper {
  30184. /** hidden */
  30185. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30186. /** hidden */
  30187. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30188. /** hidden */
  30189. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30190. /** hidden */
  30191. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30192. /**
  30193. * Appends the serialized animations from the source animations
  30194. * @param source Source containing the animations
  30195. * @param destination Target to store the animations
  30196. */
  30197. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30198. /**
  30199. * Static function used to serialized a specific entity
  30200. * @param entity defines the entity to serialize
  30201. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30202. * @returns a JSON compatible object representing the serialization of the entity
  30203. */
  30204. static Serialize<T>(entity: T, serializationObject?: any): any;
  30205. /**
  30206. * Creates a new entity from a serialization data object
  30207. * @param creationFunction defines a function used to instanciated the new entity
  30208. * @param source defines the source serialization data
  30209. * @param scene defines the hosting scene
  30210. * @param rootUrl defines the root url for resources
  30211. * @returns a new entity
  30212. */
  30213. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30214. /**
  30215. * Clones an object
  30216. * @param creationFunction defines the function used to instanciate the new object
  30217. * @param source defines the source object
  30218. * @returns the cloned object
  30219. */
  30220. static Clone<T>(creationFunction: () => T, source: T): T;
  30221. /**
  30222. * Instanciates a new object based on a source one (some data will be shared between both object)
  30223. * @param creationFunction defines the function used to instanciate the new object
  30224. * @param source defines the source object
  30225. * @returns the new object
  30226. */
  30227. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30228. }
  30229. }
  30230. declare module "babylonjs/Cameras/camera" {
  30231. import { SmartArray } from "babylonjs/Misc/smartArray";
  30232. import { Observable } from "babylonjs/Misc/observable";
  30233. import { Nullable } from "babylonjs/types";
  30234. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30235. import { Scene } from "babylonjs/scene";
  30236. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30237. import { Node } from "babylonjs/node";
  30238. import { Mesh } from "babylonjs/Meshes/mesh";
  30239. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30240. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30241. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30242. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30243. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30244. import { Ray } from "babylonjs/Culling/ray";
  30245. /**
  30246. * This is the base class of all the camera used in the application.
  30247. * @see http://doc.babylonjs.com/features/cameras
  30248. */
  30249. export class Camera extends Node {
  30250. /** @hidden */
  30251. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30252. /**
  30253. * This is the default projection mode used by the cameras.
  30254. * It helps recreating a feeling of perspective and better appreciate depth.
  30255. * This is the best way to simulate real life cameras.
  30256. */
  30257. static readonly PERSPECTIVE_CAMERA: number;
  30258. /**
  30259. * This helps creating camera with an orthographic mode.
  30260. * 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.
  30261. */
  30262. static readonly ORTHOGRAPHIC_CAMERA: number;
  30263. /**
  30264. * This is the default FOV mode for perspective cameras.
  30265. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30266. */
  30267. static readonly FOVMODE_VERTICAL_FIXED: number;
  30268. /**
  30269. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30270. */
  30271. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30272. /**
  30273. * This specifies ther is no need for a camera rig.
  30274. * Basically only one eye is rendered corresponding to the camera.
  30275. */
  30276. static readonly RIG_MODE_NONE: number;
  30277. /**
  30278. * Simulates a camera Rig with one blue eye and one red eye.
  30279. * This can be use with 3d blue and red glasses.
  30280. */
  30281. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30282. /**
  30283. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30284. */
  30285. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30286. /**
  30287. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30288. */
  30289. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30290. /**
  30291. * Defines that both eyes of the camera will be rendered over under each other.
  30292. */
  30293. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30294. /**
  30295. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30296. */
  30297. static readonly RIG_MODE_VR: number;
  30298. /**
  30299. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30300. */
  30301. static readonly RIG_MODE_WEBVR: number;
  30302. /**
  30303. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30304. */
  30305. static readonly RIG_MODE_CUSTOM: number;
  30306. /**
  30307. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30308. */
  30309. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30310. /**
  30311. * @hidden
  30312. * Might be removed once multiview will be a thing
  30313. */
  30314. static UseAlternateWebVRRendering: boolean;
  30315. /**
  30316. * Define the input manager associated with the camera.
  30317. */
  30318. inputs: CameraInputsManager<Camera>;
  30319. /** @hidden */
  30320. _position: Vector3;
  30321. /**
  30322. * Define the current local position of the camera in the scene
  30323. */
  30324. position: Vector3;
  30325. /**
  30326. * The vector the camera should consider as up.
  30327. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30328. */
  30329. upVector: Vector3;
  30330. /**
  30331. * Define the current limit on the left side for an orthographic camera
  30332. * In scene unit
  30333. */
  30334. orthoLeft: Nullable<number>;
  30335. /**
  30336. * Define the current limit on the right side for an orthographic camera
  30337. * In scene unit
  30338. */
  30339. orthoRight: Nullable<number>;
  30340. /**
  30341. * Define the current limit on the bottom side for an orthographic camera
  30342. * In scene unit
  30343. */
  30344. orthoBottom: Nullable<number>;
  30345. /**
  30346. * Define the current limit on the top side for an orthographic camera
  30347. * In scene unit
  30348. */
  30349. orthoTop: Nullable<number>;
  30350. /**
  30351. * Field Of View is set in Radians. (default is 0.8)
  30352. */
  30353. fov: number;
  30354. /**
  30355. * Define the minimum distance the camera can see from.
  30356. * This is important to note that the depth buffer are not infinite and the closer it starts
  30357. * the more your scene might encounter depth fighting issue.
  30358. */
  30359. minZ: number;
  30360. /**
  30361. * Define the maximum distance the camera can see to.
  30362. * This is important to note that the depth buffer are not infinite and the further it end
  30363. * the more your scene might encounter depth fighting issue.
  30364. */
  30365. maxZ: number;
  30366. /**
  30367. * Define the default inertia of the camera.
  30368. * This helps giving a smooth feeling to the camera movement.
  30369. */
  30370. inertia: number;
  30371. /**
  30372. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30373. */
  30374. mode: number;
  30375. /**
  30376. * Define wether the camera is intermediate.
  30377. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30378. */
  30379. isIntermediate: boolean;
  30380. /**
  30381. * Define the viewport of the camera.
  30382. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30383. */
  30384. viewport: Viewport;
  30385. /**
  30386. * Restricts the camera to viewing objects with the same layerMask.
  30387. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30388. */
  30389. layerMask: number;
  30390. /**
  30391. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30392. */
  30393. fovMode: number;
  30394. /**
  30395. * Rig mode of the camera.
  30396. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30397. * This is normally controlled byt the camera themselves as internal use.
  30398. */
  30399. cameraRigMode: number;
  30400. /**
  30401. * Defines the distance between both "eyes" in case of a RIG
  30402. */
  30403. interaxialDistance: number;
  30404. /**
  30405. * Defines if stereoscopic rendering is done side by side or over under.
  30406. */
  30407. isStereoscopicSideBySide: boolean;
  30408. /**
  30409. * 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
  30410. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30411. * else in the scene.
  30412. */
  30413. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30414. /**
  30415. * When set, the camera will render to this render target instead of the default canvas
  30416. */
  30417. outputRenderTarget: Nullable<RenderTargetTexture>;
  30418. /**
  30419. * Observable triggered when the camera view matrix has changed.
  30420. */
  30421. onViewMatrixChangedObservable: Observable<Camera>;
  30422. /**
  30423. * Observable triggered when the camera Projection matrix has changed.
  30424. */
  30425. onProjectionMatrixChangedObservable: Observable<Camera>;
  30426. /**
  30427. * Observable triggered when the inputs have been processed.
  30428. */
  30429. onAfterCheckInputsObservable: Observable<Camera>;
  30430. /**
  30431. * Observable triggered when reset has been called and applied to the camera.
  30432. */
  30433. onRestoreStateObservable: Observable<Camera>;
  30434. /** @hidden */
  30435. _cameraRigParams: any;
  30436. /** @hidden */
  30437. _rigCameras: Camera[];
  30438. /** @hidden */
  30439. _rigPostProcess: Nullable<PostProcess>;
  30440. protected _webvrViewMatrix: Matrix;
  30441. /** @hidden */
  30442. _skipRendering: boolean;
  30443. /** @hidden */
  30444. _alternateCamera: Camera;
  30445. /** @hidden */
  30446. _projectionMatrix: Matrix;
  30447. /** @hidden */
  30448. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30449. /** @hidden */
  30450. _activeMeshes: SmartArray<AbstractMesh>;
  30451. protected _globalPosition: Vector3;
  30452. /** hidden */
  30453. _computedViewMatrix: Matrix;
  30454. private _doNotComputeProjectionMatrix;
  30455. private _transformMatrix;
  30456. private _frustumPlanes;
  30457. private _refreshFrustumPlanes;
  30458. private _storedFov;
  30459. private _stateStored;
  30460. /**
  30461. * Instantiates a new camera object.
  30462. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30463. * @see http://doc.babylonjs.com/features/cameras
  30464. * @param name Defines the name of the camera in the scene
  30465. * @param position Defines the position of the camera
  30466. * @param scene Defines the scene the camera belongs too
  30467. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30468. */
  30469. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30470. /**
  30471. * Store current camera state (fov, position, etc..)
  30472. * @returns the camera
  30473. */
  30474. storeState(): Camera;
  30475. /**
  30476. * Restores the camera state values if it has been stored. You must call storeState() first
  30477. */
  30478. protected _restoreStateValues(): boolean;
  30479. /**
  30480. * Restored camera state. You must call storeState() first.
  30481. * @returns true if restored and false otherwise
  30482. */
  30483. restoreState(): boolean;
  30484. /**
  30485. * Gets the class name of the camera.
  30486. * @returns the class name
  30487. */
  30488. getClassName(): string;
  30489. /** @hidden */
  30490. readonly _isCamera: boolean;
  30491. /**
  30492. * Gets a string representation of the camera useful for debug purpose.
  30493. * @param fullDetails Defines that a more verboe level of logging is required
  30494. * @returns the string representation
  30495. */
  30496. toString(fullDetails?: boolean): string;
  30497. /**
  30498. * Gets the current world space position of the camera.
  30499. */
  30500. readonly globalPosition: Vector3;
  30501. /**
  30502. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30503. * @returns the active meshe list
  30504. */
  30505. getActiveMeshes(): SmartArray<AbstractMesh>;
  30506. /**
  30507. * Check wether a mesh is part of the current active mesh list of the camera
  30508. * @param mesh Defines the mesh to check
  30509. * @returns true if active, false otherwise
  30510. */
  30511. isActiveMesh(mesh: Mesh): boolean;
  30512. /**
  30513. * Is this camera ready to be used/rendered
  30514. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30515. * @return true if the camera is ready
  30516. */
  30517. isReady(completeCheck?: boolean): boolean;
  30518. /** @hidden */
  30519. _initCache(): void;
  30520. /** @hidden */
  30521. _updateCache(ignoreParentClass?: boolean): void;
  30522. /** @hidden */
  30523. _isSynchronized(): boolean;
  30524. /** @hidden */
  30525. _isSynchronizedViewMatrix(): boolean;
  30526. /** @hidden */
  30527. _isSynchronizedProjectionMatrix(): boolean;
  30528. /**
  30529. * Attach the input controls to a specific dom element to get the input from.
  30530. * @param element Defines the element the controls should be listened from
  30531. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30532. */
  30533. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30534. /**
  30535. * Detach the current controls from the specified dom element.
  30536. * @param element Defines the element to stop listening the inputs from
  30537. */
  30538. detachControl(element: HTMLElement): void;
  30539. /**
  30540. * Update the camera state according to the different inputs gathered during the frame.
  30541. */
  30542. update(): void;
  30543. /** @hidden */
  30544. _checkInputs(): void;
  30545. /** @hidden */
  30546. readonly rigCameras: Camera[];
  30547. /**
  30548. * Gets the post process used by the rig cameras
  30549. */
  30550. readonly rigPostProcess: Nullable<PostProcess>;
  30551. /**
  30552. * Internal, gets the first post proces.
  30553. * @returns the first post process to be run on this camera.
  30554. */
  30555. _getFirstPostProcess(): Nullable<PostProcess>;
  30556. private _cascadePostProcessesToRigCams;
  30557. /**
  30558. * Attach a post process to the camera.
  30559. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30560. * @param postProcess The post process to attach to the camera
  30561. * @param insertAt The position of the post process in case several of them are in use in the scene
  30562. * @returns the position the post process has been inserted at
  30563. */
  30564. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30565. /**
  30566. * Detach a post process to the camera.
  30567. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30568. * @param postProcess The post process to detach from the camera
  30569. */
  30570. detachPostProcess(postProcess: PostProcess): void;
  30571. /**
  30572. * Gets the current world matrix of the camera
  30573. */
  30574. getWorldMatrix(): Matrix;
  30575. /** @hidden */
  30576. _getViewMatrix(): Matrix;
  30577. /**
  30578. * Gets the current view matrix of the camera.
  30579. * @param force forces the camera to recompute the matrix without looking at the cached state
  30580. * @returns the view matrix
  30581. */
  30582. getViewMatrix(force?: boolean): Matrix;
  30583. /**
  30584. * Freeze the projection matrix.
  30585. * It will prevent the cache check of the camera projection compute and can speed up perf
  30586. * if no parameter of the camera are meant to change
  30587. * @param projection Defines manually a projection if necessary
  30588. */
  30589. freezeProjectionMatrix(projection?: Matrix): void;
  30590. /**
  30591. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30592. */
  30593. unfreezeProjectionMatrix(): void;
  30594. /**
  30595. * Gets the current projection matrix of the camera.
  30596. * @param force forces the camera to recompute the matrix without looking at the cached state
  30597. * @returns the projection matrix
  30598. */
  30599. getProjectionMatrix(force?: boolean): Matrix;
  30600. /**
  30601. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30602. * @returns a Matrix
  30603. */
  30604. getTransformationMatrix(): Matrix;
  30605. private _updateFrustumPlanes;
  30606. /**
  30607. * Checks if a cullable object (mesh...) is in the camera frustum
  30608. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30609. * @param target The object to check
  30610. * @returns true if the object is in frustum otherwise false
  30611. */
  30612. isInFrustum(target: ICullable): boolean;
  30613. /**
  30614. * Checks if a cullable object (mesh...) is in the camera frustum
  30615. * Unlike isInFrustum this cheks the full bounding box
  30616. * @param target The object to check
  30617. * @returns true if the object is in frustum otherwise false
  30618. */
  30619. isCompletelyInFrustum(target: ICullable): boolean;
  30620. /**
  30621. * Gets a ray in the forward direction from the camera.
  30622. * @param length Defines the length of the ray to create
  30623. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30624. * @param origin Defines the start point of the ray which defaults to the camera position
  30625. * @returns the forward ray
  30626. */
  30627. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30628. /**
  30629. * Releases resources associated with this node.
  30630. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30631. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30632. */
  30633. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30634. /** @hidden */
  30635. _isLeftCamera: boolean;
  30636. /**
  30637. * Gets the left camera of a rig setup in case of Rigged Camera
  30638. */
  30639. readonly isLeftCamera: boolean;
  30640. /** @hidden */
  30641. _isRightCamera: boolean;
  30642. /**
  30643. * Gets the right camera of a rig setup in case of Rigged Camera
  30644. */
  30645. readonly isRightCamera: boolean;
  30646. /**
  30647. * Gets the left camera of a rig setup in case of Rigged Camera
  30648. */
  30649. readonly leftCamera: Nullable<FreeCamera>;
  30650. /**
  30651. * Gets the right camera of a rig setup in case of Rigged Camera
  30652. */
  30653. readonly rightCamera: Nullable<FreeCamera>;
  30654. /**
  30655. * Gets the left camera target of a rig setup in case of Rigged Camera
  30656. * @returns the target position
  30657. */
  30658. getLeftTarget(): Nullable<Vector3>;
  30659. /**
  30660. * Gets the right camera target of a rig setup in case of Rigged Camera
  30661. * @returns the target position
  30662. */
  30663. getRightTarget(): Nullable<Vector3>;
  30664. /**
  30665. * @hidden
  30666. */
  30667. setCameraRigMode(mode: number, rigParams: any): void;
  30668. /** @hidden */
  30669. static _setStereoscopicRigMode(camera: Camera): void;
  30670. /** @hidden */
  30671. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30672. /** @hidden */
  30673. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30674. /** @hidden */
  30675. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30676. /** @hidden */
  30677. _getVRProjectionMatrix(): Matrix;
  30678. protected _updateCameraRotationMatrix(): void;
  30679. protected _updateWebVRCameraRotationMatrix(): void;
  30680. /**
  30681. * This function MUST be overwritten by the different WebVR cameras available.
  30682. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30683. * @hidden
  30684. */
  30685. _getWebVRProjectionMatrix(): Matrix;
  30686. /**
  30687. * This function MUST be overwritten by the different WebVR cameras available.
  30688. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30689. * @hidden
  30690. */
  30691. _getWebVRViewMatrix(): Matrix;
  30692. /** @hidden */
  30693. setCameraRigParameter(name: string, value: any): void;
  30694. /**
  30695. * needs to be overridden by children so sub has required properties to be copied
  30696. * @hidden
  30697. */
  30698. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30699. /**
  30700. * May need to be overridden by children
  30701. * @hidden
  30702. */
  30703. _updateRigCameras(): void;
  30704. /** @hidden */
  30705. _setupInputs(): void;
  30706. /**
  30707. * Serialiaze the camera setup to a json represention
  30708. * @returns the JSON representation
  30709. */
  30710. serialize(): any;
  30711. /**
  30712. * Clones the current camera.
  30713. * @param name The cloned camera name
  30714. * @returns the cloned camera
  30715. */
  30716. clone(name: string): Camera;
  30717. /**
  30718. * Gets the direction of the camera relative to a given local axis.
  30719. * @param localAxis Defines the reference axis to provide a relative direction.
  30720. * @return the direction
  30721. */
  30722. getDirection(localAxis: Vector3): Vector3;
  30723. /**
  30724. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30725. * @param localAxis Defines the reference axis to provide a relative direction.
  30726. * @param result Defines the vector to store the result in
  30727. */
  30728. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30729. /**
  30730. * Gets a camera constructor for a given camera type
  30731. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30732. * @param name The name of the camera the result will be able to instantiate
  30733. * @param scene The scene the result will construct the camera in
  30734. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30735. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30736. * @returns a factory method to construc the camera
  30737. */
  30738. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30739. /**
  30740. * Compute the world matrix of the camera.
  30741. * @returns the camera workd matrix
  30742. */
  30743. computeWorldMatrix(): Matrix;
  30744. /**
  30745. * Parse a JSON and creates the camera from the parsed information
  30746. * @param parsedCamera The JSON to parse
  30747. * @param scene The scene to instantiate the camera in
  30748. * @returns the newly constructed camera
  30749. */
  30750. static Parse(parsedCamera: any, scene: Scene): Camera;
  30751. }
  30752. }
  30753. declare module "babylonjs/Misc/tools" {
  30754. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  30755. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  30756. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30757. import { Observable } from "babylonjs/Misc/observable";
  30758. import { DomManagement } from "babylonjs/Misc/domManagement";
  30759. import { WebRequest } from "babylonjs/Misc/webRequest";
  30760. import { Camera } from "babylonjs/Cameras/camera";
  30761. import { Engine } from "babylonjs/Engines/engine";
  30762. import { Animation } from "babylonjs/Animations/animation";
  30763. /**
  30764. * Interface for any object that can request an animation frame
  30765. */
  30766. export interface ICustomAnimationFrameRequester {
  30767. /**
  30768. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30769. */
  30770. renderFunction?: Function;
  30771. /**
  30772. * Called to request the next frame to render to
  30773. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30774. */
  30775. requestAnimationFrame: Function;
  30776. /**
  30777. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30778. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30779. */
  30780. requestID?: number;
  30781. }
  30782. /**
  30783. * Interface containing an array of animations
  30784. */
  30785. export interface IAnimatable {
  30786. /**
  30787. * Array of animations
  30788. */
  30789. animations: Array<Animation>;
  30790. }
  30791. /** Interface used by value gradients (color, factor, ...) */
  30792. export interface IValueGradient {
  30793. /**
  30794. * Gets or sets the gradient value (between 0 and 1)
  30795. */
  30796. gradient: number;
  30797. }
  30798. /** Class used to store color4 gradient */
  30799. export class ColorGradient implements IValueGradient {
  30800. /**
  30801. * Gets or sets the gradient value (between 0 and 1)
  30802. */
  30803. gradient: number;
  30804. /**
  30805. * Gets or sets first associated color
  30806. */
  30807. color1: Color4;
  30808. /**
  30809. * Gets or sets second associated color
  30810. */
  30811. color2?: Color4;
  30812. /**
  30813. * Will get a color picked randomly between color1 and color2.
  30814. * If color2 is undefined then color1 will be used
  30815. * @param result defines the target Color4 to store the result in
  30816. */
  30817. getColorToRef(result: Color4): void;
  30818. }
  30819. /** Class used to store color 3 gradient */
  30820. export class Color3Gradient implements IValueGradient {
  30821. /**
  30822. * Gets or sets the gradient value (between 0 and 1)
  30823. */
  30824. gradient: number;
  30825. /**
  30826. * Gets or sets the associated color
  30827. */
  30828. color: Color3;
  30829. }
  30830. /** Class used to store factor gradient */
  30831. export class FactorGradient implements IValueGradient {
  30832. /**
  30833. * Gets or sets the gradient value (between 0 and 1)
  30834. */
  30835. gradient: number;
  30836. /**
  30837. * Gets or sets first associated factor
  30838. */
  30839. factor1: number;
  30840. /**
  30841. * Gets or sets second associated factor
  30842. */
  30843. factor2?: number;
  30844. /**
  30845. * Will get a number picked randomly between factor1 and factor2.
  30846. * If factor2 is undefined then factor1 will be used
  30847. * @returns the picked number
  30848. */
  30849. getFactor(): number;
  30850. }
  30851. /**
  30852. * @ignore
  30853. * Application error to support additional information when loading a file
  30854. */
  30855. export class LoadFileError extends Error {
  30856. /** defines the optional web request */
  30857. request?: WebRequest | undefined;
  30858. private static _setPrototypeOf;
  30859. /**
  30860. * Creates a new LoadFileError
  30861. * @param message defines the message of the error
  30862. * @param request defines the optional web request
  30863. */
  30864. constructor(message: string,
  30865. /** defines the optional web request */
  30866. request?: WebRequest | undefined);
  30867. }
  30868. /**
  30869. * Class used to define a retry strategy when error happens while loading assets
  30870. */
  30871. export class RetryStrategy {
  30872. /**
  30873. * Function used to defines an exponential back off strategy
  30874. * @param maxRetries defines the maximum number of retries (3 by default)
  30875. * @param baseInterval defines the interval between retries
  30876. * @returns the strategy function to use
  30877. */
  30878. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  30879. }
  30880. /**
  30881. * File request interface
  30882. */
  30883. export interface IFileRequest {
  30884. /**
  30885. * Raised when the request is complete (success or error).
  30886. */
  30887. onCompleteObservable: Observable<IFileRequest>;
  30888. /**
  30889. * Aborts the request for a file.
  30890. */
  30891. abort: () => void;
  30892. }
  30893. /**
  30894. * Class containing a set of static utilities functions
  30895. */
  30896. export class Tools {
  30897. /**
  30898. * Gets or sets the base URL to use to load assets
  30899. */
  30900. static BaseUrl: string;
  30901. /**
  30902. * Enable/Disable Custom HTTP Request Headers globally.
  30903. * default = false
  30904. * @see CustomRequestHeaders
  30905. */
  30906. static UseCustomRequestHeaders: boolean;
  30907. /**
  30908. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30909. * i.e. when loading files, where the server/service expects an Authorization header
  30910. */
  30911. static CustomRequestHeaders: {
  30912. [key: string]: string;
  30913. };
  30914. /**
  30915. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30916. */
  30917. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  30918. /**
  30919. * Default behaviour for cors in the application.
  30920. * It can be a string if the expected behavior is identical in the entire app.
  30921. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30922. */
  30923. static CorsBehavior: string | ((url: string | string[]) => string);
  30924. /**
  30925. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30926. * @ignorenaming
  30927. */
  30928. static UseFallbackTexture: boolean;
  30929. /**
  30930. * Use this object to register external classes like custom textures or material
  30931. * to allow the laoders to instantiate them
  30932. */
  30933. static RegisteredExternalClasses: {
  30934. [key: string]: Object;
  30935. };
  30936. /**
  30937. * Texture content used if a texture cannot loaded
  30938. * @ignorenaming
  30939. */
  30940. static fallbackTexture: string;
  30941. /**
  30942. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30943. * @param u defines the coordinate on X axis
  30944. * @param v defines the coordinate on Y axis
  30945. * @param width defines the width of the source data
  30946. * @param height defines the height of the source data
  30947. * @param pixels defines the source byte array
  30948. * @param color defines the output color
  30949. */
  30950. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30951. /**
  30952. * Interpolates between a and b via alpha
  30953. * @param a The lower value (returned when alpha = 0)
  30954. * @param b The upper value (returned when alpha = 1)
  30955. * @param alpha The interpolation-factor
  30956. * @return The mixed value
  30957. */
  30958. static Mix(a: number, b: number, alpha: number): number;
  30959. /**
  30960. * Tries to instantiate a new object from a given class name
  30961. * @param className defines the class name to instantiate
  30962. * @returns the new object or null if the system was not able to do the instantiation
  30963. */
  30964. static Instantiate(className: string): any;
  30965. /**
  30966. * Provides a slice function that will work even on IE
  30967. * @param data defines the array to slice
  30968. * @param start defines the start of the data (optional)
  30969. * @param end defines the end of the data (optional)
  30970. * @returns the new sliced array
  30971. */
  30972. static Slice<T>(data: T, start?: number, end?: number): T;
  30973. /**
  30974. * Polyfill for setImmediate
  30975. * @param action defines the action to execute after the current execution block
  30976. */
  30977. static SetImmediate(action: () => void): void;
  30978. /**
  30979. * Function indicating if a number is an exponent of 2
  30980. * @param value defines the value to test
  30981. * @returns true if the value is an exponent of 2
  30982. */
  30983. static IsExponentOfTwo(value: number): boolean;
  30984. private static _tmpFloatArray;
  30985. /**
  30986. * Returns the nearest 32-bit single precision float representation of a Number
  30987. * @param value A Number. If the parameter is of a different type, it will get converted
  30988. * to a number or to NaN if it cannot be converted
  30989. * @returns number
  30990. */
  30991. static FloatRound(value: number): number;
  30992. /**
  30993. * Find the next highest power of two.
  30994. * @param x Number to start search from.
  30995. * @return Next highest power of two.
  30996. */
  30997. static CeilingPOT(x: number): number;
  30998. /**
  30999. * Find the next lowest power of two.
  31000. * @param x Number to start search from.
  31001. * @return Next lowest power of two.
  31002. */
  31003. static FloorPOT(x: number): number;
  31004. /**
  31005. * Find the nearest power of two.
  31006. * @param x Number to start search from.
  31007. * @return Next nearest power of two.
  31008. */
  31009. static NearestPOT(x: number): number;
  31010. /**
  31011. * Get the closest exponent of two
  31012. * @param value defines the value to approximate
  31013. * @param max defines the maximum value to return
  31014. * @param mode defines how to define the closest value
  31015. * @returns closest exponent of two of the given value
  31016. */
  31017. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31018. /**
  31019. * Extracts the filename from a path
  31020. * @param path defines the path to use
  31021. * @returns the filename
  31022. */
  31023. static GetFilename(path: string): string;
  31024. /**
  31025. * Extracts the "folder" part of a path (everything before the filename).
  31026. * @param uri The URI to extract the info from
  31027. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31028. * @returns The "folder" part of the path
  31029. */
  31030. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31031. /**
  31032. * Extracts text content from a DOM element hierarchy
  31033. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31034. */
  31035. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31036. /**
  31037. * Convert an angle in radians to degrees
  31038. * @param angle defines the angle to convert
  31039. * @returns the angle in degrees
  31040. */
  31041. static ToDegrees(angle: number): number;
  31042. /**
  31043. * Convert an angle in degrees to radians
  31044. * @param angle defines the angle to convert
  31045. * @returns the angle in radians
  31046. */
  31047. static ToRadians(angle: number): number;
  31048. /**
  31049. * Encode a buffer to a base64 string
  31050. * @param buffer defines the buffer to encode
  31051. * @returns the encoded string
  31052. */
  31053. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31054. /**
  31055. * Extracts minimum and maximum values from a list of indexed positions
  31056. * @param positions defines the positions to use
  31057. * @param indices defines the indices to the positions
  31058. * @param indexStart defines the start index
  31059. * @param indexCount defines the end index
  31060. * @param bias defines bias value to add to the result
  31061. * @return minimum and maximum values
  31062. */
  31063. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31064. minimum: Vector3;
  31065. maximum: Vector3;
  31066. };
  31067. /**
  31068. * Extracts minimum and maximum values from a list of positions
  31069. * @param positions defines the positions to use
  31070. * @param start defines the start index in the positions array
  31071. * @param count defines the number of positions to handle
  31072. * @param bias defines bias value to add to the result
  31073. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31074. * @return minimum and maximum values
  31075. */
  31076. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31077. minimum: Vector3;
  31078. maximum: Vector3;
  31079. };
  31080. /**
  31081. * Returns an array if obj is not an array
  31082. * @param obj defines the object to evaluate as an array
  31083. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31084. * @returns either obj directly if obj is an array or a new array containing obj
  31085. */
  31086. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31087. /**
  31088. * Gets the pointer prefix to use
  31089. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31090. */
  31091. static GetPointerPrefix(): string;
  31092. /**
  31093. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31094. * @param func - the function to be called
  31095. * @param requester - the object that will request the next frame. Falls back to window.
  31096. * @returns frame number
  31097. */
  31098. static QueueNewFrame(func: () => void, requester?: any): number;
  31099. /**
  31100. * Ask the browser to promote the current element to fullscreen rendering mode
  31101. * @param element defines the DOM element to promote
  31102. */
  31103. static RequestFullscreen(element: HTMLElement): void;
  31104. /**
  31105. * Asks the browser to exit fullscreen mode
  31106. */
  31107. static ExitFullscreen(): void;
  31108. /**
  31109. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31110. * @param url define the url we are trying
  31111. * @param element define the dom element where to configure the cors policy
  31112. */
  31113. static SetCorsBehavior(url: string | string[], element: {
  31114. crossOrigin: string | null;
  31115. }): void;
  31116. /**
  31117. * Removes unwanted characters from an url
  31118. * @param url defines the url to clean
  31119. * @returns the cleaned url
  31120. */
  31121. static CleanUrl(url: string): string;
  31122. /**
  31123. * Gets or sets a function used to pre-process url before using them to load assets
  31124. */
  31125. static PreprocessUrl: (url: string) => string;
  31126. /**
  31127. * Loads an image as an HTMLImageElement.
  31128. * @param input url string, ArrayBuffer, or Blob to load
  31129. * @param onLoad callback called when the image successfully loads
  31130. * @param onError callback called when the image fails to load
  31131. * @param offlineProvider offline provider for caching
  31132. * @returns the HTMLImageElement of the loaded image
  31133. */
  31134. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31135. /**
  31136. * Loads a file
  31137. * @param url url string, ArrayBuffer, or Blob to load
  31138. * @param onSuccess callback called when the file successfully loads
  31139. * @param onProgress callback called while file is loading (if the server supports this mode)
  31140. * @param offlineProvider defines the offline provider for caching
  31141. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31142. * @param onError callback called when the file fails to load
  31143. * @returns a file request object
  31144. */
  31145. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  31146. /**
  31147. * Load a script (identified by an url). When the url returns, the
  31148. * content of this file is added into a new script element, attached to the DOM (body element)
  31149. * @param scriptUrl defines the url of the script to laod
  31150. * @param onSuccess defines the callback called when the script is loaded
  31151. * @param onError defines the callback to call if an error occurs
  31152. */
  31153. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  31154. /**
  31155. * Loads a file from a blob
  31156. * @param fileToLoad defines the blob to use
  31157. * @param callback defines the callback to call when data is loaded
  31158. * @param progressCallback defines the callback to call during loading process
  31159. * @returns a file request object
  31160. */
  31161. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31162. /**
  31163. * Loads a file
  31164. * @param fileToLoad defines the file to load
  31165. * @param callback defines the callback to call when data is loaded
  31166. * @param progressCallBack defines the callback to call during loading process
  31167. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31168. * @returns a file request object
  31169. */
  31170. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31171. /**
  31172. * Creates a data url from a given string content
  31173. * @param content defines the content to convert
  31174. * @returns the new data url link
  31175. */
  31176. static FileAsURL(content: string): string;
  31177. /**
  31178. * Format the given number to a specific decimal format
  31179. * @param value defines the number to format
  31180. * @param decimals defines the number of decimals to use
  31181. * @returns the formatted string
  31182. */
  31183. static Format(value: number, decimals?: number): string;
  31184. /**
  31185. * Checks if a given vector is inside a specific range
  31186. * @param v defines the vector to test
  31187. * @param min defines the minimum range
  31188. * @param max defines the maximum range
  31189. */
  31190. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31191. /**
  31192. * Tries to copy an object by duplicating every property
  31193. * @param source defines the source object
  31194. * @param destination defines the target object
  31195. * @param doNotCopyList defines a list of properties to avoid
  31196. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31197. */
  31198. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31199. /**
  31200. * Gets a boolean indicating if the given object has no own property
  31201. * @param obj defines the object to test
  31202. * @returns true if object has no own property
  31203. */
  31204. static IsEmpty(obj: any): boolean;
  31205. /**
  31206. * Function used to register events at window level
  31207. * @param events defines the events to register
  31208. */
  31209. static RegisterTopRootEvents(events: {
  31210. name: string;
  31211. handler: Nullable<(e: FocusEvent) => any>;
  31212. }[]): void;
  31213. /**
  31214. * Function used to unregister events from window level
  31215. * @param events defines the events to unregister
  31216. */
  31217. static UnregisterTopRootEvents(events: {
  31218. name: string;
  31219. handler: Nullable<(e: FocusEvent) => any>;
  31220. }[]): void;
  31221. /**
  31222. * @ignore
  31223. */
  31224. static _ScreenshotCanvas: HTMLCanvasElement;
  31225. /**
  31226. * Dumps the current bound framebuffer
  31227. * @param width defines the rendering width
  31228. * @param height defines the rendering height
  31229. * @param engine defines the hosting engine
  31230. * @param successCallback defines the callback triggered once the data are available
  31231. * @param mimeType defines the mime type of the result
  31232. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31233. */
  31234. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31235. /**
  31236. * Converts the canvas data to blob.
  31237. * This acts as a polyfill for browsers not supporting the to blob function.
  31238. * @param canvas Defines the canvas to extract the data from
  31239. * @param successCallback Defines the callback triggered once the data are available
  31240. * @param mimeType Defines the mime type of the result
  31241. */
  31242. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31243. /**
  31244. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31245. * @param successCallback defines the callback triggered once the data are available
  31246. * @param mimeType defines the mime type of the result
  31247. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31248. */
  31249. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31250. /**
  31251. * Downloads a blob in the browser
  31252. * @param blob defines the blob to download
  31253. * @param fileName defines the name of the downloaded file
  31254. */
  31255. static Download(blob: Blob, fileName: string): void;
  31256. /**
  31257. * Captures a screenshot of the current rendering
  31258. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31259. * @param engine defines the rendering engine
  31260. * @param camera defines the source camera
  31261. * @param size This parameter can be set to a single number or to an object with the
  31262. * following (optional) properties: precision, width, height. If a single number is passed,
  31263. * it will be used for both width and height. If an object is passed, the screenshot size
  31264. * will be derived from the parameters. The precision property is a multiplier allowing
  31265. * rendering at a higher or lower resolution
  31266. * @param successCallback defines the callback receives a single parameter which contains the
  31267. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31268. * src parameter of an <img> to display it
  31269. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31270. * Check your browser for supported MIME types
  31271. */
  31272. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31273. /**
  31274. * Generates an image screenshot from the specified camera.
  31275. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31276. * @param engine The engine to use for rendering
  31277. * @param camera The camera to use for rendering
  31278. * @param size This parameter can be set to a single number or to an object with the
  31279. * following (optional) properties: precision, width, height. If a single number is passed,
  31280. * it will be used for both width and height. If an object is passed, the screenshot size
  31281. * will be derived from the parameters. The precision property is a multiplier allowing
  31282. * rendering at a higher or lower resolution
  31283. * @param successCallback The callback receives a single parameter which contains the
  31284. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31285. * src parameter of an <img> to display it
  31286. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31287. * Check your browser for supported MIME types
  31288. * @param samples Texture samples (default: 1)
  31289. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31290. * @param fileName A name for for the downloaded file.
  31291. */
  31292. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31293. /**
  31294. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31295. * Be aware Math.random() could cause collisions, but:
  31296. * "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"
  31297. * @returns a pseudo random id
  31298. */
  31299. static RandomId(): string;
  31300. /**
  31301. * Test if the given uri is a base64 string
  31302. * @param uri The uri to test
  31303. * @return True if the uri is a base64 string or false otherwise
  31304. */
  31305. static IsBase64(uri: string): boolean;
  31306. /**
  31307. * Decode the given base64 uri.
  31308. * @param uri The uri to decode
  31309. * @return The decoded base64 data.
  31310. */
  31311. static DecodeBase64(uri: string): ArrayBuffer;
  31312. /**
  31313. * No log
  31314. */
  31315. static readonly NoneLogLevel: number;
  31316. /**
  31317. * Only message logs
  31318. */
  31319. static readonly MessageLogLevel: number;
  31320. /**
  31321. * Only warning logs
  31322. */
  31323. static readonly WarningLogLevel: number;
  31324. /**
  31325. * Only error logs
  31326. */
  31327. static readonly ErrorLogLevel: number;
  31328. /**
  31329. * All logs
  31330. */
  31331. static readonly AllLogLevel: number;
  31332. /**
  31333. * Gets a value indicating the number of loading errors
  31334. * @ignorenaming
  31335. */
  31336. static readonly errorsCount: number;
  31337. /**
  31338. * Callback called when a new log is added
  31339. */
  31340. static OnNewCacheEntry: (entry: string) => void;
  31341. /**
  31342. * Log a message to the console
  31343. * @param message defines the message to log
  31344. */
  31345. static Log(message: string): void;
  31346. /**
  31347. * Write a warning message to the console
  31348. * @param message defines the message to log
  31349. */
  31350. static Warn(message: string): void;
  31351. /**
  31352. * Write an error message to the console
  31353. * @param message defines the message to log
  31354. */
  31355. static Error(message: string): void;
  31356. /**
  31357. * Gets current log cache (list of logs)
  31358. */
  31359. static readonly LogCache: string;
  31360. /**
  31361. * Clears the log cache
  31362. */
  31363. static ClearLogCache(): void;
  31364. /**
  31365. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31366. */
  31367. static LogLevels: number;
  31368. /**
  31369. * Checks if the loaded document was accessed via `file:`-Protocol.
  31370. * @returns boolean
  31371. */
  31372. static IsFileURL(): boolean;
  31373. /**
  31374. * Checks if the window object exists
  31375. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31376. */
  31377. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31378. /**
  31379. * No performance log
  31380. */
  31381. static readonly PerformanceNoneLogLevel: number;
  31382. /**
  31383. * Use user marks to log performance
  31384. */
  31385. static readonly PerformanceUserMarkLogLevel: number;
  31386. /**
  31387. * Log performance to the console
  31388. */
  31389. static readonly PerformanceConsoleLogLevel: number;
  31390. private static _performance;
  31391. /**
  31392. * Sets the current performance log level
  31393. */
  31394. static PerformanceLogLevel: number;
  31395. private static _StartPerformanceCounterDisabled;
  31396. private static _EndPerformanceCounterDisabled;
  31397. private static _StartUserMark;
  31398. private static _EndUserMark;
  31399. private static _StartPerformanceConsole;
  31400. private static _EndPerformanceConsole;
  31401. /**
  31402. * Starts a performance counter
  31403. */
  31404. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31405. /**
  31406. * Ends a specific performance coutner
  31407. */
  31408. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31409. /**
  31410. * Gets either window.performance.now() if supported or Date.now() else
  31411. */
  31412. static readonly Now: number;
  31413. /**
  31414. * This method will return the name of the class used to create the instance of the given object.
  31415. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31416. * @param object the object to get the class name from
  31417. * @param isType defines if the object is actually a type
  31418. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31419. */
  31420. static GetClassName(object: any, isType?: boolean): string;
  31421. /**
  31422. * Gets the first element of an array satisfying a given predicate
  31423. * @param array defines the array to browse
  31424. * @param predicate defines the predicate to use
  31425. * @returns null if not found or the element
  31426. */
  31427. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31428. /**
  31429. * This method will return the name of the full name of the class, including its owning module (if any).
  31430. * 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).
  31431. * @param object the object to get the class name from
  31432. * @param isType defines if the object is actually a type
  31433. * @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.
  31434. * @ignorenaming
  31435. */
  31436. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31437. /**
  31438. * Returns a promise that resolves after the given amount of time.
  31439. * @param delay Number of milliseconds to delay
  31440. * @returns Promise that resolves after the given amount of time
  31441. */
  31442. static DelayAsync(delay: number): Promise<void>;
  31443. /**
  31444. * Gets the current gradient from an array of IValueGradient
  31445. * @param ratio defines the current ratio to get
  31446. * @param gradients defines the array of IValueGradient
  31447. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31448. */
  31449. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31450. }
  31451. /**
  31452. * This class is used to track a performance counter which is number based.
  31453. * The user has access to many properties which give statistics of different nature.
  31454. *
  31455. * The implementer can track two kinds of Performance Counter: time and count.
  31456. * 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.
  31457. * 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.
  31458. */
  31459. export class PerfCounter {
  31460. /**
  31461. * Gets or sets a global boolean to turn on and off all the counters
  31462. */
  31463. static Enabled: boolean;
  31464. /**
  31465. * Returns the smallest value ever
  31466. */
  31467. readonly min: number;
  31468. /**
  31469. * Returns the biggest value ever
  31470. */
  31471. readonly max: number;
  31472. /**
  31473. * Returns the average value since the performance counter is running
  31474. */
  31475. readonly average: number;
  31476. /**
  31477. * Returns the average value of the last second the counter was monitored
  31478. */
  31479. readonly lastSecAverage: number;
  31480. /**
  31481. * Returns the current value
  31482. */
  31483. readonly current: number;
  31484. /**
  31485. * Gets the accumulated total
  31486. */
  31487. readonly total: number;
  31488. /**
  31489. * Gets the total value count
  31490. */
  31491. readonly count: number;
  31492. /**
  31493. * Creates a new counter
  31494. */
  31495. constructor();
  31496. /**
  31497. * Call this method to start monitoring a new frame.
  31498. * 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.
  31499. */
  31500. fetchNewFrame(): void;
  31501. /**
  31502. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31503. * @param newCount the count value to add to the monitored count
  31504. * @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.
  31505. */
  31506. addCount(newCount: number, fetchResult: boolean): void;
  31507. /**
  31508. * Start monitoring this performance counter
  31509. */
  31510. beginMonitoring(): void;
  31511. /**
  31512. * Compute the time lapsed since the previous beginMonitoring() call.
  31513. * @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
  31514. */
  31515. endMonitoring(newFrame?: boolean): void;
  31516. private _fetchResult;
  31517. private _startMonitoringTime;
  31518. private _min;
  31519. private _max;
  31520. private _average;
  31521. private _current;
  31522. private _totalValueCount;
  31523. private _totalAccumulated;
  31524. private _lastSecAverage;
  31525. private _lastSecAccumulated;
  31526. private _lastSecTime;
  31527. private _lastSecValueCount;
  31528. }
  31529. /**
  31530. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31531. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31532. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31533. * @param name The name of the class, case should be preserved
  31534. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31535. */
  31536. export function className(name: string, module?: string): (target: Object) => void;
  31537. /**
  31538. * An implementation of a loop for asynchronous functions.
  31539. */
  31540. export class AsyncLoop {
  31541. /**
  31542. * Defines the number of iterations for the loop
  31543. */
  31544. iterations: number;
  31545. /**
  31546. * Defines the current index of the loop.
  31547. */
  31548. index: number;
  31549. private _done;
  31550. private _fn;
  31551. private _successCallback;
  31552. /**
  31553. * Constructor.
  31554. * @param iterations the number of iterations.
  31555. * @param func the function to run each iteration
  31556. * @param successCallback the callback that will be called upon succesful execution
  31557. * @param offset starting offset.
  31558. */
  31559. constructor(
  31560. /**
  31561. * Defines the number of iterations for the loop
  31562. */
  31563. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31564. /**
  31565. * Execute the next iteration. Must be called after the last iteration was finished.
  31566. */
  31567. executeNext(): void;
  31568. /**
  31569. * Break the loop and run the success callback.
  31570. */
  31571. breakLoop(): void;
  31572. /**
  31573. * Create and run an async loop.
  31574. * @param iterations the number of iterations.
  31575. * @param fn the function to run each iteration
  31576. * @param successCallback the callback that will be called upon succesful execution
  31577. * @param offset starting offset.
  31578. * @returns the created async loop object
  31579. */
  31580. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31581. /**
  31582. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31583. * @param iterations total number of iterations
  31584. * @param syncedIterations number of synchronous iterations in each async iteration.
  31585. * @param fn the function to call each iteration.
  31586. * @param callback a success call back that will be called when iterating stops.
  31587. * @param breakFunction a break condition (optional)
  31588. * @param timeout timeout settings for the setTimeout function. default - 0.
  31589. * @returns the created async loop object
  31590. */
  31591. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31592. }
  31593. }
  31594. declare module "babylonjs/Collisions/collisionCoordinator" {
  31595. import { Nullable } from "babylonjs/types";
  31596. import { Scene } from "babylonjs/scene";
  31597. import { Vector3 } from "babylonjs/Maths/math";
  31598. import { Collider } from "babylonjs/Collisions/collider";
  31599. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31600. /** @hidden */
  31601. export interface ICollisionCoordinator {
  31602. createCollider(): Collider;
  31603. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31604. init(scene: Scene): void;
  31605. }
  31606. /** @hidden */
  31607. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31608. private _scene;
  31609. private _scaledPosition;
  31610. private _scaledVelocity;
  31611. private _finalPosition;
  31612. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31613. createCollider(): Collider;
  31614. init(scene: Scene): void;
  31615. private _collideWithWorld;
  31616. }
  31617. }
  31618. declare module "babylonjs/Animations/animationGroup" {
  31619. import { Animatable } from "babylonjs/Animations/animatable";
  31620. import { Animation } from "babylonjs/Animations/animation";
  31621. import { Scene, IDisposable } from "babylonjs/scene";
  31622. import { Observable } from "babylonjs/Misc/observable";
  31623. import { Nullable } from "babylonjs/types";
  31624. /**
  31625. * This class defines the direct association between an animation and a target
  31626. */
  31627. export class TargetedAnimation {
  31628. /**
  31629. * Animation to perform
  31630. */
  31631. animation: Animation;
  31632. /**
  31633. * Target to animate
  31634. */
  31635. target: any;
  31636. }
  31637. /**
  31638. * Use this class to create coordinated animations on multiple targets
  31639. */
  31640. export class AnimationGroup implements IDisposable {
  31641. /** The name of the animation group */
  31642. name: string;
  31643. private _scene;
  31644. private _targetedAnimations;
  31645. private _animatables;
  31646. private _from;
  31647. private _to;
  31648. private _isStarted;
  31649. private _isPaused;
  31650. private _speedRatio;
  31651. /**
  31652. * Gets or sets the unique id of the node
  31653. */
  31654. uniqueId: number;
  31655. /**
  31656. * This observable will notify when one animation have ended
  31657. */
  31658. onAnimationEndObservable: Observable<TargetedAnimation>;
  31659. /**
  31660. * Observer raised when one animation loops
  31661. */
  31662. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31663. /**
  31664. * This observable will notify when all animations have ended.
  31665. */
  31666. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31667. /**
  31668. * This observable will notify when all animations have paused.
  31669. */
  31670. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31671. /**
  31672. * This observable will notify when all animations are playing.
  31673. */
  31674. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31675. /**
  31676. * Gets the first frame
  31677. */
  31678. readonly from: number;
  31679. /**
  31680. * Gets the last frame
  31681. */
  31682. readonly to: number;
  31683. /**
  31684. * Define if the animations are started
  31685. */
  31686. readonly isStarted: boolean;
  31687. /**
  31688. * Gets a value indicating that the current group is playing
  31689. */
  31690. readonly isPlaying: boolean;
  31691. /**
  31692. * Gets or sets the speed ratio to use for all animations
  31693. */
  31694. /**
  31695. * Gets or sets the speed ratio to use for all animations
  31696. */
  31697. speedRatio: number;
  31698. /**
  31699. * Gets the targeted animations for this animation group
  31700. */
  31701. readonly targetedAnimations: Array<TargetedAnimation>;
  31702. /**
  31703. * returning the list of animatables controlled by this animation group.
  31704. */
  31705. readonly animatables: Array<Animatable>;
  31706. /**
  31707. * Instantiates a new Animation Group.
  31708. * This helps managing several animations at once.
  31709. * @see http://doc.babylonjs.com/how_to/group
  31710. * @param name Defines the name of the group
  31711. * @param scene Defines the scene the group belongs to
  31712. */
  31713. constructor(
  31714. /** The name of the animation group */
  31715. name: string, scene?: Nullable<Scene>);
  31716. /**
  31717. * Add an animation (with its target) in the group
  31718. * @param animation defines the animation we want to add
  31719. * @param target defines the target of the animation
  31720. * @returns the TargetedAnimation object
  31721. */
  31722. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31723. /**
  31724. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31725. * It can add constant keys at begin or end
  31726. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31727. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31728. * @returns the animation group
  31729. */
  31730. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31731. /**
  31732. * Start all animations on given targets
  31733. * @param loop defines if animations must loop
  31734. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31735. * @param from defines the from key (optional)
  31736. * @param to defines the to key (optional)
  31737. * @returns the current animation group
  31738. */
  31739. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31740. /**
  31741. * Pause all animations
  31742. * @returns the animation group
  31743. */
  31744. pause(): AnimationGroup;
  31745. /**
  31746. * Play all animations to initial state
  31747. * This function will start() the animations if they were not started or will restart() them if they were paused
  31748. * @param loop defines if animations must loop
  31749. * @returns the animation group
  31750. */
  31751. play(loop?: boolean): AnimationGroup;
  31752. /**
  31753. * Reset all animations to initial state
  31754. * @returns the animation group
  31755. */
  31756. reset(): AnimationGroup;
  31757. /**
  31758. * Restart animations from key 0
  31759. * @returns the animation group
  31760. */
  31761. restart(): AnimationGroup;
  31762. /**
  31763. * Stop all animations
  31764. * @returns the animation group
  31765. */
  31766. stop(): AnimationGroup;
  31767. /**
  31768. * Set animation weight for all animatables
  31769. * @param weight defines the weight to use
  31770. * @return the animationGroup
  31771. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31772. */
  31773. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31774. /**
  31775. * Synchronize and normalize all animatables with a source animatable
  31776. * @param root defines the root animatable to synchronize with
  31777. * @return the animationGroup
  31778. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31779. */
  31780. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31781. /**
  31782. * Goes to a specific frame in this animation group
  31783. * @param frame the frame number to go to
  31784. * @return the animationGroup
  31785. */
  31786. goToFrame(frame: number): AnimationGroup;
  31787. /**
  31788. * Dispose all associated resources
  31789. */
  31790. dispose(): void;
  31791. private _checkAnimationGroupEnded;
  31792. /**
  31793. * Clone the current animation group and returns a copy
  31794. * @param newName defines the name of the new group
  31795. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31796. * @returns the new aniamtion group
  31797. */
  31798. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31799. /**
  31800. * Returns a new AnimationGroup object parsed from the source provided.
  31801. * @param parsedAnimationGroup defines the source
  31802. * @param scene defines the scene that will receive the animationGroup
  31803. * @returns a new AnimationGroup
  31804. */
  31805. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31806. /**
  31807. * Returns the string "AnimationGroup"
  31808. * @returns "AnimationGroup"
  31809. */
  31810. getClassName(): string;
  31811. /**
  31812. * Creates a detailled string about the object
  31813. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31814. * @returns a string representing the object
  31815. */
  31816. toString(fullDetails?: boolean): string;
  31817. }
  31818. }
  31819. declare module "babylonjs/scene" {
  31820. import { Nullable } from "babylonjs/types";
  31821. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  31822. import { Observable } from "babylonjs/Misc/observable";
  31823. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  31824. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  31825. import { Geometry } from "babylonjs/Meshes/geometry";
  31826. import { TransformNode } from "babylonjs/Meshes/transformNode";
  31827. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31828. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31829. import { Mesh } from "babylonjs/Meshes/mesh";
  31830. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  31831. import { Bone } from "babylonjs/Bones/bone";
  31832. import { Skeleton } from "babylonjs/Bones/skeleton";
  31833. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  31834. import { Camera } from "babylonjs/Cameras/camera";
  31835. import { AbstractScene } from "babylonjs/abstractScene";
  31836. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31837. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31838. import { Material } from "babylonjs/Materials/material";
  31839. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  31840. import { Effect } from "babylonjs/Materials/effect";
  31841. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31842. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  31843. import { Light } from "babylonjs/Lights/light";
  31844. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31845. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  31846. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  31847. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  31848. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31849. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  31850. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31851. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  31852. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction } from "babylonjs/sceneComponent";
  31853. import { Engine } from "babylonjs/Engines/engine";
  31854. import { Node } from "babylonjs/node";
  31855. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  31856. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  31857. import { WebRequest } from "babylonjs/Misc/webRequest";
  31858. import { Ray } from "babylonjs/Culling/ray";
  31859. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  31860. import { Animation } from "babylonjs/Animations/animation";
  31861. import { Animatable } from "babylonjs/Animations/animatable";
  31862. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  31863. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  31864. import { Collider } from "babylonjs/Collisions/collider";
  31865. /**
  31866. * Define an interface for all classes that will hold resources
  31867. */
  31868. export interface IDisposable {
  31869. /**
  31870. * Releases all held resources
  31871. */
  31872. dispose(): void;
  31873. }
  31874. /** Interface defining initialization parameters for Scene class */
  31875. export interface SceneOptions {
  31876. /**
  31877. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31878. * It will improve performance when the number of geometries becomes important.
  31879. */
  31880. useGeometryUniqueIdsMap?: boolean;
  31881. /**
  31882. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31883. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31884. */
  31885. useMaterialMeshMap?: boolean;
  31886. /**
  31887. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31888. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31889. */
  31890. useClonedMeshhMap?: boolean;
  31891. }
  31892. /**
  31893. * Represents a scene to be rendered by the engine.
  31894. * @see http://doc.babylonjs.com/features/scene
  31895. */
  31896. export class Scene extends AbstractScene implements IAnimatable {
  31897. private static _uniqueIdCounter;
  31898. /** The fog is deactivated */
  31899. static readonly FOGMODE_NONE: number;
  31900. /** The fog density is following an exponential function */
  31901. static readonly FOGMODE_EXP: number;
  31902. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31903. static readonly FOGMODE_EXP2: number;
  31904. /** The fog density is following a linear function. */
  31905. static readonly FOGMODE_LINEAR: number;
  31906. /**
  31907. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31908. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31909. */
  31910. static MinDeltaTime: number;
  31911. /**
  31912. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31913. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31914. */
  31915. static MaxDeltaTime: number;
  31916. /**
  31917. * Factory used to create the default material.
  31918. * @param name The name of the material to create
  31919. * @param scene The scene to create the material for
  31920. * @returns The default material
  31921. */
  31922. static DefaultMaterialFactory(scene: Scene): Material;
  31923. /**
  31924. * Factory used to create the a collision coordinator.
  31925. * @returns The collision coordinator
  31926. */
  31927. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31928. /** @hidden */
  31929. readonly _isScene: boolean;
  31930. /**
  31931. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31932. */
  31933. autoClear: boolean;
  31934. /**
  31935. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31936. */
  31937. autoClearDepthAndStencil: boolean;
  31938. /**
  31939. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31940. */
  31941. clearColor: Color4;
  31942. /**
  31943. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31944. */
  31945. ambientColor: Color3;
  31946. /** @hidden */
  31947. _environmentBRDFTexture: BaseTexture;
  31948. /** @hidden */
  31949. protected _environmentTexture: Nullable<BaseTexture>;
  31950. /**
  31951. * Texture used in all pbr material as the reflection texture.
  31952. * As in the majority of the scene they are the same (exception for multi room and so on),
  31953. * this is easier to reference from here than from all the materials.
  31954. */
  31955. /**
  31956. * Texture used in all pbr material as the reflection texture.
  31957. * As in the majority of the scene they are the same (exception for multi room and so on),
  31958. * this is easier to set here than in all the materials.
  31959. */
  31960. environmentTexture: Nullable<BaseTexture>;
  31961. /** @hidden */
  31962. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31963. /**
  31964. * Default image processing configuration used either in the rendering
  31965. * Forward main pass or through the imageProcessingPostProcess if present.
  31966. * As in the majority of the scene they are the same (exception for multi camera),
  31967. * this is easier to reference from here than from all the materials and post process.
  31968. *
  31969. * No setter as we it is a shared configuration, you can set the values instead.
  31970. */
  31971. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31972. private _forceWireframe;
  31973. /**
  31974. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31975. */
  31976. forceWireframe: boolean;
  31977. private _forcePointsCloud;
  31978. /**
  31979. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31980. */
  31981. forcePointsCloud: boolean;
  31982. /**
  31983. * Gets or sets the active clipplane 1
  31984. */
  31985. clipPlane: Nullable<Plane>;
  31986. /**
  31987. * Gets or sets the active clipplane 2
  31988. */
  31989. clipPlane2: Nullable<Plane>;
  31990. /**
  31991. * Gets or sets the active clipplane 3
  31992. */
  31993. clipPlane3: Nullable<Plane>;
  31994. /**
  31995. * Gets or sets the active clipplane 4
  31996. */
  31997. clipPlane4: Nullable<Plane>;
  31998. /**
  31999. * Gets or sets a boolean indicating if animations are enabled
  32000. */
  32001. animationsEnabled: boolean;
  32002. private _animationPropertiesOverride;
  32003. /**
  32004. * Gets or sets the animation properties override
  32005. */
  32006. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32007. /**
  32008. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32009. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32010. */
  32011. useConstantAnimationDeltaTime: boolean;
  32012. /**
  32013. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32014. * Please note that it requires to run a ray cast through the scene on every frame
  32015. */
  32016. constantlyUpdateMeshUnderPointer: boolean;
  32017. /**
  32018. * Defines the HTML cursor to use when hovering over interactive elements
  32019. */
  32020. hoverCursor: string;
  32021. /**
  32022. * Defines the HTML default cursor to use (empty by default)
  32023. */
  32024. defaultCursor: string;
  32025. /**
  32026. * This is used to call preventDefault() on pointer down
  32027. * in order to block unwanted artifacts like system double clicks
  32028. */
  32029. preventDefaultOnPointerDown: boolean;
  32030. /**
  32031. * This is used to call preventDefault() on pointer up
  32032. * in order to block unwanted artifacts like system double clicks
  32033. */
  32034. preventDefaultOnPointerUp: boolean;
  32035. /**
  32036. * Gets or sets user defined metadata
  32037. */
  32038. metadata: any;
  32039. /**
  32040. * For internal use only. Please do not use.
  32041. */
  32042. reservedDataStore: any;
  32043. /**
  32044. * Gets the name of the plugin used to load this scene (null by default)
  32045. */
  32046. loadingPluginName: string;
  32047. /**
  32048. * Use this array to add regular expressions used to disable offline support for specific urls
  32049. */
  32050. disableOfflineSupportExceptionRules: RegExp[];
  32051. /**
  32052. * An event triggered when the scene is disposed.
  32053. */
  32054. onDisposeObservable: Observable<Scene>;
  32055. private _onDisposeObserver;
  32056. /** Sets a function to be executed when this scene is disposed. */
  32057. onDispose: () => void;
  32058. /**
  32059. * An event triggered before rendering the scene (right after animations and physics)
  32060. */
  32061. onBeforeRenderObservable: Observable<Scene>;
  32062. private _onBeforeRenderObserver;
  32063. /** Sets a function to be executed before rendering this scene */
  32064. beforeRender: Nullable<() => void>;
  32065. /**
  32066. * An event triggered after rendering the scene
  32067. */
  32068. onAfterRenderObservable: Observable<Scene>;
  32069. private _onAfterRenderObserver;
  32070. /** Sets a function to be executed after rendering this scene */
  32071. afterRender: Nullable<() => void>;
  32072. /**
  32073. * An event triggered before animating the scene
  32074. */
  32075. onBeforeAnimationsObservable: Observable<Scene>;
  32076. /**
  32077. * An event triggered after animations processing
  32078. */
  32079. onAfterAnimationsObservable: Observable<Scene>;
  32080. /**
  32081. * An event triggered before draw calls are ready to be sent
  32082. */
  32083. onBeforeDrawPhaseObservable: Observable<Scene>;
  32084. /**
  32085. * An event triggered after draw calls have been sent
  32086. */
  32087. onAfterDrawPhaseObservable: Observable<Scene>;
  32088. /**
  32089. * An event triggered when the scene is ready
  32090. */
  32091. onReadyObservable: Observable<Scene>;
  32092. /**
  32093. * An event triggered before rendering a camera
  32094. */
  32095. onBeforeCameraRenderObservable: Observable<Camera>;
  32096. private _onBeforeCameraRenderObserver;
  32097. /** Sets a function to be executed before rendering a camera*/
  32098. beforeCameraRender: () => void;
  32099. /**
  32100. * An event triggered after rendering a camera
  32101. */
  32102. onAfterCameraRenderObservable: Observable<Camera>;
  32103. private _onAfterCameraRenderObserver;
  32104. /** Sets a function to be executed after rendering a camera*/
  32105. afterCameraRender: () => void;
  32106. /**
  32107. * An event triggered when active meshes evaluation is about to start
  32108. */
  32109. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32110. /**
  32111. * An event triggered when active meshes evaluation is done
  32112. */
  32113. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32114. /**
  32115. * An event triggered when particles rendering is about to start
  32116. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32117. */
  32118. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32119. /**
  32120. * An event triggered when particles rendering is done
  32121. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32122. */
  32123. onAfterParticlesRenderingObservable: Observable<Scene>;
  32124. /**
  32125. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32126. */
  32127. onDataLoadedObservable: Observable<Scene>;
  32128. /**
  32129. * An event triggered when a camera is created
  32130. */
  32131. onNewCameraAddedObservable: Observable<Camera>;
  32132. /**
  32133. * An event triggered when a camera is removed
  32134. */
  32135. onCameraRemovedObservable: Observable<Camera>;
  32136. /**
  32137. * An event triggered when a light is created
  32138. */
  32139. onNewLightAddedObservable: Observable<Light>;
  32140. /**
  32141. * An event triggered when a light is removed
  32142. */
  32143. onLightRemovedObservable: Observable<Light>;
  32144. /**
  32145. * An event triggered when a geometry is created
  32146. */
  32147. onNewGeometryAddedObservable: Observable<Geometry>;
  32148. /**
  32149. * An event triggered when a geometry is removed
  32150. */
  32151. onGeometryRemovedObservable: Observable<Geometry>;
  32152. /**
  32153. * An event triggered when a transform node is created
  32154. */
  32155. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32156. /**
  32157. * An event triggered when a transform node is removed
  32158. */
  32159. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32160. /**
  32161. * An event triggered when a mesh is created
  32162. */
  32163. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32164. /**
  32165. * An event triggered when a mesh is removed
  32166. */
  32167. onMeshRemovedObservable: Observable<AbstractMesh>;
  32168. /**
  32169. * An event triggered when a skeleton is created
  32170. */
  32171. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32172. /**
  32173. * An event triggered when a skeleton is removed
  32174. */
  32175. onSkeletonRemovedObservable: Observable<Skeleton>;
  32176. /**
  32177. * An event triggered when a material is created
  32178. */
  32179. onNewMaterialAddedObservable: Observable<Material>;
  32180. /**
  32181. * An event triggered when a material is removed
  32182. */
  32183. onMaterialRemovedObservable: Observable<Material>;
  32184. /**
  32185. * An event triggered when a texture is created
  32186. */
  32187. onNewTextureAddedObservable: Observable<BaseTexture>;
  32188. /**
  32189. * An event triggered when a texture is removed
  32190. */
  32191. onTextureRemovedObservable: Observable<BaseTexture>;
  32192. /**
  32193. * An event triggered when render targets are about to be rendered
  32194. * Can happen multiple times per frame.
  32195. */
  32196. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32197. /**
  32198. * An event triggered when render targets were rendered.
  32199. * Can happen multiple times per frame.
  32200. */
  32201. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32202. /**
  32203. * An event triggered before calculating deterministic simulation step
  32204. */
  32205. onBeforeStepObservable: Observable<Scene>;
  32206. /**
  32207. * An event triggered after calculating deterministic simulation step
  32208. */
  32209. onAfterStepObservable: Observable<Scene>;
  32210. /**
  32211. * An event triggered when the activeCamera property is updated
  32212. */
  32213. onActiveCameraChanged: Observable<Scene>;
  32214. /**
  32215. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32216. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32217. * 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)
  32218. */
  32219. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32220. /**
  32221. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32222. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32223. * 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)
  32224. */
  32225. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32226. /**
  32227. * This Observable will when a mesh has been imported into the scene.
  32228. */
  32229. onMeshImportedObservable: Observable<AbstractMesh>;
  32230. /**
  32231. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32232. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32233. */
  32234. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32235. /** @hidden */
  32236. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32237. /**
  32238. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32239. */
  32240. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32241. /**
  32242. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32243. */
  32244. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32245. /**
  32246. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32247. */
  32248. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32249. private _onPointerMove;
  32250. private _onPointerDown;
  32251. private _onPointerUp;
  32252. /** Callback called when a pointer move is detected */
  32253. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32254. /** Callback called when a pointer down is detected */
  32255. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32256. /** Callback called when a pointer up is detected */
  32257. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32258. /** Callback called when a pointer pick is detected */
  32259. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32260. /**
  32261. * 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).
  32262. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32263. */
  32264. onPrePointerObservable: Observable<PointerInfoPre>;
  32265. /**
  32266. * Observable event triggered each time an input event is received from the rendering canvas
  32267. */
  32268. onPointerObservable: Observable<PointerInfo>;
  32269. /**
  32270. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32271. */
  32272. readonly unTranslatedPointer: Vector2;
  32273. /** The distance in pixel that you have to move to prevent some events */
  32274. static DragMovementThreshold: number;
  32275. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32276. static LongPressDelay: number;
  32277. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32278. static DoubleClickDelay: number;
  32279. /** If you need to check double click without raising a single click at first click, enable this flag */
  32280. static ExclusiveDoubleClickMode: boolean;
  32281. private _initClickEvent;
  32282. private _initActionManager;
  32283. private _delayedSimpleClick;
  32284. private _delayedSimpleClickTimeout;
  32285. private _previousDelayedSimpleClickTimeout;
  32286. private _meshPickProceed;
  32287. private _previousButtonPressed;
  32288. private _currentPickResult;
  32289. private _previousPickResult;
  32290. private _totalPointersPressed;
  32291. private _doubleClickOccured;
  32292. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32293. cameraToUseForPointers: Nullable<Camera>;
  32294. private _pointerX;
  32295. private _pointerY;
  32296. private _unTranslatedPointerX;
  32297. private _unTranslatedPointerY;
  32298. private _startingPointerPosition;
  32299. private _previousStartingPointerPosition;
  32300. private _startingPointerTime;
  32301. private _previousStartingPointerTime;
  32302. private _pointerCaptures;
  32303. private _timeAccumulator;
  32304. private _currentStepId;
  32305. private _currentInternalStep;
  32306. /** @hidden */
  32307. _mirroredCameraPosition: Nullable<Vector3>;
  32308. /**
  32309. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32310. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32311. */
  32312. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32313. /**
  32314. * Observable event triggered each time an keyboard event is received from the hosting window
  32315. */
  32316. onKeyboardObservable: Observable<KeyboardInfo>;
  32317. private _onKeyDown;
  32318. private _onKeyUp;
  32319. private _onCanvasFocusObserver;
  32320. private _onCanvasBlurObserver;
  32321. private _useRightHandedSystem;
  32322. /**
  32323. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32324. */
  32325. useRightHandedSystem: boolean;
  32326. /**
  32327. * Sets the step Id used by deterministic lock step
  32328. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32329. * @param newStepId defines the step Id
  32330. */
  32331. setStepId(newStepId: number): void;
  32332. /**
  32333. * Gets the step Id used by deterministic lock step
  32334. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32335. * @returns the step Id
  32336. */
  32337. getStepId(): number;
  32338. /**
  32339. * Gets the internal step used by deterministic lock step
  32340. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32341. * @returns the internal step
  32342. */
  32343. getInternalStep(): number;
  32344. private _fogEnabled;
  32345. /**
  32346. * Gets or sets a boolean indicating if fog is enabled on this scene
  32347. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32348. * (Default is true)
  32349. */
  32350. fogEnabled: boolean;
  32351. private _fogMode;
  32352. /**
  32353. * Gets or sets the fog mode to use
  32354. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32355. * | mode | value |
  32356. * | --- | --- |
  32357. * | FOGMODE_NONE | 0 |
  32358. * | FOGMODE_EXP | 1 |
  32359. * | FOGMODE_EXP2 | 2 |
  32360. * | FOGMODE_LINEAR | 3 |
  32361. */
  32362. fogMode: number;
  32363. /**
  32364. * Gets or sets the fog color to use
  32365. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32366. * (Default is Color3(0.2, 0.2, 0.3))
  32367. */
  32368. fogColor: Color3;
  32369. /**
  32370. * Gets or sets the fog density to use
  32371. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32372. * (Default is 0.1)
  32373. */
  32374. fogDensity: number;
  32375. /**
  32376. * Gets or sets the fog start distance to use
  32377. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32378. * (Default is 0)
  32379. */
  32380. fogStart: number;
  32381. /**
  32382. * Gets or sets the fog end distance to use
  32383. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32384. * (Default is 1000)
  32385. */
  32386. fogEnd: number;
  32387. private _shadowsEnabled;
  32388. /**
  32389. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32390. */
  32391. shadowsEnabled: boolean;
  32392. private _lightsEnabled;
  32393. /**
  32394. * Gets or sets a boolean indicating if lights are enabled on this scene
  32395. */
  32396. lightsEnabled: boolean;
  32397. /** All of the active cameras added to this scene. */
  32398. activeCameras: Camera[];
  32399. private _activeCamera;
  32400. /** Gets or sets the current active camera */
  32401. activeCamera: Nullable<Camera>;
  32402. private _defaultMaterial;
  32403. /** The default material used on meshes when no material is affected */
  32404. /** The default material used on meshes when no material is affected */
  32405. defaultMaterial: Material;
  32406. private _texturesEnabled;
  32407. /**
  32408. * Gets or sets a boolean indicating if textures are enabled on this scene
  32409. */
  32410. texturesEnabled: boolean;
  32411. /**
  32412. * Gets or sets a boolean indicating if particles are enabled on this scene
  32413. */
  32414. particlesEnabled: boolean;
  32415. /**
  32416. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32417. */
  32418. spritesEnabled: boolean;
  32419. private _skeletonsEnabled;
  32420. /**
  32421. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32422. */
  32423. skeletonsEnabled: boolean;
  32424. /**
  32425. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32426. */
  32427. lensFlaresEnabled: boolean;
  32428. /**
  32429. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32430. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32431. */
  32432. collisionsEnabled: boolean;
  32433. private _collisionCoordinator;
  32434. /** @hidden */
  32435. readonly collisionCoordinator: ICollisionCoordinator;
  32436. /**
  32437. * Defines the gravity applied to this scene (used only for collisions)
  32438. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32439. */
  32440. gravity: Vector3;
  32441. /**
  32442. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32443. */
  32444. postProcessesEnabled: boolean;
  32445. /**
  32446. * The list of postprocesses added to the scene
  32447. */
  32448. postProcesses: PostProcess[];
  32449. /**
  32450. * Gets the current postprocess manager
  32451. */
  32452. postProcessManager: PostProcessManager;
  32453. /**
  32454. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32455. */
  32456. renderTargetsEnabled: boolean;
  32457. /**
  32458. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32459. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32460. */
  32461. dumpNextRenderTargets: boolean;
  32462. /**
  32463. * The list of user defined render targets added to the scene
  32464. */
  32465. customRenderTargets: RenderTargetTexture[];
  32466. /**
  32467. * Defines if texture loading must be delayed
  32468. * If true, textures will only be loaded when they need to be rendered
  32469. */
  32470. useDelayedTextureLoading: boolean;
  32471. /**
  32472. * Gets the list of meshes imported to the scene through SceneLoader
  32473. */
  32474. importedMeshesFiles: String[];
  32475. /**
  32476. * Gets or sets a boolean indicating if probes are enabled on this scene
  32477. */
  32478. probesEnabled: boolean;
  32479. /**
  32480. * Gets or sets the current offline provider to use to store scene data
  32481. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32482. */
  32483. offlineProvider: IOfflineProvider;
  32484. /**
  32485. * Gets or sets the action manager associated with the scene
  32486. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32487. */
  32488. actionManager: AbstractActionManager;
  32489. private _meshesForIntersections;
  32490. /**
  32491. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32492. */
  32493. proceduralTexturesEnabled: boolean;
  32494. private _engine;
  32495. private _totalVertices;
  32496. /** @hidden */
  32497. _activeIndices: PerfCounter;
  32498. /** @hidden */
  32499. _activeParticles: PerfCounter;
  32500. /** @hidden */
  32501. _activeBones: PerfCounter;
  32502. private _animationRatio;
  32503. /** @hidden */
  32504. _animationTimeLast: number;
  32505. /** @hidden */
  32506. _animationTime: number;
  32507. /**
  32508. * Gets or sets a general scale for animation speed
  32509. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32510. */
  32511. animationTimeScale: number;
  32512. /** @hidden */
  32513. _cachedMaterial: Nullable<Material>;
  32514. /** @hidden */
  32515. _cachedEffect: Nullable<Effect>;
  32516. /** @hidden */
  32517. _cachedVisibility: Nullable<number>;
  32518. private _renderId;
  32519. private _frameId;
  32520. private _executeWhenReadyTimeoutId;
  32521. private _intermediateRendering;
  32522. private _viewUpdateFlag;
  32523. private _projectionUpdateFlag;
  32524. private _alternateViewUpdateFlag;
  32525. private _alternateProjectionUpdateFlag;
  32526. /** @hidden */
  32527. _toBeDisposed: Nullable<IDisposable>[];
  32528. private _activeRequests;
  32529. /** @hidden */
  32530. _pendingData: any[];
  32531. private _isDisposed;
  32532. /**
  32533. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32534. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32535. */
  32536. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32537. private _activeMeshes;
  32538. private _processedMaterials;
  32539. private _renderTargets;
  32540. /** @hidden */
  32541. _activeParticleSystems: SmartArray<IParticleSystem>;
  32542. private _activeSkeletons;
  32543. private _softwareSkinnedMeshes;
  32544. private _renderingManager;
  32545. /** @hidden */
  32546. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  32547. private _transformMatrix;
  32548. private _sceneUbo;
  32549. private _alternateSceneUbo;
  32550. private _viewMatrix;
  32551. private _projectionMatrix;
  32552. private _alternateViewMatrix;
  32553. private _alternateProjectionMatrix;
  32554. private _alternateTransformMatrix;
  32555. private _useAlternateCameraConfiguration;
  32556. private _alternateRendering;
  32557. private _wheelEventName;
  32558. /** @hidden */
  32559. _forcedViewPosition: Nullable<Vector3>;
  32560. /** @hidden */
  32561. readonly _isAlternateRenderingEnabled: boolean;
  32562. private _frustumPlanes;
  32563. /**
  32564. * Gets the list of frustum planes (built from the active camera)
  32565. */
  32566. readonly frustumPlanes: Plane[];
  32567. /**
  32568. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32569. * This is useful if there are more lights that the maximum simulteanous authorized
  32570. */
  32571. requireLightSorting: boolean;
  32572. /** @hidden */
  32573. readonly useMaterialMeshMap: boolean;
  32574. /** @hidden */
  32575. readonly useClonedMeshhMap: boolean;
  32576. private _pointerOverMesh;
  32577. private _pickedDownMesh;
  32578. private _pickedUpMesh;
  32579. private _externalData;
  32580. private _uid;
  32581. /**
  32582. * @hidden
  32583. * Backing store of defined scene components.
  32584. */
  32585. _components: ISceneComponent[];
  32586. /**
  32587. * @hidden
  32588. * Backing store of defined scene components.
  32589. */
  32590. _serializableComponents: ISceneSerializableComponent[];
  32591. /**
  32592. * List of components to register on the next registration step.
  32593. */
  32594. private _transientComponents;
  32595. /**
  32596. * Registers the transient components if needed.
  32597. */
  32598. private _registerTransientComponents;
  32599. /**
  32600. * @hidden
  32601. * Add a component to the scene.
  32602. * Note that the ccomponent could be registered on th next frame if this is called after
  32603. * the register component stage.
  32604. * @param component Defines the component to add to the scene
  32605. */
  32606. _addComponent(component: ISceneComponent): void;
  32607. /**
  32608. * @hidden
  32609. * Gets a component from the scene.
  32610. * @param name defines the name of the component to retrieve
  32611. * @returns the component or null if not present
  32612. */
  32613. _getComponent(name: string): Nullable<ISceneComponent>;
  32614. /**
  32615. * @hidden
  32616. * Defines the actions happening before camera updates.
  32617. */
  32618. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32619. /**
  32620. * @hidden
  32621. * Defines the actions happening before clear the canvas.
  32622. */
  32623. _beforeClearStage: Stage<SimpleStageAction>;
  32624. /**
  32625. * @hidden
  32626. * Defines the actions when collecting render targets for the frame.
  32627. */
  32628. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32629. /**
  32630. * @hidden
  32631. * Defines the actions happening for one camera in the frame.
  32632. */
  32633. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32634. /**
  32635. * @hidden
  32636. * Defines the actions happening during the per mesh ready checks.
  32637. */
  32638. _isReadyForMeshStage: Stage<MeshStageAction>;
  32639. /**
  32640. * @hidden
  32641. * Defines the actions happening before evaluate active mesh checks.
  32642. */
  32643. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32644. /**
  32645. * @hidden
  32646. * Defines the actions happening during the evaluate sub mesh checks.
  32647. */
  32648. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32649. /**
  32650. * @hidden
  32651. * Defines the actions happening during the active mesh stage.
  32652. */
  32653. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32654. /**
  32655. * @hidden
  32656. * Defines the actions happening during the per camera render target step.
  32657. */
  32658. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  32659. /**
  32660. * @hidden
  32661. * Defines the actions happening just before the active camera is drawing.
  32662. */
  32663. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32664. /**
  32665. * @hidden
  32666. * Defines the actions happening just before a render target is drawing.
  32667. */
  32668. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32669. /**
  32670. * @hidden
  32671. * Defines the actions happening just before a rendering group is drawing.
  32672. */
  32673. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32674. /**
  32675. * @hidden
  32676. * Defines the actions happening just before a mesh is drawing.
  32677. */
  32678. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32679. /**
  32680. * @hidden
  32681. * Defines the actions happening just after a mesh has been drawn.
  32682. */
  32683. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32684. /**
  32685. * @hidden
  32686. * Defines the actions happening just after a rendering group has been drawn.
  32687. */
  32688. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32689. /**
  32690. * @hidden
  32691. * Defines the actions happening just after the active camera has been drawn.
  32692. */
  32693. _afterCameraDrawStage: Stage<CameraStageAction>;
  32694. /**
  32695. * @hidden
  32696. * Defines the actions happening just after a render target has been drawn.
  32697. */
  32698. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32699. /**
  32700. * @hidden
  32701. * Defines the actions happening just after rendering all cameras and computing intersections.
  32702. */
  32703. _afterRenderStage: Stage<SimpleStageAction>;
  32704. /**
  32705. * @hidden
  32706. * Defines the actions happening when a pointer move event happens.
  32707. */
  32708. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32709. /**
  32710. * @hidden
  32711. * Defines the actions happening when a pointer down event happens.
  32712. */
  32713. _pointerDownStage: Stage<PointerUpDownStageAction>;
  32714. /**
  32715. * @hidden
  32716. * Defines the actions happening when a pointer up event happens.
  32717. */
  32718. _pointerUpStage: Stage<PointerUpDownStageAction>;
  32719. /**
  32720. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32721. */
  32722. private geometriesByUniqueId;
  32723. /**
  32724. * Creates a new Scene
  32725. * @param engine defines the engine to use to render this scene
  32726. * @param options defines the scene options
  32727. */
  32728. constructor(engine: Engine, options?: SceneOptions);
  32729. private _defaultMeshCandidates;
  32730. /**
  32731. * @hidden
  32732. */
  32733. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32734. private _defaultSubMeshCandidates;
  32735. /**
  32736. * @hidden
  32737. */
  32738. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32739. /**
  32740. * Sets the default candidate providers for the scene.
  32741. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32742. * and getCollidingSubMeshCandidates to their default function
  32743. */
  32744. setDefaultCandidateProviders(): void;
  32745. /**
  32746. * Gets the mesh that is currently under the pointer
  32747. */
  32748. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32749. /**
  32750. * Gets or sets the current on-screen X position of the pointer
  32751. */
  32752. pointerX: number;
  32753. /**
  32754. * Gets or sets the current on-screen Y position of the pointer
  32755. */
  32756. pointerY: number;
  32757. /**
  32758. * Gets the cached material (ie. the latest rendered one)
  32759. * @returns the cached material
  32760. */
  32761. getCachedMaterial(): Nullable<Material>;
  32762. /**
  32763. * Gets the cached effect (ie. the latest rendered one)
  32764. * @returns the cached effect
  32765. */
  32766. getCachedEffect(): Nullable<Effect>;
  32767. /**
  32768. * Gets the cached visibility state (ie. the latest rendered one)
  32769. * @returns the cached visibility state
  32770. */
  32771. getCachedVisibility(): Nullable<number>;
  32772. /**
  32773. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32774. * @param material defines the current material
  32775. * @param effect defines the current effect
  32776. * @param visibility defines the current visibility state
  32777. * @returns true if one parameter is not cached
  32778. */
  32779. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32780. /**
  32781. * Gets the engine associated with the scene
  32782. * @returns an Engine
  32783. */
  32784. getEngine(): Engine;
  32785. /**
  32786. * Gets the total number of vertices rendered per frame
  32787. * @returns the total number of vertices rendered per frame
  32788. */
  32789. getTotalVertices(): number;
  32790. /**
  32791. * Gets the performance counter for total vertices
  32792. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32793. */
  32794. readonly totalVerticesPerfCounter: PerfCounter;
  32795. /**
  32796. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32797. * @returns the total number of active indices rendered per frame
  32798. */
  32799. getActiveIndices(): number;
  32800. /**
  32801. * Gets the performance counter for active indices
  32802. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32803. */
  32804. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32805. /**
  32806. * Gets the total number of active particles rendered per frame
  32807. * @returns the total number of active particles rendered per frame
  32808. */
  32809. getActiveParticles(): number;
  32810. /**
  32811. * Gets the performance counter for active particles
  32812. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32813. */
  32814. readonly activeParticlesPerfCounter: PerfCounter;
  32815. /**
  32816. * Gets the total number of active bones rendered per frame
  32817. * @returns the total number of active bones rendered per frame
  32818. */
  32819. getActiveBones(): number;
  32820. /**
  32821. * Gets the performance counter for active bones
  32822. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32823. */
  32824. readonly activeBonesPerfCounter: PerfCounter;
  32825. /**
  32826. * Gets the array of active meshes
  32827. * @returns an array of AbstractMesh
  32828. */
  32829. getActiveMeshes(): SmartArray<AbstractMesh>;
  32830. /**
  32831. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32832. * @returns a number
  32833. */
  32834. getAnimationRatio(): number;
  32835. /**
  32836. * Gets an unique Id for the current render phase
  32837. * @returns a number
  32838. */
  32839. getRenderId(): number;
  32840. /**
  32841. * Gets an unique Id for the current frame
  32842. * @returns a number
  32843. */
  32844. getFrameId(): number;
  32845. /** Call this function if you want to manually increment the render Id*/
  32846. incrementRenderId(): void;
  32847. private _updatePointerPosition;
  32848. private _createUbo;
  32849. private _createAlternateUbo;
  32850. private _setRayOnPointerInfo;
  32851. /**
  32852. * Use this method to simulate a pointer move on a mesh
  32853. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32854. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32855. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32856. * @returns the current scene
  32857. */
  32858. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32859. private _processPointerMove;
  32860. private _checkPrePointerObservable;
  32861. /**
  32862. * Use this method to simulate a pointer down on a mesh
  32863. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32864. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32865. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32866. * @returns the current scene
  32867. */
  32868. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32869. private _processPointerDown;
  32870. /**
  32871. * Use this method to simulate a pointer up on a mesh
  32872. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32873. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32874. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32875. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32876. * @returns the current scene
  32877. */
  32878. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32879. private _processPointerUp;
  32880. /**
  32881. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32882. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32883. * @returns true if the pointer was captured
  32884. */
  32885. isPointerCaptured(pointerId?: number): boolean;
  32886. /** @hidden */
  32887. _isPointerSwiping(): boolean;
  32888. /**
  32889. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32890. * @param attachUp defines if you want to attach events to pointerup
  32891. * @param attachDown defines if you want to attach events to pointerdown
  32892. * @param attachMove defines if you want to attach events to pointermove
  32893. */
  32894. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32895. /** Detaches all event handlers*/
  32896. detachControl(): void;
  32897. /**
  32898. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32899. * Delay loaded resources are not taking in account
  32900. * @return true if all required resources are ready
  32901. */
  32902. isReady(): boolean;
  32903. /** Resets all cached information relative to material (including effect and visibility) */
  32904. resetCachedMaterial(): void;
  32905. /**
  32906. * Registers a function to be called before every frame render
  32907. * @param func defines the function to register
  32908. */
  32909. registerBeforeRender(func: () => void): void;
  32910. /**
  32911. * Unregisters a function called before every frame render
  32912. * @param func defines the function to unregister
  32913. */
  32914. unregisterBeforeRender(func: () => void): void;
  32915. /**
  32916. * Registers a function to be called after every frame render
  32917. * @param func defines the function to register
  32918. */
  32919. registerAfterRender(func: () => void): void;
  32920. /**
  32921. * Unregisters a function called after every frame render
  32922. * @param func defines the function to unregister
  32923. */
  32924. unregisterAfterRender(func: () => void): void;
  32925. private _executeOnceBeforeRender;
  32926. /**
  32927. * The provided function will run before render once and will be disposed afterwards.
  32928. * A timeout delay can be provided so that the function will be executed in N ms.
  32929. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32930. * @param func The function to be executed.
  32931. * @param timeout optional delay in ms
  32932. */
  32933. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32934. /** @hidden */
  32935. _addPendingData(data: any): void;
  32936. /** @hidden */
  32937. _removePendingData(data: any): void;
  32938. /**
  32939. * Returns the number of items waiting to be loaded
  32940. * @returns the number of items waiting to be loaded
  32941. */
  32942. getWaitingItemsCount(): number;
  32943. /**
  32944. * Returns a boolean indicating if the scene is still loading data
  32945. */
  32946. readonly isLoading: boolean;
  32947. /**
  32948. * Registers a function to be executed when the scene is ready
  32949. * @param {Function} func - the function to be executed
  32950. */
  32951. executeWhenReady(func: () => void): void;
  32952. /**
  32953. * Returns a promise that resolves when the scene is ready
  32954. * @returns A promise that resolves when the scene is ready
  32955. */
  32956. whenReadyAsync(): Promise<void>;
  32957. /** @hidden */
  32958. _checkIsReady(): void;
  32959. /**
  32960. * Gets all animatable attached to the scene
  32961. */
  32962. readonly animatables: Animatable[];
  32963. /**
  32964. * Resets the last animation time frame.
  32965. * Useful to override when animations start running when loading a scene for the first time.
  32966. */
  32967. resetLastAnimationTimeFrame(): void;
  32968. /** @hidden */
  32969. _switchToAlternateCameraConfiguration(active: boolean): void;
  32970. /**
  32971. * Gets the current view matrix
  32972. * @returns a Matrix
  32973. */
  32974. getViewMatrix(): Matrix;
  32975. /**
  32976. * Gets the current projection matrix
  32977. * @returns a Matrix
  32978. */
  32979. getProjectionMatrix(): Matrix;
  32980. /**
  32981. * Gets the current transform matrix
  32982. * @returns a Matrix made of View * Projection
  32983. */
  32984. getTransformMatrix(): Matrix;
  32985. /**
  32986. * Sets the current transform matrix
  32987. * @param view defines the View matrix to use
  32988. * @param projection defines the Projection matrix to use
  32989. */
  32990. setTransformMatrix(view: Matrix, projection: Matrix): void;
  32991. /** @hidden */
  32992. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  32993. /**
  32994. * Gets the uniform buffer used to store scene data
  32995. * @returns a UniformBuffer
  32996. */
  32997. getSceneUniformBuffer(): UniformBuffer;
  32998. /**
  32999. * Gets an unique (relatively to the current scene) Id
  33000. * @returns an unique number for the scene
  33001. */
  33002. getUniqueId(): number;
  33003. /**
  33004. * Add a mesh to the list of scene's meshes
  33005. * @param newMesh defines the mesh to add
  33006. * @param recursive if all child meshes should also be added to the scene
  33007. */
  33008. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33009. /**
  33010. * Remove a mesh for the list of scene's meshes
  33011. * @param toRemove defines the mesh to remove
  33012. * @param recursive if all child meshes should also be removed from the scene
  33013. * @returns the index where the mesh was in the mesh list
  33014. */
  33015. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33016. /**
  33017. * Add a transform node to the list of scene's transform nodes
  33018. * @param newTransformNode defines the transform node to add
  33019. */
  33020. addTransformNode(newTransformNode: TransformNode): void;
  33021. /**
  33022. * Remove a transform node for the list of scene's transform nodes
  33023. * @param toRemove defines the transform node to remove
  33024. * @returns the index where the transform node was in the transform node list
  33025. */
  33026. removeTransformNode(toRemove: TransformNode): number;
  33027. /**
  33028. * Remove a skeleton for the list of scene's skeletons
  33029. * @param toRemove defines the skeleton to remove
  33030. * @returns the index where the skeleton was in the skeleton list
  33031. */
  33032. removeSkeleton(toRemove: Skeleton): number;
  33033. /**
  33034. * Remove a morph target for the list of scene's morph targets
  33035. * @param toRemove defines the morph target to remove
  33036. * @returns the index where the morph target was in the morph target list
  33037. */
  33038. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33039. /**
  33040. * Remove a light for the list of scene's lights
  33041. * @param toRemove defines the light to remove
  33042. * @returns the index where the light was in the light list
  33043. */
  33044. removeLight(toRemove: Light): number;
  33045. /**
  33046. * Remove a camera for the list of scene's cameras
  33047. * @param toRemove defines the camera to remove
  33048. * @returns the index where the camera was in the camera list
  33049. */
  33050. removeCamera(toRemove: Camera): number;
  33051. /**
  33052. * Remove a particle system for the list of scene's particle systems
  33053. * @param toRemove defines the particle system to remove
  33054. * @returns the index where the particle system was in the particle system list
  33055. */
  33056. removeParticleSystem(toRemove: IParticleSystem): number;
  33057. /**
  33058. * Remove a animation for the list of scene's animations
  33059. * @param toRemove defines the animation to remove
  33060. * @returns the index where the animation was in the animation list
  33061. */
  33062. removeAnimation(toRemove: Animation): number;
  33063. /**
  33064. * Removes the given animation group from this scene.
  33065. * @param toRemove The animation group to remove
  33066. * @returns The index of the removed animation group
  33067. */
  33068. removeAnimationGroup(toRemove: AnimationGroup): number;
  33069. /**
  33070. * Removes the given multi-material from this scene.
  33071. * @param toRemove The multi-material to remove
  33072. * @returns The index of the removed multi-material
  33073. */
  33074. removeMultiMaterial(toRemove: MultiMaterial): number;
  33075. /**
  33076. * Removes the given material from this scene.
  33077. * @param toRemove The material to remove
  33078. * @returns The index of the removed material
  33079. */
  33080. removeMaterial(toRemove: Material): number;
  33081. /**
  33082. * Removes the given action manager from this scene.
  33083. * @param toRemove The action manager to remove
  33084. * @returns The index of the removed action manager
  33085. */
  33086. removeActionManager(toRemove: AbstractActionManager): number;
  33087. /**
  33088. * Removes the given texture from this scene.
  33089. * @param toRemove The texture to remove
  33090. * @returns The index of the removed texture
  33091. */
  33092. removeTexture(toRemove: BaseTexture): number;
  33093. /**
  33094. * Adds the given light to this scene
  33095. * @param newLight The light to add
  33096. */
  33097. addLight(newLight: Light): void;
  33098. /**
  33099. * Sorts the list list based on light priorities
  33100. */
  33101. sortLightsByPriority(): void;
  33102. /**
  33103. * Adds the given camera to this scene
  33104. * @param newCamera The camera to add
  33105. */
  33106. addCamera(newCamera: Camera): void;
  33107. /**
  33108. * Adds the given skeleton to this scene
  33109. * @param newSkeleton The skeleton to add
  33110. */
  33111. addSkeleton(newSkeleton: Skeleton): void;
  33112. /**
  33113. * Adds the given particle system to this scene
  33114. * @param newParticleSystem The particle system to add
  33115. */
  33116. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33117. /**
  33118. * Adds the given animation to this scene
  33119. * @param newAnimation The animation to add
  33120. */
  33121. addAnimation(newAnimation: Animation): void;
  33122. /**
  33123. * Adds the given animation group to this scene.
  33124. * @param newAnimationGroup The animation group to add
  33125. */
  33126. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33127. /**
  33128. * Adds the given multi-material to this scene
  33129. * @param newMultiMaterial The multi-material to add
  33130. */
  33131. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33132. /**
  33133. * Adds the given material to this scene
  33134. * @param newMaterial The material to add
  33135. */
  33136. addMaterial(newMaterial: Material): void;
  33137. /**
  33138. * Adds the given morph target to this scene
  33139. * @param newMorphTargetManager The morph target to add
  33140. */
  33141. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33142. /**
  33143. * Adds the given geometry to this scene
  33144. * @param newGeometry The geometry to add
  33145. */
  33146. addGeometry(newGeometry: Geometry): void;
  33147. /**
  33148. * Adds the given action manager to this scene
  33149. * @param newActionManager The action manager to add
  33150. */
  33151. addActionManager(newActionManager: AbstractActionManager): void;
  33152. /**
  33153. * Adds the given texture to this scene.
  33154. * @param newTexture The texture to add
  33155. */
  33156. addTexture(newTexture: BaseTexture): void;
  33157. /**
  33158. * Switch active camera
  33159. * @param newCamera defines the new active camera
  33160. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33161. */
  33162. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33163. /**
  33164. * sets the active camera of the scene using its ID
  33165. * @param id defines the camera's ID
  33166. * @return the new active camera or null if none found.
  33167. */
  33168. setActiveCameraByID(id: string): Nullable<Camera>;
  33169. /**
  33170. * sets the active camera of the scene using its name
  33171. * @param name defines the camera's name
  33172. * @returns the new active camera or null if none found.
  33173. */
  33174. setActiveCameraByName(name: string): Nullable<Camera>;
  33175. /**
  33176. * get an animation group using its name
  33177. * @param name defines the material's name
  33178. * @return the animation group or null if none found.
  33179. */
  33180. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33181. /**
  33182. * get a material using its id
  33183. * @param id defines the material's ID
  33184. * @return the material or null if none found.
  33185. */
  33186. getMaterialByID(id: string): Nullable<Material>;
  33187. /**
  33188. * Gets a material using its name
  33189. * @param name defines the material's name
  33190. * @return the material or null if none found.
  33191. */
  33192. getMaterialByName(name: string): Nullable<Material>;
  33193. /**
  33194. * Gets a camera using its id
  33195. * @param id defines the id to look for
  33196. * @returns the camera or null if not found
  33197. */
  33198. getCameraByID(id: string): Nullable<Camera>;
  33199. /**
  33200. * Gets a camera using its unique id
  33201. * @param uniqueId defines the unique id to look for
  33202. * @returns the camera or null if not found
  33203. */
  33204. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33205. /**
  33206. * Gets a camera using its name
  33207. * @param name defines the camera's name
  33208. * @return the camera or null if none found.
  33209. */
  33210. getCameraByName(name: string): Nullable<Camera>;
  33211. /**
  33212. * Gets a bone using its id
  33213. * @param id defines the bone's id
  33214. * @return the bone or null if not found
  33215. */
  33216. getBoneByID(id: string): Nullable<Bone>;
  33217. /**
  33218. * Gets a bone using its id
  33219. * @param name defines the bone's name
  33220. * @return the bone or null if not found
  33221. */
  33222. getBoneByName(name: string): Nullable<Bone>;
  33223. /**
  33224. * Gets a light node using its name
  33225. * @param name defines the the light's name
  33226. * @return the light or null if none found.
  33227. */
  33228. getLightByName(name: string): Nullable<Light>;
  33229. /**
  33230. * Gets a light node using its id
  33231. * @param id defines the light's id
  33232. * @return the light or null if none found.
  33233. */
  33234. getLightByID(id: string): Nullable<Light>;
  33235. /**
  33236. * Gets a light node using its scene-generated unique ID
  33237. * @param uniqueId defines the light's unique id
  33238. * @return the light or null if none found.
  33239. */
  33240. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33241. /**
  33242. * Gets a particle system by id
  33243. * @param id defines the particle system id
  33244. * @return the corresponding system or null if none found
  33245. */
  33246. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33247. /**
  33248. * Gets a geometry using its ID
  33249. * @param id defines the geometry's id
  33250. * @return the geometry or null if none found.
  33251. */
  33252. getGeometryByID(id: string): Nullable<Geometry>;
  33253. private _getGeometryByUniqueID;
  33254. /**
  33255. * Add a new geometry to this scene
  33256. * @param geometry defines the geometry to be added to the scene.
  33257. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33258. * @return a boolean defining if the geometry was added or not
  33259. */
  33260. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33261. /**
  33262. * Removes an existing geometry
  33263. * @param geometry defines the geometry to be removed from the scene
  33264. * @return a boolean defining if the geometry was removed or not
  33265. */
  33266. removeGeometry(geometry: Geometry): boolean;
  33267. /**
  33268. * Gets the list of geometries attached to the scene
  33269. * @returns an array of Geometry
  33270. */
  33271. getGeometries(): Geometry[];
  33272. /**
  33273. * Gets the first added mesh found of a given ID
  33274. * @param id defines the id to search for
  33275. * @return the mesh found or null if not found at all
  33276. */
  33277. getMeshByID(id: string): Nullable<AbstractMesh>;
  33278. /**
  33279. * Gets a list of meshes using their id
  33280. * @param id defines the id to search for
  33281. * @returns a list of meshes
  33282. */
  33283. getMeshesByID(id: string): Array<AbstractMesh>;
  33284. /**
  33285. * Gets the first added transform node found of a given ID
  33286. * @param id defines the id to search for
  33287. * @return the found transform node or null if not found at all.
  33288. */
  33289. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33290. /**
  33291. * Gets a list of transform nodes using their id
  33292. * @param id defines the id to search for
  33293. * @returns a list of transform nodes
  33294. */
  33295. getTransformNodesByID(id: string): Array<TransformNode>;
  33296. /**
  33297. * Gets a mesh with its auto-generated unique id
  33298. * @param uniqueId defines the unique id to search for
  33299. * @return the found mesh or null if not found at all.
  33300. */
  33301. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33302. /**
  33303. * Gets a the last added mesh using a given id
  33304. * @param id defines the id to search for
  33305. * @return the found mesh or null if not found at all.
  33306. */
  33307. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33308. /**
  33309. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33310. * @param id defines the id to search for
  33311. * @return the found node or null if not found at all
  33312. */
  33313. getLastEntryByID(id: string): Nullable<Node>;
  33314. /**
  33315. * Gets a node (Mesh, Camera, Light) using a given id
  33316. * @param id defines the id to search for
  33317. * @return the found node or null if not found at all
  33318. */
  33319. getNodeByID(id: string): Nullable<Node>;
  33320. /**
  33321. * Gets a node (Mesh, Camera, Light) using a given name
  33322. * @param name defines the name to search for
  33323. * @return the found node or null if not found at all.
  33324. */
  33325. getNodeByName(name: string): Nullable<Node>;
  33326. /**
  33327. * Gets a mesh using a given name
  33328. * @param name defines the name to search for
  33329. * @return the found mesh or null if not found at all.
  33330. */
  33331. getMeshByName(name: string): Nullable<AbstractMesh>;
  33332. /**
  33333. * Gets a transform node using a given name
  33334. * @param name defines the name to search for
  33335. * @return the found transform node or null if not found at all.
  33336. */
  33337. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33338. /**
  33339. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33340. * @param id defines the id to search for
  33341. * @return the found skeleton or null if not found at all.
  33342. */
  33343. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33344. /**
  33345. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33346. * @param id defines the id to search for
  33347. * @return the found skeleton or null if not found at all.
  33348. */
  33349. getSkeletonById(id: string): Nullable<Skeleton>;
  33350. /**
  33351. * Gets a skeleton using a given name
  33352. * @param name defines the name to search for
  33353. * @return the found skeleton or null if not found at all.
  33354. */
  33355. getSkeletonByName(name: string): Nullable<Skeleton>;
  33356. /**
  33357. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33358. * @param id defines the id to search for
  33359. * @return the found morph target manager or null if not found at all.
  33360. */
  33361. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33362. /**
  33363. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33364. * @param id defines the id to search for
  33365. * @return the found morph target or null if not found at all.
  33366. */
  33367. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33368. /**
  33369. * Gets a boolean indicating if the given mesh is active
  33370. * @param mesh defines the mesh to look for
  33371. * @returns true if the mesh is in the active list
  33372. */
  33373. isActiveMesh(mesh: AbstractMesh): boolean;
  33374. /**
  33375. * Return a unique id as a string which can serve as an identifier for the scene
  33376. */
  33377. readonly uid: string;
  33378. /**
  33379. * Add an externaly attached data from its key.
  33380. * This method call will fail and return false, if such key already exists.
  33381. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33382. * @param key the unique key that identifies the data
  33383. * @param data the data object to associate to the key for this Engine instance
  33384. * @return true if no such key were already present and the data was added successfully, false otherwise
  33385. */
  33386. addExternalData<T>(key: string, data: T): boolean;
  33387. /**
  33388. * Get an externaly attached data from its key
  33389. * @param key the unique key that identifies the data
  33390. * @return the associated data, if present (can be null), or undefined if not present
  33391. */
  33392. getExternalData<T>(key: string): Nullable<T>;
  33393. /**
  33394. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33395. * @param key the unique key that identifies the data
  33396. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33397. * @return the associated data, can be null if the factory returned null.
  33398. */
  33399. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33400. /**
  33401. * Remove an externaly attached data from the Engine instance
  33402. * @param key the unique key that identifies the data
  33403. * @return true if the data was successfully removed, false if it doesn't exist
  33404. */
  33405. removeExternalData(key: string): boolean;
  33406. private _evaluateSubMesh;
  33407. /**
  33408. * Clear the processed materials smart array preventing retention point in material dispose.
  33409. */
  33410. freeProcessedMaterials(): void;
  33411. private _preventFreeActiveMeshesAndRenderingGroups;
  33412. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33413. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33414. * when disposing several meshes in a row or a hierarchy of meshes.
  33415. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33416. */
  33417. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33418. /**
  33419. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33420. */
  33421. freeActiveMeshes(): void;
  33422. /**
  33423. * Clear the info related to rendering groups preventing retention points during dispose.
  33424. */
  33425. freeRenderingGroups(): void;
  33426. /** @hidden */
  33427. _isInIntermediateRendering(): boolean;
  33428. /**
  33429. * Lambda returning the list of potentially active meshes.
  33430. */
  33431. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33432. /**
  33433. * Lambda returning the list of potentially active sub meshes.
  33434. */
  33435. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33436. /**
  33437. * Lambda returning the list of potentially intersecting sub meshes.
  33438. */
  33439. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33440. /**
  33441. * Lambda returning the list of potentially colliding sub meshes.
  33442. */
  33443. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33444. private _activeMeshesFrozen;
  33445. /**
  33446. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33447. * @returns the current scene
  33448. */
  33449. freezeActiveMeshes(): Scene;
  33450. /**
  33451. * Use this function to restart evaluating active meshes on every frame
  33452. * @returns the current scene
  33453. */
  33454. unfreezeActiveMeshes(): Scene;
  33455. private _evaluateActiveMeshes;
  33456. private _activeMesh;
  33457. /**
  33458. * Update the transform matrix to update from the current active camera
  33459. * @param force defines a boolean used to force the update even if cache is up to date
  33460. */
  33461. updateTransformMatrix(force?: boolean): void;
  33462. /**
  33463. * 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)
  33464. * @param alternateCamera defines the camera to use
  33465. */
  33466. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  33467. /** @hidden */
  33468. _allowPostProcessClearColor: boolean;
  33469. private _renderForCamera;
  33470. private _processSubCameras;
  33471. private _checkIntersections;
  33472. /** @hidden */
  33473. _advancePhysicsEngineStep(step: number): void;
  33474. /**
  33475. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33476. */
  33477. getDeterministicFrameTime: () => number;
  33478. /** @hidden */
  33479. _animate(): void;
  33480. /**
  33481. * Render the scene
  33482. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33483. */
  33484. render(updateCameras?: boolean): void;
  33485. /**
  33486. * Freeze all materials
  33487. * A frozen material will not be updatable but should be faster to render
  33488. */
  33489. freezeMaterials(): void;
  33490. /**
  33491. * Unfreeze all materials
  33492. * A frozen material will not be updatable but should be faster to render
  33493. */
  33494. unfreezeMaterials(): void;
  33495. /**
  33496. * Releases all held ressources
  33497. */
  33498. dispose(): void;
  33499. /**
  33500. * Gets if the scene is already disposed
  33501. */
  33502. readonly isDisposed: boolean;
  33503. /**
  33504. * Call this function to reduce memory footprint of the scene.
  33505. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33506. */
  33507. clearCachedVertexData(): void;
  33508. /**
  33509. * This function will remove the local cached buffer data from texture.
  33510. * It will save memory but will prevent the texture from being rebuilt
  33511. */
  33512. cleanCachedTextureBuffer(): void;
  33513. /**
  33514. * Get the world extend vectors with an optional filter
  33515. *
  33516. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33517. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33518. */
  33519. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33520. min: Vector3;
  33521. max: Vector3;
  33522. };
  33523. /**
  33524. * Creates a ray that can be used to pick in the scene
  33525. * @param x defines the x coordinate of the origin (on-screen)
  33526. * @param y defines the y coordinate of the origin (on-screen)
  33527. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33528. * @param camera defines the camera to use for the picking
  33529. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33530. * @returns a Ray
  33531. */
  33532. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33533. /**
  33534. * Creates a ray that can be used to pick in the scene
  33535. * @param x defines the x coordinate of the origin (on-screen)
  33536. * @param y defines the y coordinate of the origin (on-screen)
  33537. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33538. * @param result defines the ray where to store the picking ray
  33539. * @param camera defines the camera to use for the picking
  33540. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33541. * @returns the current scene
  33542. */
  33543. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33544. /**
  33545. * Creates a ray that can be used to pick in the scene
  33546. * @param x defines the x coordinate of the origin (on-screen)
  33547. * @param y defines the y coordinate of the origin (on-screen)
  33548. * @param camera defines the camera to use for the picking
  33549. * @returns a Ray
  33550. */
  33551. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33552. /**
  33553. * Creates a ray that can be used to pick in the scene
  33554. * @param x defines the x coordinate of the origin (on-screen)
  33555. * @param y defines the y coordinate of the origin (on-screen)
  33556. * @param result defines the ray where to store the picking ray
  33557. * @param camera defines the camera to use for the picking
  33558. * @returns the current scene
  33559. */
  33560. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33561. /** Launch a ray to try to pick a mesh in the scene
  33562. * @param x position on screen
  33563. * @param y position on screen
  33564. * @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
  33565. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33566. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33567. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33568. * @returns a PickingInfo
  33569. */
  33570. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  33571. /** Use the given ray to pick a mesh in the scene
  33572. * @param ray The ray to use to pick meshes
  33573. * @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
  33574. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33575. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33576. * @returns a PickingInfo
  33577. */
  33578. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33579. /**
  33580. * Launch a ray to try to pick a mesh in the scene
  33581. * @param x X position on screen
  33582. * @param y Y position on screen
  33583. * @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
  33584. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33585. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33586. * @returns an array of PickingInfo
  33587. */
  33588. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33589. /**
  33590. * Launch a ray to try to pick a mesh in the scene
  33591. * @param ray Ray to use
  33592. * @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
  33593. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33594. * @returns an array of PickingInfo
  33595. */
  33596. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33597. /**
  33598. * Force the value of meshUnderPointer
  33599. * @param mesh defines the mesh to use
  33600. */
  33601. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33602. /**
  33603. * Gets the mesh under the pointer
  33604. * @returns a Mesh or null if no mesh is under the pointer
  33605. */
  33606. getPointerOverMesh(): Nullable<AbstractMesh>;
  33607. /** @hidden */
  33608. _rebuildGeometries(): void;
  33609. /** @hidden */
  33610. _rebuildTextures(): void;
  33611. private _getByTags;
  33612. /**
  33613. * Get a list of meshes by tags
  33614. * @param tagsQuery defines the tags query to use
  33615. * @param forEach defines a predicate used to filter results
  33616. * @returns an array of Mesh
  33617. */
  33618. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33619. /**
  33620. * Get a list of cameras by tags
  33621. * @param tagsQuery defines the tags query to use
  33622. * @param forEach defines a predicate used to filter results
  33623. * @returns an array of Camera
  33624. */
  33625. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33626. /**
  33627. * Get a list of lights by tags
  33628. * @param tagsQuery defines the tags query to use
  33629. * @param forEach defines a predicate used to filter results
  33630. * @returns an array of Light
  33631. */
  33632. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33633. /**
  33634. * Get a list of materials by tags
  33635. * @param tagsQuery defines the tags query to use
  33636. * @param forEach defines a predicate used to filter results
  33637. * @returns an array of Material
  33638. */
  33639. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33640. /**
  33641. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33642. * This allowed control for front to back rendering or reversly depending of the special needs.
  33643. *
  33644. * @param renderingGroupId The rendering group id corresponding to its index
  33645. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33646. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33647. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33648. */
  33649. 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;
  33650. /**
  33651. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33652. *
  33653. * @param renderingGroupId The rendering group id corresponding to its index
  33654. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33655. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33656. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33657. */
  33658. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33659. /**
  33660. * Gets the current auto clear configuration for one rendering group of the rendering
  33661. * manager.
  33662. * @param index the rendering group index to get the information for
  33663. * @returns The auto clear setup for the requested rendering group
  33664. */
  33665. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33666. private _blockMaterialDirtyMechanism;
  33667. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33668. blockMaterialDirtyMechanism: boolean;
  33669. /**
  33670. * Will flag all materials as dirty to trigger new shader compilation
  33671. * @param flag defines the flag used to specify which material part must be marked as dirty
  33672. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33673. */
  33674. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33675. /** @hidden */
  33676. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  33677. /** @hidden */
  33678. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33679. }
  33680. }
  33681. declare module "babylonjs/assetContainer" {
  33682. import { AbstractScene } from "babylonjs/abstractScene";
  33683. import { Scene } from "babylonjs/scene";
  33684. import { Mesh } from "babylonjs/Meshes/mesh";
  33685. /**
  33686. * Set of assets to keep when moving a scene into an asset container.
  33687. */
  33688. export class KeepAssets extends AbstractScene {
  33689. }
  33690. /**
  33691. * Container with a set of assets that can be added or removed from a scene.
  33692. */
  33693. export class AssetContainer extends AbstractScene {
  33694. /**
  33695. * The scene the AssetContainer belongs to.
  33696. */
  33697. scene: Scene;
  33698. /**
  33699. * Instantiates an AssetContainer.
  33700. * @param scene The scene the AssetContainer belongs to.
  33701. */
  33702. constructor(scene: Scene);
  33703. /**
  33704. * Adds all the assets from the container to the scene.
  33705. */
  33706. addAllToScene(): void;
  33707. /**
  33708. * Removes all the assets in the container from the scene
  33709. */
  33710. removeAllFromScene(): void;
  33711. /**
  33712. * Disposes all the assets in the container
  33713. */
  33714. dispose(): void;
  33715. private _moveAssets;
  33716. /**
  33717. * Removes all the assets contained in the scene and adds them to the container.
  33718. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33719. */
  33720. moveAllFromScene(keepAssets?: KeepAssets): void;
  33721. /**
  33722. * 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.
  33723. * @returns the root mesh
  33724. */
  33725. createRootMesh(): Mesh;
  33726. }
  33727. }
  33728. declare module "babylonjs/abstractScene" {
  33729. import { Scene } from "babylonjs/scene";
  33730. import { Nullable } from "babylonjs/types";
  33731. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33732. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33733. import { Geometry } from "babylonjs/Meshes/geometry";
  33734. import { Skeleton } from "babylonjs/Bones/skeleton";
  33735. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33736. import { AssetContainer } from "babylonjs/assetContainer";
  33737. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33738. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33739. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33740. import { Material } from "babylonjs/Materials/material";
  33741. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33742. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33743. import { Camera } from "babylonjs/Cameras/camera";
  33744. import { Light } from "babylonjs/Lights/light";
  33745. import { Node } from "babylonjs/node";
  33746. import { Animation } from "babylonjs/Animations/animation";
  33747. /**
  33748. * Defines how the parser contract is defined.
  33749. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33750. */
  33751. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33752. /**
  33753. * Defines how the individual parser contract is defined.
  33754. * These parser can parse an individual asset
  33755. */
  33756. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33757. /**
  33758. * Base class of the scene acting as a container for the different elements composing a scene.
  33759. * This class is dynamically extended by the different components of the scene increasing
  33760. * flexibility and reducing coupling
  33761. */
  33762. export abstract class AbstractScene {
  33763. /**
  33764. * Stores the list of available parsers in the application.
  33765. */
  33766. private static _BabylonFileParsers;
  33767. /**
  33768. * Stores the list of available individual parsers in the application.
  33769. */
  33770. private static _IndividualBabylonFileParsers;
  33771. /**
  33772. * Adds a parser in the list of available ones
  33773. * @param name Defines the name of the parser
  33774. * @param parser Defines the parser to add
  33775. */
  33776. static AddParser(name: string, parser: BabylonFileParser): void;
  33777. /**
  33778. * Gets a general parser from the list of avaialble ones
  33779. * @param name Defines the name of the parser
  33780. * @returns the requested parser or null
  33781. */
  33782. static GetParser(name: string): Nullable<BabylonFileParser>;
  33783. /**
  33784. * Adds n individual parser in the list of available ones
  33785. * @param name Defines the name of the parser
  33786. * @param parser Defines the parser to add
  33787. */
  33788. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33789. /**
  33790. * Gets an individual parser from the list of avaialble ones
  33791. * @param name Defines the name of the parser
  33792. * @returns the requested parser or null
  33793. */
  33794. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33795. /**
  33796. * Parser json data and populate both a scene and its associated container object
  33797. * @param jsonData Defines the data to parse
  33798. * @param scene Defines the scene to parse the data for
  33799. * @param container Defines the container attached to the parsing sequence
  33800. * @param rootUrl Defines the root url of the data
  33801. */
  33802. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33803. /**
  33804. * Gets the list of root nodes (ie. nodes with no parent)
  33805. */
  33806. rootNodes: Node[];
  33807. /** All of the cameras added to this scene
  33808. * @see http://doc.babylonjs.com/babylon101/cameras
  33809. */
  33810. cameras: Camera[];
  33811. /**
  33812. * All of the lights added to this scene
  33813. * @see http://doc.babylonjs.com/babylon101/lights
  33814. */
  33815. lights: Light[];
  33816. /**
  33817. * All of the (abstract) meshes added to this scene
  33818. */
  33819. meshes: AbstractMesh[];
  33820. /**
  33821. * The list of skeletons added to the scene
  33822. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33823. */
  33824. skeletons: Skeleton[];
  33825. /**
  33826. * All of the particle systems added to this scene
  33827. * @see http://doc.babylonjs.com/babylon101/particles
  33828. */
  33829. particleSystems: IParticleSystem[];
  33830. /**
  33831. * Gets a list of Animations associated with the scene
  33832. */
  33833. animations: Animation[];
  33834. /**
  33835. * All of the animation groups added to this scene
  33836. * @see http://doc.babylonjs.com/how_to/group
  33837. */
  33838. animationGroups: AnimationGroup[];
  33839. /**
  33840. * All of the multi-materials added to this scene
  33841. * @see http://doc.babylonjs.com/how_to/multi_materials
  33842. */
  33843. multiMaterials: MultiMaterial[];
  33844. /**
  33845. * All of the materials added to this scene
  33846. * In the context of a Scene, it is not supposed to be modified manually.
  33847. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33848. * Note also that the order of the Material wihin the array is not significant and might change.
  33849. * @see http://doc.babylonjs.com/babylon101/materials
  33850. */
  33851. materials: Material[];
  33852. /**
  33853. * The list of morph target managers added to the scene
  33854. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33855. */
  33856. morphTargetManagers: MorphTargetManager[];
  33857. /**
  33858. * The list of geometries used in the scene.
  33859. */
  33860. geometries: Geometry[];
  33861. /**
  33862. * All of the tranform nodes added to this scene
  33863. * In the context of a Scene, it is not supposed to be modified manually.
  33864. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33865. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33866. * @see http://doc.babylonjs.com/how_to/transformnode
  33867. */
  33868. transformNodes: TransformNode[];
  33869. /**
  33870. * ActionManagers available on the scene.
  33871. */
  33872. actionManagers: AbstractActionManager[];
  33873. /**
  33874. * Textures to keep.
  33875. */
  33876. textures: BaseTexture[];
  33877. }
  33878. }
  33879. declare module "babylonjs/Audio/sound" {
  33880. import { Observable } from "babylonjs/Misc/observable";
  33881. import { Vector3 } from "babylonjs/Maths/math";
  33882. import { Nullable } from "babylonjs/types";
  33883. import { Scene } from "babylonjs/scene";
  33884. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33885. /**
  33886. * Defines a sound that can be played in the application.
  33887. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33888. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33889. */
  33890. export class Sound {
  33891. /**
  33892. * The name of the sound in the scene.
  33893. */
  33894. name: string;
  33895. /**
  33896. * Does the sound autoplay once loaded.
  33897. */
  33898. autoplay: boolean;
  33899. /**
  33900. * Does the sound loop after it finishes playing once.
  33901. */
  33902. loop: boolean;
  33903. /**
  33904. * Does the sound use a custom attenuation curve to simulate the falloff
  33905. * happening when the source gets further away from the camera.
  33906. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33907. */
  33908. useCustomAttenuation: boolean;
  33909. /**
  33910. * The sound track id this sound belongs to.
  33911. */
  33912. soundTrackId: number;
  33913. /**
  33914. * Is this sound currently played.
  33915. */
  33916. isPlaying: boolean;
  33917. /**
  33918. * Is this sound currently paused.
  33919. */
  33920. isPaused: boolean;
  33921. /**
  33922. * Does this sound enables spatial sound.
  33923. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33924. */
  33925. spatialSound: boolean;
  33926. /**
  33927. * Define the reference distance the sound should be heard perfectly.
  33928. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33929. */
  33930. refDistance: number;
  33931. /**
  33932. * Define the roll off factor of spatial sounds.
  33933. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33934. */
  33935. rolloffFactor: number;
  33936. /**
  33937. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33938. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33939. */
  33940. maxDistance: number;
  33941. /**
  33942. * Define the distance attenuation model the sound will follow.
  33943. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33944. */
  33945. distanceModel: string;
  33946. /**
  33947. * @hidden
  33948. * Back Compat
  33949. **/
  33950. onended: () => any;
  33951. /**
  33952. * Observable event when the current playing sound finishes.
  33953. */
  33954. onEndedObservable: Observable<Sound>;
  33955. private _panningModel;
  33956. private _playbackRate;
  33957. private _streaming;
  33958. private _startTime;
  33959. private _startOffset;
  33960. private _position;
  33961. /** @hidden */
  33962. _positionInEmitterSpace: boolean;
  33963. private _localDirection;
  33964. private _volume;
  33965. private _isReadyToPlay;
  33966. private _isDirectional;
  33967. private _readyToPlayCallback;
  33968. private _audioBuffer;
  33969. private _soundSource;
  33970. private _streamingSource;
  33971. private _soundPanner;
  33972. private _soundGain;
  33973. private _inputAudioNode;
  33974. private _outputAudioNode;
  33975. private _coneInnerAngle;
  33976. private _coneOuterAngle;
  33977. private _coneOuterGain;
  33978. private _scene;
  33979. private _connectedTransformNode;
  33980. private _customAttenuationFunction;
  33981. private _registerFunc;
  33982. private _isOutputConnected;
  33983. private _htmlAudioElement;
  33984. private _urlType;
  33985. /** @hidden */
  33986. static _SceneComponentInitialization: (scene: Scene) => void;
  33987. /**
  33988. * Create a sound and attach it to a scene
  33989. * @param name Name of your sound
  33990. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33991. * @param scene defines the scene the sound belongs to
  33992. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33993. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33994. */
  33995. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33996. /**
  33997. * Release the sound and its associated resources
  33998. */
  33999. dispose(): void;
  34000. /**
  34001. * Gets if the sounds is ready to be played or not.
  34002. * @returns true if ready, otherwise false
  34003. */
  34004. isReady(): boolean;
  34005. private _soundLoaded;
  34006. /**
  34007. * Sets the data of the sound from an audiobuffer
  34008. * @param audioBuffer The audioBuffer containing the data
  34009. */
  34010. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34011. /**
  34012. * Updates the current sounds options such as maxdistance, loop...
  34013. * @param options A JSON object containing values named as the object properties
  34014. */
  34015. updateOptions(options: any): void;
  34016. private _createSpatialParameters;
  34017. private _updateSpatialParameters;
  34018. /**
  34019. * Switch the panning model to HRTF:
  34020. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34021. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34022. */
  34023. switchPanningModelToHRTF(): void;
  34024. /**
  34025. * Switch the panning model to Equal Power:
  34026. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34027. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34028. */
  34029. switchPanningModelToEqualPower(): void;
  34030. private _switchPanningModel;
  34031. /**
  34032. * Connect this sound to a sound track audio node like gain...
  34033. * @param soundTrackAudioNode the sound track audio node to connect to
  34034. */
  34035. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34036. /**
  34037. * Transform this sound into a directional source
  34038. * @param coneInnerAngle Size of the inner cone in degree
  34039. * @param coneOuterAngle Size of the outer cone in degree
  34040. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34041. */
  34042. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34043. /**
  34044. * Gets or sets the inner angle for the directional cone.
  34045. */
  34046. /**
  34047. * Gets or sets the inner angle for the directional cone.
  34048. */
  34049. directionalConeInnerAngle: number;
  34050. /**
  34051. * Gets or sets the outer angle for the directional cone.
  34052. */
  34053. /**
  34054. * Gets or sets the outer angle for the directional cone.
  34055. */
  34056. directionalConeOuterAngle: number;
  34057. /**
  34058. * Sets the position of the emitter if spatial sound is enabled
  34059. * @param newPosition Defines the new posisiton
  34060. */
  34061. setPosition(newPosition: Vector3): void;
  34062. /**
  34063. * Sets the local direction of the emitter if spatial sound is enabled
  34064. * @param newLocalDirection Defines the new local direction
  34065. */
  34066. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34067. private _updateDirection;
  34068. /** @hidden */
  34069. updateDistanceFromListener(): void;
  34070. /**
  34071. * Sets a new custom attenuation function for the sound.
  34072. * @param callback Defines the function used for the attenuation
  34073. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34074. */
  34075. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34076. /**
  34077. * Play the sound
  34078. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34079. * @param offset (optional) Start the sound setting it at a specific time
  34080. */
  34081. play(time?: number, offset?: number): void;
  34082. private _onended;
  34083. /**
  34084. * Stop the sound
  34085. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34086. */
  34087. stop(time?: number): void;
  34088. /**
  34089. * Put the sound in pause
  34090. */
  34091. pause(): void;
  34092. /**
  34093. * Sets a dedicated volume for this sounds
  34094. * @param newVolume Define the new volume of the sound
  34095. * @param time Define in how long the sound should be at this value
  34096. */
  34097. setVolume(newVolume: number, time?: number): void;
  34098. /**
  34099. * Set the sound play back rate
  34100. * @param newPlaybackRate Define the playback rate the sound should be played at
  34101. */
  34102. setPlaybackRate(newPlaybackRate: number): void;
  34103. /**
  34104. * Gets the volume of the sound.
  34105. * @returns the volume of the sound
  34106. */
  34107. getVolume(): number;
  34108. /**
  34109. * Attach the sound to a dedicated mesh
  34110. * @param transformNode The transform node to connect the sound with
  34111. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34112. */
  34113. attachToMesh(transformNode: TransformNode): void;
  34114. /**
  34115. * Detach the sound from the previously attached mesh
  34116. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34117. */
  34118. detachFromMesh(): void;
  34119. private _onRegisterAfterWorldMatrixUpdate;
  34120. /**
  34121. * Clone the current sound in the scene.
  34122. * @returns the new sound clone
  34123. */
  34124. clone(): Nullable<Sound>;
  34125. /**
  34126. * Gets the current underlying audio buffer containing the data
  34127. * @returns the audio buffer
  34128. */
  34129. getAudioBuffer(): Nullable<AudioBuffer>;
  34130. /**
  34131. * Serializes the Sound in a JSON representation
  34132. * @returns the JSON representation of the sound
  34133. */
  34134. serialize(): any;
  34135. /**
  34136. * Parse a JSON representation of a sound to innstantiate in a given scene
  34137. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34138. * @param scene Define the scene the new parsed sound should be created in
  34139. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34140. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34141. * @returns the newly parsed sound
  34142. */
  34143. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34144. }
  34145. }
  34146. declare module "babylonjs/Actions/directAudioActions" {
  34147. import { Action } from "babylonjs/Actions/action";
  34148. import { Condition } from "babylonjs/Actions/condition";
  34149. import { Sound } from "babylonjs/Audio/sound";
  34150. /**
  34151. * This defines an action helpful to play a defined sound on a triggered action.
  34152. */
  34153. export class PlaySoundAction extends Action {
  34154. private _sound;
  34155. /**
  34156. * Instantiate the action
  34157. * @param triggerOptions defines the trigger options
  34158. * @param sound defines the sound to play
  34159. * @param condition defines the trigger related conditions
  34160. */
  34161. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34162. /** @hidden */
  34163. _prepare(): void;
  34164. /**
  34165. * Execute the action and play the sound.
  34166. */
  34167. execute(): void;
  34168. /**
  34169. * Serializes the actions and its related information.
  34170. * @param parent defines the object to serialize in
  34171. * @returns the serialized object
  34172. */
  34173. serialize(parent: any): any;
  34174. }
  34175. /**
  34176. * This defines an action helpful to stop a defined sound on a triggered action.
  34177. */
  34178. export class StopSoundAction extends Action {
  34179. private _sound;
  34180. /**
  34181. * Instantiate the action
  34182. * @param triggerOptions defines the trigger options
  34183. * @param sound defines the sound to stop
  34184. * @param condition defines the trigger related conditions
  34185. */
  34186. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34187. /** @hidden */
  34188. _prepare(): void;
  34189. /**
  34190. * Execute the action and stop the sound.
  34191. */
  34192. execute(): void;
  34193. /**
  34194. * Serializes the actions and its related information.
  34195. * @param parent defines the object to serialize in
  34196. * @returns the serialized object
  34197. */
  34198. serialize(parent: any): any;
  34199. }
  34200. }
  34201. declare module "babylonjs/Actions/interpolateValueAction" {
  34202. import { Action } from "babylonjs/Actions/action";
  34203. import { Condition } from "babylonjs/Actions/condition";
  34204. import { Observable } from "babylonjs/Misc/observable";
  34205. /**
  34206. * This defines an action responsible to change the value of a property
  34207. * by interpolating between its current value and the newly set one once triggered.
  34208. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34209. */
  34210. export class InterpolateValueAction extends Action {
  34211. /**
  34212. * Defines the path of the property where the value should be interpolated
  34213. */
  34214. propertyPath: string;
  34215. /**
  34216. * Defines the target value at the end of the interpolation.
  34217. */
  34218. value: any;
  34219. /**
  34220. * Defines the time it will take for the property to interpolate to the value.
  34221. */
  34222. duration: number;
  34223. /**
  34224. * Defines if the other scene animations should be stopped when the action has been triggered
  34225. */
  34226. stopOtherAnimations?: boolean;
  34227. /**
  34228. * Defines a callback raised once the interpolation animation has been done.
  34229. */
  34230. onInterpolationDone?: () => void;
  34231. /**
  34232. * Observable triggered once the interpolation animation has been done.
  34233. */
  34234. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34235. private _target;
  34236. private _effectiveTarget;
  34237. private _property;
  34238. /**
  34239. * Instantiate the action
  34240. * @param triggerOptions defines the trigger options
  34241. * @param target defines the object containing the value to interpolate
  34242. * @param propertyPath defines the path to the property in the target object
  34243. * @param value defines the target value at the end of the interpolation
  34244. * @param duration deines the time it will take for the property to interpolate to the value.
  34245. * @param condition defines the trigger related conditions
  34246. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34247. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34248. */
  34249. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34250. /** @hidden */
  34251. _prepare(): void;
  34252. /**
  34253. * Execute the action starts the value interpolation.
  34254. */
  34255. execute(): void;
  34256. /**
  34257. * Serializes the actions and its related information.
  34258. * @param parent defines the object to serialize in
  34259. * @returns the serialized object
  34260. */
  34261. serialize(parent: any): any;
  34262. }
  34263. }
  34264. declare module "babylonjs/Actions/index" {
  34265. export * from "babylonjs/Actions/action";
  34266. export * from "babylonjs/Actions/actionEvent";
  34267. export * from "babylonjs/Actions/actionManager";
  34268. export * from "babylonjs/Actions/condition";
  34269. export * from "babylonjs/Actions/directActions";
  34270. export * from "babylonjs/Actions/directAudioActions";
  34271. export * from "babylonjs/Actions/interpolateValueAction";
  34272. }
  34273. declare module "babylonjs/Animations/index" {
  34274. export * from "babylonjs/Animations/animatable";
  34275. export * from "babylonjs/Animations/animation";
  34276. export * from "babylonjs/Animations/animationGroup";
  34277. export * from "babylonjs/Animations/animationPropertiesOverride";
  34278. export * from "babylonjs/Animations/easing";
  34279. export * from "babylonjs/Animations/runtimeAnimation";
  34280. export * from "babylonjs/Animations/animationEvent";
  34281. export * from "babylonjs/Animations/animationGroup";
  34282. export * from "babylonjs/Animations/animationKey";
  34283. export * from "babylonjs/Animations/animationRange";
  34284. }
  34285. declare module "babylonjs/Audio/soundTrack" {
  34286. import { Sound } from "babylonjs/Audio/sound";
  34287. import { Analyser } from "babylonjs/Audio/analyser";
  34288. import { Scene } from "babylonjs/scene";
  34289. /**
  34290. * Options allowed during the creation of a sound track.
  34291. */
  34292. export interface ISoundTrackOptions {
  34293. /**
  34294. * The volume the sound track should take during creation
  34295. */
  34296. volume?: number;
  34297. /**
  34298. * Define if the sound track is the main sound track of the scene
  34299. */
  34300. mainTrack?: boolean;
  34301. }
  34302. /**
  34303. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34304. * It will be also used in a future release to apply effects on a specific track.
  34305. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34306. */
  34307. export class SoundTrack {
  34308. /**
  34309. * The unique identifier of the sound track in the scene.
  34310. */
  34311. id: number;
  34312. /**
  34313. * The list of sounds included in the sound track.
  34314. */
  34315. soundCollection: Array<Sound>;
  34316. private _outputAudioNode;
  34317. private _scene;
  34318. private _isMainTrack;
  34319. private _connectedAnalyser;
  34320. private _options;
  34321. private _isInitialized;
  34322. /**
  34323. * Creates a new sound track.
  34324. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34325. * @param scene Define the scene the sound track belongs to
  34326. * @param options
  34327. */
  34328. constructor(scene: Scene, options?: ISoundTrackOptions);
  34329. private _initializeSoundTrackAudioGraph;
  34330. /**
  34331. * Release the sound track and its associated resources
  34332. */
  34333. dispose(): void;
  34334. /**
  34335. * Adds a sound to this sound track
  34336. * @param sound define the cound to add
  34337. * @ignoreNaming
  34338. */
  34339. AddSound(sound: Sound): void;
  34340. /**
  34341. * Removes a sound to this sound track
  34342. * @param sound define the cound to remove
  34343. * @ignoreNaming
  34344. */
  34345. RemoveSound(sound: Sound): void;
  34346. /**
  34347. * Set a global volume for the full sound track.
  34348. * @param newVolume Define the new volume of the sound track
  34349. */
  34350. setVolume(newVolume: number): void;
  34351. /**
  34352. * Switch the panning model to HRTF:
  34353. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34354. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34355. */
  34356. switchPanningModelToHRTF(): void;
  34357. /**
  34358. * Switch the panning model to Equal Power:
  34359. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34360. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34361. */
  34362. switchPanningModelToEqualPower(): void;
  34363. /**
  34364. * Connect the sound track to an audio analyser allowing some amazing
  34365. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34366. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34367. * @param analyser The analyser to connect to the engine
  34368. */
  34369. connectToAnalyser(analyser: Analyser): void;
  34370. }
  34371. }
  34372. declare module "babylonjs/Audio/audioSceneComponent" {
  34373. import { Sound } from "babylonjs/Audio/sound";
  34374. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  34375. import { Nullable } from "babylonjs/types";
  34376. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  34377. import { Scene } from "babylonjs/scene";
  34378. import { AbstractScene } from "babylonjs/abstractScene";
  34379. module "babylonjs/abstractScene" {
  34380. interface AbstractScene {
  34381. /**
  34382. * The list of sounds used in the scene.
  34383. */
  34384. sounds: Nullable<Array<Sound>>;
  34385. }
  34386. }
  34387. module "babylonjs/scene" {
  34388. interface Scene {
  34389. /**
  34390. * @hidden
  34391. * Backing field
  34392. */
  34393. _mainSoundTrack: SoundTrack;
  34394. /**
  34395. * The main sound track played by the scene.
  34396. * It cotains your primary collection of sounds.
  34397. */
  34398. mainSoundTrack: SoundTrack;
  34399. /**
  34400. * The list of sound tracks added to the scene
  34401. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34402. */
  34403. soundTracks: Nullable<Array<SoundTrack>>;
  34404. /**
  34405. * Gets a sound using a given name
  34406. * @param name defines the name to search for
  34407. * @return the found sound or null if not found at all.
  34408. */
  34409. getSoundByName(name: string): Nullable<Sound>;
  34410. /**
  34411. * Gets or sets if audio support is enabled
  34412. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34413. */
  34414. audioEnabled: boolean;
  34415. /**
  34416. * Gets or sets if audio will be output to headphones
  34417. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34418. */
  34419. headphone: boolean;
  34420. }
  34421. }
  34422. /**
  34423. * Defines the sound scene component responsible to manage any sounds
  34424. * in a given scene.
  34425. */
  34426. export class AudioSceneComponent implements ISceneSerializableComponent {
  34427. /**
  34428. * The component name helpfull to identify the component in the list of scene components.
  34429. */
  34430. readonly name: string;
  34431. /**
  34432. * The scene the component belongs to.
  34433. */
  34434. scene: Scene;
  34435. private _audioEnabled;
  34436. /**
  34437. * Gets whether audio is enabled or not.
  34438. * Please use related enable/disable method to switch state.
  34439. */
  34440. readonly audioEnabled: boolean;
  34441. private _headphone;
  34442. /**
  34443. * Gets whether audio is outputing to headphone or not.
  34444. * Please use the according Switch methods to change output.
  34445. */
  34446. readonly headphone: boolean;
  34447. /**
  34448. * Creates a new instance of the component for the given scene
  34449. * @param scene Defines the scene to register the component in
  34450. */
  34451. constructor(scene: Scene);
  34452. /**
  34453. * Registers the component in a given scene
  34454. */
  34455. register(): void;
  34456. /**
  34457. * Rebuilds the elements related to this component in case of
  34458. * context lost for instance.
  34459. */
  34460. rebuild(): void;
  34461. /**
  34462. * Serializes the component data to the specified json object
  34463. * @param serializationObject The object to serialize to
  34464. */
  34465. serialize(serializationObject: any): void;
  34466. /**
  34467. * Adds all the element from the container to the scene
  34468. * @param container the container holding the elements
  34469. */
  34470. addFromContainer(container: AbstractScene): void;
  34471. /**
  34472. * Removes all the elements in the container from the scene
  34473. * @param container contains the elements to remove
  34474. */
  34475. removeFromContainer(container: AbstractScene): void;
  34476. /**
  34477. * Disposes the component and the associated ressources.
  34478. */
  34479. dispose(): void;
  34480. /**
  34481. * Disables audio in the associated scene.
  34482. */
  34483. disableAudio(): void;
  34484. /**
  34485. * Enables audio in the associated scene.
  34486. */
  34487. enableAudio(): void;
  34488. /**
  34489. * Switch audio to headphone output.
  34490. */
  34491. switchAudioModeForHeadphones(): void;
  34492. /**
  34493. * Switch audio to normal speakers.
  34494. */
  34495. switchAudioModeForNormalSpeakers(): void;
  34496. private _afterRender;
  34497. }
  34498. }
  34499. declare module "babylonjs/Audio/weightedsound" {
  34500. import { Sound } from "babylonjs/Audio/sound";
  34501. /**
  34502. * Wraps one or more Sound objects and selects one with random weight for playback.
  34503. */
  34504. export class WeightedSound {
  34505. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34506. loop: boolean;
  34507. private _coneInnerAngle;
  34508. private _coneOuterAngle;
  34509. private _volume;
  34510. /** A Sound is currently playing. */
  34511. isPlaying: boolean;
  34512. /** A Sound is currently paused. */
  34513. isPaused: boolean;
  34514. private _sounds;
  34515. private _weights;
  34516. private _currentIndex?;
  34517. /**
  34518. * Creates a new WeightedSound from the list of sounds given.
  34519. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34520. * @param sounds Array of Sounds that will be selected from.
  34521. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34522. */
  34523. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34524. /**
  34525. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34526. */
  34527. /**
  34528. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34529. */
  34530. directionalConeInnerAngle: number;
  34531. /**
  34532. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34533. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34534. */
  34535. /**
  34536. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34537. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34538. */
  34539. directionalConeOuterAngle: number;
  34540. /**
  34541. * Playback volume.
  34542. */
  34543. /**
  34544. * Playback volume.
  34545. */
  34546. volume: number;
  34547. private _onended;
  34548. /**
  34549. * Suspend playback
  34550. */
  34551. pause(): void;
  34552. /**
  34553. * Stop playback
  34554. */
  34555. stop(): void;
  34556. /**
  34557. * Start playback.
  34558. * @param startOffset Position the clip head at a specific time in seconds.
  34559. */
  34560. play(startOffset?: number): void;
  34561. }
  34562. }
  34563. declare module "babylonjs/Audio/index" {
  34564. export * from "babylonjs/Audio/analyser";
  34565. export * from "babylonjs/Audio/audioEngine";
  34566. export * from "babylonjs/Audio/audioSceneComponent";
  34567. export * from "babylonjs/Audio/sound";
  34568. export * from "babylonjs/Audio/soundTrack";
  34569. export * from "babylonjs/Audio/weightedsound";
  34570. }
  34571. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  34572. import { Behavior } from "babylonjs/Behaviors/behavior";
  34573. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34574. import { BackEase } from "babylonjs/Animations/easing";
  34575. /**
  34576. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34577. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34578. */
  34579. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34580. /**
  34581. * Gets the name of the behavior.
  34582. */
  34583. readonly name: string;
  34584. /**
  34585. * The easing function used by animations
  34586. */
  34587. static EasingFunction: BackEase;
  34588. /**
  34589. * The easing mode used by animations
  34590. */
  34591. static EasingMode: number;
  34592. /**
  34593. * The duration of the animation, in milliseconds
  34594. */
  34595. transitionDuration: number;
  34596. /**
  34597. * Length of the distance animated by the transition when lower radius is reached
  34598. */
  34599. lowerRadiusTransitionRange: number;
  34600. /**
  34601. * Length of the distance animated by the transition when upper radius is reached
  34602. */
  34603. upperRadiusTransitionRange: number;
  34604. private _autoTransitionRange;
  34605. /**
  34606. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34607. */
  34608. /**
  34609. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34610. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34611. */
  34612. autoTransitionRange: boolean;
  34613. private _attachedCamera;
  34614. private _onAfterCheckInputsObserver;
  34615. private _onMeshTargetChangedObserver;
  34616. /**
  34617. * Initializes the behavior.
  34618. */
  34619. init(): void;
  34620. /**
  34621. * Attaches the behavior to its arc rotate camera.
  34622. * @param camera Defines the camera to attach the behavior to
  34623. */
  34624. attach(camera: ArcRotateCamera): void;
  34625. /**
  34626. * Detaches the behavior from its current arc rotate camera.
  34627. */
  34628. detach(): void;
  34629. private _radiusIsAnimating;
  34630. private _radiusBounceTransition;
  34631. private _animatables;
  34632. private _cachedWheelPrecision;
  34633. /**
  34634. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34635. * @param radiusLimit The limit to check against.
  34636. * @return Bool to indicate if at limit.
  34637. */
  34638. private _isRadiusAtLimit;
  34639. /**
  34640. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34641. * @param radiusDelta The delta by which to animate to. Can be negative.
  34642. */
  34643. private _applyBoundRadiusAnimation;
  34644. /**
  34645. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34646. */
  34647. protected _clearAnimationLocks(): void;
  34648. /**
  34649. * Stops and removes all animations that have been applied to the camera
  34650. */
  34651. stopAllAnimations(): void;
  34652. }
  34653. }
  34654. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  34655. import { Behavior } from "babylonjs/Behaviors/behavior";
  34656. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34657. import { ExponentialEase } from "babylonjs/Animations/easing";
  34658. import { Nullable } from "babylonjs/types";
  34659. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34660. import { Vector3 } from "babylonjs/Maths/math";
  34661. /**
  34662. * 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.
  34663. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34664. */
  34665. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34666. /**
  34667. * Gets the name of the behavior.
  34668. */
  34669. readonly name: string;
  34670. private _mode;
  34671. private _radiusScale;
  34672. private _positionScale;
  34673. private _defaultElevation;
  34674. private _elevationReturnTime;
  34675. private _elevationReturnWaitTime;
  34676. private _zoomStopsAnimation;
  34677. private _framingTime;
  34678. /**
  34679. * The easing function used by animations
  34680. */
  34681. static EasingFunction: ExponentialEase;
  34682. /**
  34683. * The easing mode used by animations
  34684. */
  34685. static EasingMode: number;
  34686. /**
  34687. * Sets the current mode used by the behavior
  34688. */
  34689. /**
  34690. * Gets current mode used by the behavior.
  34691. */
  34692. mode: number;
  34693. /**
  34694. * Sets the scale applied to the radius (1 by default)
  34695. */
  34696. /**
  34697. * Gets the scale applied to the radius
  34698. */
  34699. radiusScale: number;
  34700. /**
  34701. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34702. */
  34703. /**
  34704. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34705. */
  34706. positionScale: number;
  34707. /**
  34708. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34709. * behaviour is triggered, in radians.
  34710. */
  34711. /**
  34712. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34713. * behaviour is triggered, in radians.
  34714. */
  34715. defaultElevation: number;
  34716. /**
  34717. * Sets the time (in milliseconds) taken to return to the default beta position.
  34718. * Negative value indicates camera should not return to default.
  34719. */
  34720. /**
  34721. * Gets the time (in milliseconds) taken to return to the default beta position.
  34722. * Negative value indicates camera should not return to default.
  34723. */
  34724. elevationReturnTime: number;
  34725. /**
  34726. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34727. */
  34728. /**
  34729. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34730. */
  34731. elevationReturnWaitTime: number;
  34732. /**
  34733. * Sets the flag that indicates if user zooming should stop animation.
  34734. */
  34735. /**
  34736. * Gets the flag that indicates if user zooming should stop animation.
  34737. */
  34738. zoomStopsAnimation: boolean;
  34739. /**
  34740. * Sets the transition time when framing the mesh, in milliseconds
  34741. */
  34742. /**
  34743. * Gets the transition time when framing the mesh, in milliseconds
  34744. */
  34745. framingTime: number;
  34746. /**
  34747. * Define if the behavior should automatically change the configured
  34748. * camera limits and sensibilities.
  34749. */
  34750. autoCorrectCameraLimitsAndSensibility: boolean;
  34751. private _onPrePointerObservableObserver;
  34752. private _onAfterCheckInputsObserver;
  34753. private _onMeshTargetChangedObserver;
  34754. private _attachedCamera;
  34755. private _isPointerDown;
  34756. private _lastInteractionTime;
  34757. /**
  34758. * Initializes the behavior.
  34759. */
  34760. init(): void;
  34761. /**
  34762. * Attaches the behavior to its arc rotate camera.
  34763. * @param camera Defines the camera to attach the behavior to
  34764. */
  34765. attach(camera: ArcRotateCamera): void;
  34766. /**
  34767. * Detaches the behavior from its current arc rotate camera.
  34768. */
  34769. detach(): void;
  34770. private _animatables;
  34771. private _betaIsAnimating;
  34772. private _betaTransition;
  34773. private _radiusTransition;
  34774. private _vectorTransition;
  34775. /**
  34776. * Targets the given mesh and updates zoom level accordingly.
  34777. * @param mesh The mesh to target.
  34778. * @param radius Optional. If a cached radius position already exists, overrides default.
  34779. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34780. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34781. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34782. */
  34783. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34784. /**
  34785. * Targets the given mesh with its children and updates zoom level accordingly.
  34786. * @param mesh The mesh to target.
  34787. * @param radius Optional. If a cached radius position already exists, overrides default.
  34788. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34789. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34790. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34791. */
  34792. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34793. /**
  34794. * Targets the given meshes with their children and updates zoom level accordingly.
  34795. * @param meshes The mesh to target.
  34796. * @param radius Optional. If a cached radius position already exists, overrides default.
  34797. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34798. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34799. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34800. */
  34801. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34802. /**
  34803. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34804. * @param minimumWorld Determines the smaller position of the bounding box extend
  34805. * @param maximumWorld Determines the bigger position of the bounding box extend
  34806. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34807. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34808. */
  34809. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34810. /**
  34811. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34812. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34813. * frustum width.
  34814. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34815. * to fully enclose the mesh in the viewing frustum.
  34816. */
  34817. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34818. /**
  34819. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34820. * is automatically returned to its default position (expected to be above ground plane).
  34821. */
  34822. private _maintainCameraAboveGround;
  34823. /**
  34824. * Returns the frustum slope based on the canvas ratio and camera FOV
  34825. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34826. */
  34827. private _getFrustumSlope;
  34828. /**
  34829. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34830. */
  34831. private _clearAnimationLocks;
  34832. /**
  34833. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34834. */
  34835. private _applyUserInteraction;
  34836. /**
  34837. * Stops and removes all animations that have been applied to the camera
  34838. */
  34839. stopAllAnimations(): void;
  34840. /**
  34841. * Gets a value indicating if the user is moving the camera
  34842. */
  34843. readonly isUserIsMoving: boolean;
  34844. /**
  34845. * The camera can move all the way towards the mesh.
  34846. */
  34847. static IgnoreBoundsSizeMode: number;
  34848. /**
  34849. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34850. */
  34851. static FitFrustumSidesMode: number;
  34852. }
  34853. }
  34854. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  34855. import { Nullable } from "babylonjs/types";
  34856. import { Camera } from "babylonjs/Cameras/camera";
  34857. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34858. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  34859. /**
  34860. * Base class for Camera Pointer Inputs.
  34861. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  34862. * for example usage.
  34863. */
  34864. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  34865. /**
  34866. * Defines the camera the input is attached to.
  34867. */
  34868. abstract camera: Camera;
  34869. /**
  34870. * Whether keyboard modifier keys are pressed at time of last mouse event.
  34871. */
  34872. protected _altKey: boolean;
  34873. protected _ctrlKey: boolean;
  34874. protected _metaKey: boolean;
  34875. protected _shiftKey: boolean;
  34876. /**
  34877. * Which mouse buttons were pressed at time of last mouse event.
  34878. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  34879. */
  34880. protected _buttonsPressed: number;
  34881. /**
  34882. * Defines the buttons associated with the input to handle camera move.
  34883. */
  34884. buttons: number[];
  34885. /**
  34886. * Attach the input controls to a specific dom element to get the input from.
  34887. * @param element Defines the element the controls should be listened from
  34888. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34889. */
  34890. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34891. /**
  34892. * Detach the current controls from the specified dom element.
  34893. * @param element Defines the element to stop listening the inputs from
  34894. */
  34895. detachControl(element: Nullable<HTMLElement>): void;
  34896. /**
  34897. * Gets the class name of the current input.
  34898. * @returns the class name
  34899. */
  34900. getClassName(): string;
  34901. /**
  34902. * Get the friendly name associated with the input class.
  34903. * @returns the input friendly name
  34904. */
  34905. getSimpleName(): string;
  34906. /**
  34907. * Called on pointer POINTERDOUBLETAP event.
  34908. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34909. */
  34910. protected onDoubleTap(type: string): void;
  34911. /**
  34912. * Called on pointer POINTERMOVE event if only a single touch is active.
  34913. * Override this method to provide functionality.
  34914. */
  34915. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34916. /**
  34917. * Called on pointer POINTERMOVE event if multiple touches are active.
  34918. * Override this method to provide functionality.
  34919. */
  34920. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34921. /**
  34922. * Called on JS contextmenu event.
  34923. * Override this method to provide functionality.
  34924. */
  34925. protected onContextMenu(evt: PointerEvent): void;
  34926. /**
  34927. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34928. * press.
  34929. * Override this method to provide functionality.
  34930. */
  34931. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  34932. /**
  34933. * Called each time a new POINTERUP event occurs. Ie, for each button
  34934. * release.
  34935. * Override this method to provide functionality.
  34936. */
  34937. protected onButtonUp(evt: PointerEvent): void;
  34938. /**
  34939. * Called when window becomes inactive.
  34940. * Override this method to provide functionality.
  34941. */
  34942. protected onLostFocus(): void;
  34943. private _pointerInput;
  34944. private _observer;
  34945. private _onLostFocus;
  34946. }
  34947. }
  34948. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  34949. import { Nullable } from "babylonjs/types";
  34950. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34951. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  34952. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  34953. /**
  34954. * Manage the pointers inputs to control an arc rotate camera.
  34955. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34956. */
  34957. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34958. /**
  34959. * Defines the camera the input is attached to.
  34960. */
  34961. camera: ArcRotateCamera;
  34962. /**
  34963. * Gets the class name of the current input.
  34964. * @returns the class name
  34965. */
  34966. getClassName(): string;
  34967. /**
  34968. * Defines the buttons associated with the input to handle camera move.
  34969. */
  34970. buttons: number[];
  34971. /**
  34972. * Defines the pointer angular sensibility along the X axis or how fast is
  34973. * the camera rotating.
  34974. */
  34975. angularSensibilityX: number;
  34976. /**
  34977. * Defines the pointer angular sensibility along the Y axis or how fast is
  34978. * the camera rotating.
  34979. */
  34980. angularSensibilityY: number;
  34981. /**
  34982. * Defines the pointer pinch precision or how fast is the camera zooming.
  34983. */
  34984. pinchPrecision: number;
  34985. /**
  34986. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34987. * from 0.
  34988. * It defines the percentage of current camera.radius to use as delta when
  34989. * pinch zoom is used.
  34990. */
  34991. pinchDeltaPercentage: number;
  34992. /**
  34993. * Defines the pointer panning sensibility or how fast is the camera moving.
  34994. */
  34995. panningSensibility: number;
  34996. /**
  34997. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34998. */
  34999. multiTouchPanning: boolean;
  35000. /**
  35001. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35002. * zoom (pinch) through multitouch.
  35003. */
  35004. multiTouchPanAndZoom: boolean;
  35005. /**
  35006. * Revers pinch action direction.
  35007. */
  35008. pinchInwards: boolean;
  35009. private _isPanClick;
  35010. private _twoFingerActivityCount;
  35011. private _isPinching;
  35012. /**
  35013. * Called on pointer POINTERMOVE event if only a single touch is active.
  35014. */
  35015. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35016. /**
  35017. * Called on pointer POINTERDOUBLETAP event.
  35018. */
  35019. protected onDoubleTap(type: string): void;
  35020. /**
  35021. * Called on pointer POINTERMOVE event if multiple touches are active.
  35022. */
  35023. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35024. /**
  35025. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35026. * press.
  35027. */
  35028. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  35029. /**
  35030. * Called each time a new POINTERUP event occurs. Ie, for each button
  35031. * release.
  35032. */
  35033. protected onButtonUp(evt: PointerEvent): void;
  35034. /**
  35035. * Called when window becomes inactive.
  35036. */
  35037. protected onLostFocus(): void;
  35038. }
  35039. }
  35040. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  35041. import { Nullable } from "babylonjs/types";
  35042. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35043. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35044. /**
  35045. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35046. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35047. */
  35048. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35049. /**
  35050. * Defines the camera the input is attached to.
  35051. */
  35052. camera: ArcRotateCamera;
  35053. /**
  35054. * Defines the list of key codes associated with the up action (increase alpha)
  35055. */
  35056. keysUp: number[];
  35057. /**
  35058. * Defines the list of key codes associated with the down action (decrease alpha)
  35059. */
  35060. keysDown: number[];
  35061. /**
  35062. * Defines the list of key codes associated with the left action (increase beta)
  35063. */
  35064. keysLeft: number[];
  35065. /**
  35066. * Defines the list of key codes associated with the right action (decrease beta)
  35067. */
  35068. keysRight: number[];
  35069. /**
  35070. * Defines the list of key codes associated with the reset action.
  35071. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35072. */
  35073. keysReset: number[];
  35074. /**
  35075. * Defines the panning sensibility of the inputs.
  35076. * (How fast is the camera paning)
  35077. */
  35078. panningSensibility: number;
  35079. /**
  35080. * Defines the zooming sensibility of the inputs.
  35081. * (How fast is the camera zooming)
  35082. */
  35083. zoomingSensibility: number;
  35084. /**
  35085. * Defines wether maintaining the alt key down switch the movement mode from
  35086. * orientation to zoom.
  35087. */
  35088. useAltToZoom: boolean;
  35089. /**
  35090. * Rotation speed of the camera
  35091. */
  35092. angularSpeed: number;
  35093. private _keys;
  35094. private _ctrlPressed;
  35095. private _altPressed;
  35096. private _onCanvasBlurObserver;
  35097. private _onKeyboardObserver;
  35098. private _engine;
  35099. private _scene;
  35100. /**
  35101. * Attach the input controls to a specific dom element to get the input from.
  35102. * @param element Defines the element the controls should be listened from
  35103. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35104. */
  35105. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35106. /**
  35107. * Detach the current controls from the specified dom element.
  35108. * @param element Defines the element to stop listening the inputs from
  35109. */
  35110. detachControl(element: Nullable<HTMLElement>): void;
  35111. /**
  35112. * Update the current camera state depending on the inputs that have been used this frame.
  35113. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35114. */
  35115. checkInputs(): void;
  35116. /**
  35117. * Gets the class name of the current intput.
  35118. * @returns the class name
  35119. */
  35120. getClassName(): string;
  35121. /**
  35122. * Get the friendly name associated with the input class.
  35123. * @returns the input friendly name
  35124. */
  35125. getSimpleName(): string;
  35126. }
  35127. }
  35128. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  35129. import { Nullable } from "babylonjs/types";
  35130. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35131. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35132. /**
  35133. * Manage the mouse wheel inputs to control an arc rotate camera.
  35134. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35135. */
  35136. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35137. /**
  35138. * Defines the camera the input is attached to.
  35139. */
  35140. camera: ArcRotateCamera;
  35141. /**
  35142. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35143. */
  35144. wheelPrecision: number;
  35145. /**
  35146. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35147. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35148. */
  35149. wheelDeltaPercentage: number;
  35150. private _wheel;
  35151. private _observer;
  35152. /**
  35153. * Attach the input controls to a specific dom element to get the input from.
  35154. * @param element Defines the element the controls should be listened from
  35155. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35156. */
  35157. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35158. /**
  35159. * Detach the current controls from the specified dom element.
  35160. * @param element Defines the element to stop listening the inputs from
  35161. */
  35162. detachControl(element: Nullable<HTMLElement>): void;
  35163. /**
  35164. * Gets the class name of the current intput.
  35165. * @returns the class name
  35166. */
  35167. getClassName(): string;
  35168. /**
  35169. * Get the friendly name associated with the input class.
  35170. * @returns the input friendly name
  35171. */
  35172. getSimpleName(): string;
  35173. }
  35174. }
  35175. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  35176. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35177. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  35178. /**
  35179. * Default Inputs manager for the ArcRotateCamera.
  35180. * It groups all the default supported inputs for ease of use.
  35181. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35182. */
  35183. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35184. /**
  35185. * Instantiates a new ArcRotateCameraInputsManager.
  35186. * @param camera Defines the camera the inputs belong to
  35187. */
  35188. constructor(camera: ArcRotateCamera);
  35189. /**
  35190. * Add mouse wheel input support to the input manager.
  35191. * @returns the current input manager
  35192. */
  35193. addMouseWheel(): ArcRotateCameraInputsManager;
  35194. /**
  35195. * Add pointers input support to the input manager.
  35196. * @returns the current input manager
  35197. */
  35198. addPointers(): ArcRotateCameraInputsManager;
  35199. /**
  35200. * Add keyboard input support to the input manager.
  35201. * @returns the current input manager
  35202. */
  35203. addKeyboard(): ArcRotateCameraInputsManager;
  35204. }
  35205. }
  35206. declare module "babylonjs/Cameras/arcRotateCamera" {
  35207. import { Observable } from "babylonjs/Misc/observable";
  35208. import { Nullable } from "babylonjs/types";
  35209. import { Scene } from "babylonjs/scene";
  35210. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  35211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35212. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35213. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35214. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  35215. import { Camera } from "babylonjs/Cameras/camera";
  35216. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  35217. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  35218. import { Collider } from "babylonjs/Collisions/collider";
  35219. /**
  35220. * This represents an orbital type of camera.
  35221. *
  35222. * 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.
  35223. * 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.
  35224. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35225. */
  35226. export class ArcRotateCamera extends TargetCamera {
  35227. /**
  35228. * Defines the rotation angle of the camera along the longitudinal axis.
  35229. */
  35230. alpha: number;
  35231. /**
  35232. * Defines the rotation angle of the camera along the latitudinal axis.
  35233. */
  35234. beta: number;
  35235. /**
  35236. * Defines the radius of the camera from it s target point.
  35237. */
  35238. radius: number;
  35239. protected _target: Vector3;
  35240. protected _targetHost: Nullable<AbstractMesh>;
  35241. /**
  35242. * Defines the target point of the camera.
  35243. * The camera looks towards it form the radius distance.
  35244. */
  35245. target: Vector3;
  35246. /**
  35247. * Define the current local position of the camera in the scene
  35248. */
  35249. position: Vector3;
  35250. /**
  35251. * Current inertia value on the longitudinal axis.
  35252. * The bigger this number the longer it will take for the camera to stop.
  35253. */
  35254. inertialAlphaOffset: number;
  35255. /**
  35256. * Current inertia value on the latitudinal axis.
  35257. * The bigger this number the longer it will take for the camera to stop.
  35258. */
  35259. inertialBetaOffset: number;
  35260. /**
  35261. * Current inertia value on the radius axis.
  35262. * The bigger this number the longer it will take for the camera to stop.
  35263. */
  35264. inertialRadiusOffset: number;
  35265. /**
  35266. * Minimum allowed angle on the longitudinal axis.
  35267. * This can help limiting how the Camera is able to move in the scene.
  35268. */
  35269. lowerAlphaLimit: Nullable<number>;
  35270. /**
  35271. * Maximum allowed angle on the longitudinal axis.
  35272. * This can help limiting how the Camera is able to move in the scene.
  35273. */
  35274. upperAlphaLimit: Nullable<number>;
  35275. /**
  35276. * Minimum allowed angle on the latitudinal axis.
  35277. * This can help limiting how the Camera is able to move in the scene.
  35278. */
  35279. lowerBetaLimit: number;
  35280. /**
  35281. * Maximum allowed angle on the latitudinal axis.
  35282. * This can help limiting how the Camera is able to move in the scene.
  35283. */
  35284. upperBetaLimit: number;
  35285. /**
  35286. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35287. * This can help limiting how the Camera is able to move in the scene.
  35288. */
  35289. lowerRadiusLimit: Nullable<number>;
  35290. /**
  35291. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35292. * This can help limiting how the Camera is able to move in the scene.
  35293. */
  35294. upperRadiusLimit: Nullable<number>;
  35295. /**
  35296. * Defines the current inertia value used during panning of the camera along the X axis.
  35297. */
  35298. inertialPanningX: number;
  35299. /**
  35300. * Defines the current inertia value used during panning of the camera along the Y axis.
  35301. */
  35302. inertialPanningY: number;
  35303. /**
  35304. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35305. * Basically if your fingers moves away from more than this distance you will be considered
  35306. * in pinch mode.
  35307. */
  35308. pinchToPanMaxDistance: number;
  35309. /**
  35310. * Defines the maximum distance the camera can pan.
  35311. * This could help keeping the cammera always in your scene.
  35312. */
  35313. panningDistanceLimit: Nullable<number>;
  35314. /**
  35315. * Defines the target of the camera before paning.
  35316. */
  35317. panningOriginTarget: Vector3;
  35318. /**
  35319. * Defines the value of the inertia used during panning.
  35320. * 0 would mean stop inertia and one would mean no decelleration at all.
  35321. */
  35322. panningInertia: number;
  35323. /**
  35324. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35325. */
  35326. angularSensibilityX: number;
  35327. /**
  35328. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35329. */
  35330. angularSensibilityY: number;
  35331. /**
  35332. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35333. */
  35334. pinchPrecision: number;
  35335. /**
  35336. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35337. * It will be used instead of pinchDeltaPrecision if different from 0.
  35338. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35339. */
  35340. pinchDeltaPercentage: number;
  35341. /**
  35342. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35343. */
  35344. panningSensibility: number;
  35345. /**
  35346. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35347. */
  35348. keysUp: number[];
  35349. /**
  35350. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35351. */
  35352. keysDown: number[];
  35353. /**
  35354. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35355. */
  35356. keysLeft: number[];
  35357. /**
  35358. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35359. */
  35360. keysRight: number[];
  35361. /**
  35362. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35363. */
  35364. wheelPrecision: number;
  35365. /**
  35366. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35367. * It will be used instead of pinchDeltaPrecision if different from 0.
  35368. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35369. */
  35370. wheelDeltaPercentage: number;
  35371. /**
  35372. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35373. */
  35374. zoomOnFactor: number;
  35375. /**
  35376. * Defines a screen offset for the camera position.
  35377. */
  35378. targetScreenOffset: Vector2;
  35379. /**
  35380. * Allows the camera to be completely reversed.
  35381. * If false the camera can not arrive upside down.
  35382. */
  35383. allowUpsideDown: boolean;
  35384. /**
  35385. * Define if double tap/click is used to restore the previously saved state of the camera.
  35386. */
  35387. useInputToRestoreState: boolean;
  35388. /** @hidden */
  35389. _viewMatrix: Matrix;
  35390. /** @hidden */
  35391. _useCtrlForPanning: boolean;
  35392. /** @hidden */
  35393. _panningMouseButton: number;
  35394. /**
  35395. * Defines the input associated to the camera.
  35396. */
  35397. inputs: ArcRotateCameraInputsManager;
  35398. /** @hidden */
  35399. _reset: () => void;
  35400. /**
  35401. * Defines the allowed panning axis.
  35402. */
  35403. panningAxis: Vector3;
  35404. protected _localDirection: Vector3;
  35405. protected _transformedDirection: Vector3;
  35406. private _bouncingBehavior;
  35407. /**
  35408. * Gets the bouncing behavior of the camera if it has been enabled.
  35409. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35410. */
  35411. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35412. /**
  35413. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35414. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35415. */
  35416. useBouncingBehavior: boolean;
  35417. private _framingBehavior;
  35418. /**
  35419. * Gets the framing behavior of the camera if it has been enabled.
  35420. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35421. */
  35422. readonly framingBehavior: Nullable<FramingBehavior>;
  35423. /**
  35424. * Defines if the framing behavior of the camera is enabled on the camera.
  35425. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35426. */
  35427. useFramingBehavior: boolean;
  35428. private _autoRotationBehavior;
  35429. /**
  35430. * Gets the auto rotation behavior of the camera if it has been enabled.
  35431. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35432. */
  35433. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35434. /**
  35435. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35436. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35437. */
  35438. useAutoRotationBehavior: boolean;
  35439. /**
  35440. * Observable triggered when the mesh target has been changed on the camera.
  35441. */
  35442. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35443. /**
  35444. * Event raised when the camera is colliding with a mesh.
  35445. */
  35446. onCollide: (collidedMesh: AbstractMesh) => void;
  35447. /**
  35448. * Defines whether the camera should check collision with the objects oh the scene.
  35449. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35450. */
  35451. checkCollisions: boolean;
  35452. /**
  35453. * Defines the collision radius of the camera.
  35454. * This simulates a sphere around the camera.
  35455. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35456. */
  35457. collisionRadius: Vector3;
  35458. protected _collider: Collider;
  35459. protected _previousPosition: Vector3;
  35460. protected _collisionVelocity: Vector3;
  35461. protected _newPosition: Vector3;
  35462. protected _previousAlpha: number;
  35463. protected _previousBeta: number;
  35464. protected _previousRadius: number;
  35465. protected _collisionTriggered: boolean;
  35466. protected _targetBoundingCenter: Nullable<Vector3>;
  35467. private _computationVector;
  35468. private _tempAxisVector;
  35469. private _tempAxisRotationMatrix;
  35470. /**
  35471. * Instantiates a new ArcRotateCamera in a given scene
  35472. * @param name Defines the name of the camera
  35473. * @param alpha Defines the camera rotation along the logitudinal axis
  35474. * @param beta Defines the camera rotation along the latitudinal axis
  35475. * @param radius Defines the camera distance from its target
  35476. * @param target Defines the camera target
  35477. * @param scene Defines the scene the camera belongs to
  35478. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35479. */
  35480. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35481. /** @hidden */
  35482. _initCache(): void;
  35483. /** @hidden */
  35484. _updateCache(ignoreParentClass?: boolean): void;
  35485. protected _getTargetPosition(): Vector3;
  35486. private _storedAlpha;
  35487. private _storedBeta;
  35488. private _storedRadius;
  35489. private _storedTarget;
  35490. /**
  35491. * Stores the current state of the camera (alpha, beta, radius and target)
  35492. * @returns the camera itself
  35493. */
  35494. storeState(): Camera;
  35495. /**
  35496. * @hidden
  35497. * Restored camera state. You must call storeState() first
  35498. */
  35499. _restoreStateValues(): boolean;
  35500. /** @hidden */
  35501. _isSynchronizedViewMatrix(): boolean;
  35502. /**
  35503. * Attached controls to the current camera.
  35504. * @param element Defines the element the controls should be listened from
  35505. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35506. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35507. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35508. */
  35509. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35510. /**
  35511. * Detach the current controls from the camera.
  35512. * The camera will stop reacting to inputs.
  35513. * @param element Defines the element to stop listening the inputs from
  35514. */
  35515. detachControl(element: HTMLElement): void;
  35516. /** @hidden */
  35517. _checkInputs(): void;
  35518. protected _checkLimits(): void;
  35519. /**
  35520. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35521. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  35522. */
  35523. rebuildAnglesAndRadius(updateView?: boolean): void;
  35524. /**
  35525. * Use a position to define the current camera related information like aplha, beta and radius
  35526. * @param position Defines the position to set the camera at
  35527. */
  35528. setPosition(position: Vector3): void;
  35529. /**
  35530. * Defines the target the camera should look at.
  35531. * This will automatically adapt alpha beta and radius to fit within the new target.
  35532. * @param target Defines the new target as a Vector or a mesh
  35533. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35534. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35535. */
  35536. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35537. /** @hidden */
  35538. _getViewMatrix(): Matrix;
  35539. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35540. /**
  35541. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35542. * @param meshes Defines the mesh to zoom on
  35543. * @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)
  35544. */
  35545. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35546. /**
  35547. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35548. * The target will be changed but the radius
  35549. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35550. * @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)
  35551. */
  35552. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35553. min: Vector3;
  35554. max: Vector3;
  35555. distance: number;
  35556. }, doNotUpdateMaxZ?: boolean): void;
  35557. /**
  35558. * @override
  35559. * Override Camera.createRigCamera
  35560. */
  35561. createRigCamera(name: string, cameraIndex: number): Camera;
  35562. /**
  35563. * @hidden
  35564. * @override
  35565. * Override Camera._updateRigCameras
  35566. */
  35567. _updateRigCameras(): void;
  35568. /**
  35569. * Destroy the camera and release the current resources hold by it.
  35570. */
  35571. dispose(): void;
  35572. /**
  35573. * Gets the current object class name.
  35574. * @return the class name
  35575. */
  35576. getClassName(): string;
  35577. }
  35578. }
  35579. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  35580. import { Behavior } from "babylonjs/Behaviors/behavior";
  35581. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35582. /**
  35583. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35584. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35585. */
  35586. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35587. /**
  35588. * Gets the name of the behavior.
  35589. */
  35590. readonly name: string;
  35591. private _zoomStopsAnimation;
  35592. private _idleRotationSpeed;
  35593. private _idleRotationWaitTime;
  35594. private _idleRotationSpinupTime;
  35595. /**
  35596. * Sets the flag that indicates if user zooming should stop animation.
  35597. */
  35598. /**
  35599. * Gets the flag that indicates if user zooming should stop animation.
  35600. */
  35601. zoomStopsAnimation: boolean;
  35602. /**
  35603. * Sets the default speed at which the camera rotates around the model.
  35604. */
  35605. /**
  35606. * Gets the default speed at which the camera rotates around the model.
  35607. */
  35608. idleRotationSpeed: number;
  35609. /**
  35610. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35611. */
  35612. /**
  35613. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35614. */
  35615. idleRotationWaitTime: number;
  35616. /**
  35617. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35618. */
  35619. /**
  35620. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35621. */
  35622. idleRotationSpinupTime: number;
  35623. /**
  35624. * Gets a value indicating if the camera is currently rotating because of this behavior
  35625. */
  35626. readonly rotationInProgress: boolean;
  35627. private _onPrePointerObservableObserver;
  35628. private _onAfterCheckInputsObserver;
  35629. private _attachedCamera;
  35630. private _isPointerDown;
  35631. private _lastFrameTime;
  35632. private _lastInteractionTime;
  35633. private _cameraRotationSpeed;
  35634. /**
  35635. * Initializes the behavior.
  35636. */
  35637. init(): void;
  35638. /**
  35639. * Attaches the behavior to its arc rotate camera.
  35640. * @param camera Defines the camera to attach the behavior to
  35641. */
  35642. attach(camera: ArcRotateCamera): void;
  35643. /**
  35644. * Detaches the behavior from its current arc rotate camera.
  35645. */
  35646. detach(): void;
  35647. /**
  35648. * Returns true if user is scrolling.
  35649. * @return true if user is scrolling.
  35650. */
  35651. private _userIsZooming;
  35652. private _lastFrameRadius;
  35653. private _shouldAnimationStopForInteraction;
  35654. /**
  35655. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35656. */
  35657. private _applyUserInteraction;
  35658. private _userIsMoving;
  35659. }
  35660. }
  35661. declare module "babylonjs/Behaviors/Cameras/index" {
  35662. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35663. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35664. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  35665. }
  35666. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  35667. import { Mesh } from "babylonjs/Meshes/mesh";
  35668. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35669. import { Behavior } from "babylonjs/Behaviors/behavior";
  35670. /**
  35671. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35672. */
  35673. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35674. private ui;
  35675. /**
  35676. * The name of the behavior
  35677. */
  35678. name: string;
  35679. /**
  35680. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35681. */
  35682. distanceAwayFromFace: number;
  35683. /**
  35684. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35685. */
  35686. distanceAwayFromBottomOfFace: number;
  35687. private _faceVectors;
  35688. private _target;
  35689. private _scene;
  35690. private _onRenderObserver;
  35691. private _tmpMatrix;
  35692. private _tmpVector;
  35693. /**
  35694. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35695. * @param ui The transform node that should be attched to the mesh
  35696. */
  35697. constructor(ui: TransformNode);
  35698. /**
  35699. * Initializes the behavior
  35700. */
  35701. init(): void;
  35702. private _closestFace;
  35703. private _zeroVector;
  35704. private _lookAtTmpMatrix;
  35705. private _lookAtToRef;
  35706. /**
  35707. * Attaches the AttachToBoxBehavior to the passed in mesh
  35708. * @param target The mesh that the specified node will be attached to
  35709. */
  35710. attach(target: Mesh): void;
  35711. /**
  35712. * Detaches the behavior from the mesh
  35713. */
  35714. detach(): void;
  35715. }
  35716. }
  35717. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  35718. import { Behavior } from "babylonjs/Behaviors/behavior";
  35719. import { Mesh } from "babylonjs/Meshes/mesh";
  35720. /**
  35721. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35722. */
  35723. export class FadeInOutBehavior implements Behavior<Mesh> {
  35724. /**
  35725. * Time in milliseconds to delay before fading in (Default: 0)
  35726. */
  35727. delay: number;
  35728. /**
  35729. * Time in milliseconds for the mesh to fade in (Default: 300)
  35730. */
  35731. fadeInTime: number;
  35732. private _millisecondsPerFrame;
  35733. private _hovered;
  35734. private _hoverValue;
  35735. private _ownerNode;
  35736. /**
  35737. * Instatiates the FadeInOutBehavior
  35738. */
  35739. constructor();
  35740. /**
  35741. * The name of the behavior
  35742. */
  35743. readonly name: string;
  35744. /**
  35745. * Initializes the behavior
  35746. */
  35747. init(): void;
  35748. /**
  35749. * Attaches the fade behavior on the passed in mesh
  35750. * @param ownerNode The mesh that will be faded in/out once attached
  35751. */
  35752. attach(ownerNode: Mesh): void;
  35753. /**
  35754. * Detaches the behavior from the mesh
  35755. */
  35756. detach(): void;
  35757. /**
  35758. * Triggers the mesh to begin fading in or out
  35759. * @param value if the object should fade in or out (true to fade in)
  35760. */
  35761. fadeIn(value: boolean): void;
  35762. private _update;
  35763. private _setAllVisibility;
  35764. }
  35765. }
  35766. declare module "babylonjs/Misc/pivotTools" {
  35767. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35768. /**
  35769. * Class containing a set of static utilities functions for managing Pivots
  35770. * @hidden
  35771. */
  35772. export class PivotTools {
  35773. private static _PivotCached;
  35774. private static _OldPivotPoint;
  35775. private static _PivotTranslation;
  35776. private static _PivotTmpVector;
  35777. /** @hidden */
  35778. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35779. /** @hidden */
  35780. static _RestorePivotPoint(mesh: AbstractMesh): void;
  35781. }
  35782. }
  35783. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  35784. import { Scene } from "babylonjs/scene";
  35785. import { Vector4, Plane } from "babylonjs/Maths/math";
  35786. import { Mesh } from "babylonjs/Meshes/mesh";
  35787. /**
  35788. * Class containing static functions to help procedurally build meshes
  35789. */
  35790. export class PlaneBuilder {
  35791. /**
  35792. * Creates a plane mesh
  35793. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35794. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35795. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35796. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35797. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35798. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35799. * @param name defines the name of the mesh
  35800. * @param options defines the options used to create the mesh
  35801. * @param scene defines the hosting scene
  35802. * @returns the plane mesh
  35803. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35804. */
  35805. static CreatePlane(name: string, options: {
  35806. size?: number;
  35807. width?: number;
  35808. height?: number;
  35809. sideOrientation?: number;
  35810. frontUVs?: Vector4;
  35811. backUVs?: Vector4;
  35812. updatable?: boolean;
  35813. sourcePlane?: Plane;
  35814. }, scene: Scene): Mesh;
  35815. }
  35816. }
  35817. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  35818. import { Behavior } from "babylonjs/Behaviors/behavior";
  35819. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35820. import { Observable } from "babylonjs/Misc/observable";
  35821. import { Vector3 } from "babylonjs/Maths/math";
  35822. import { Ray } from "babylonjs/Culling/ray";
  35823. import "babylonjs/Meshes/Builders/planeBuilder";
  35824. /**
  35825. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35826. */
  35827. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35828. private static _AnyMouseID;
  35829. private _attachedNode;
  35830. private _dragPlane;
  35831. private _scene;
  35832. private _pointerObserver;
  35833. private _beforeRenderObserver;
  35834. private static _planeScene;
  35835. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35836. /**
  35837. * 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)
  35838. */
  35839. maxDragAngle: number;
  35840. /**
  35841. * @hidden
  35842. */
  35843. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35844. /**
  35845. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35846. */
  35847. currentDraggingPointerID: number;
  35848. /**
  35849. * The last position where the pointer hit the drag plane in world space
  35850. */
  35851. lastDragPosition: Vector3;
  35852. /**
  35853. * If the behavior is currently in a dragging state
  35854. */
  35855. dragging: boolean;
  35856. /**
  35857. * 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)
  35858. */
  35859. dragDeltaRatio: number;
  35860. /**
  35861. * If the drag plane orientation should be updated during the dragging (Default: true)
  35862. */
  35863. updateDragPlane: boolean;
  35864. private _debugMode;
  35865. private _moving;
  35866. /**
  35867. * Fires each time the attached mesh is dragged with the pointer
  35868. * * delta between last drag position and current drag position in world space
  35869. * * dragDistance along the drag axis
  35870. * * dragPlaneNormal normal of the current drag plane used during the drag
  35871. * * dragPlanePoint in world space where the drag intersects the drag plane
  35872. */
  35873. onDragObservable: Observable<{
  35874. delta: Vector3;
  35875. dragPlanePoint: Vector3;
  35876. dragPlaneNormal: Vector3;
  35877. dragDistance: number;
  35878. pointerId: number;
  35879. }>;
  35880. /**
  35881. * Fires each time a drag begins (eg. mouse down on mesh)
  35882. */
  35883. onDragStartObservable: Observable<{
  35884. dragPlanePoint: Vector3;
  35885. pointerId: number;
  35886. }>;
  35887. /**
  35888. * Fires each time a drag ends (eg. mouse release after drag)
  35889. */
  35890. onDragEndObservable: Observable<{
  35891. dragPlanePoint: Vector3;
  35892. pointerId: number;
  35893. }>;
  35894. /**
  35895. * If the attached mesh should be moved when dragged
  35896. */
  35897. moveAttached: boolean;
  35898. /**
  35899. * If the drag behavior will react to drag events (Default: true)
  35900. */
  35901. enabled: boolean;
  35902. /**
  35903. * If camera controls should be detached during the drag
  35904. */
  35905. detachCameraControls: boolean;
  35906. /**
  35907. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35908. */
  35909. useObjectOrienationForDragging: boolean;
  35910. private _options;
  35911. /**
  35912. * Creates a pointer drag behavior that can be attached to a mesh
  35913. * @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)
  35914. */
  35915. constructor(options?: {
  35916. dragAxis?: Vector3;
  35917. dragPlaneNormal?: Vector3;
  35918. });
  35919. /**
  35920. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35921. */
  35922. validateDrag: (targetPosition: Vector3) => boolean;
  35923. /**
  35924. * The name of the behavior
  35925. */
  35926. readonly name: string;
  35927. /**
  35928. * Initializes the behavior
  35929. */
  35930. init(): void;
  35931. private _tmpVector;
  35932. private _alternatePickedPoint;
  35933. private _worldDragAxis;
  35934. private _targetPosition;
  35935. private _attachedElement;
  35936. /**
  35937. * Attaches the drag behavior the passed in mesh
  35938. * @param ownerNode The mesh that will be dragged around once attached
  35939. */
  35940. attach(ownerNode: AbstractMesh): void;
  35941. /**
  35942. * Force relase the drag action by code.
  35943. */
  35944. releaseDrag(): void;
  35945. private _startDragRay;
  35946. private _lastPointerRay;
  35947. /**
  35948. * Simulates the start of a pointer drag event on the behavior
  35949. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35950. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35951. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35952. */
  35953. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35954. private _startDrag;
  35955. private _dragDelta;
  35956. private _moveDrag;
  35957. private _pickWithRayOnDragPlane;
  35958. private _pointA;
  35959. private _pointB;
  35960. private _pointC;
  35961. private _lineA;
  35962. private _lineB;
  35963. private _localAxis;
  35964. private _lookAt;
  35965. private _updateDragPlanePosition;
  35966. /**
  35967. * Detaches the behavior from the mesh
  35968. */
  35969. detach(): void;
  35970. }
  35971. }
  35972. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  35973. import { Mesh } from "babylonjs/Meshes/mesh";
  35974. import { Behavior } from "babylonjs/Behaviors/behavior";
  35975. /**
  35976. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35977. */
  35978. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35979. private _dragBehaviorA;
  35980. private _dragBehaviorB;
  35981. private _startDistance;
  35982. private _initialScale;
  35983. private _targetScale;
  35984. private _ownerNode;
  35985. private _sceneRenderObserver;
  35986. /**
  35987. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35988. */
  35989. constructor();
  35990. /**
  35991. * The name of the behavior
  35992. */
  35993. readonly name: string;
  35994. /**
  35995. * Initializes the behavior
  35996. */
  35997. init(): void;
  35998. private _getCurrentDistance;
  35999. /**
  36000. * Attaches the scale behavior the passed in mesh
  36001. * @param ownerNode The mesh that will be scaled around once attached
  36002. */
  36003. attach(ownerNode: Mesh): void;
  36004. /**
  36005. * Detaches the behavior from the mesh
  36006. */
  36007. detach(): void;
  36008. }
  36009. }
  36010. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  36011. import { Behavior } from "babylonjs/Behaviors/behavior";
  36012. import { Mesh } from "babylonjs/Meshes/mesh";
  36013. import { Observable } from "babylonjs/Misc/observable";
  36014. /**
  36015. * 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
  36016. */
  36017. export class SixDofDragBehavior implements Behavior<Mesh> {
  36018. private static _virtualScene;
  36019. private _ownerNode;
  36020. private _sceneRenderObserver;
  36021. private _scene;
  36022. private _targetPosition;
  36023. private _virtualOriginMesh;
  36024. private _virtualDragMesh;
  36025. private _pointerObserver;
  36026. private _moving;
  36027. private _startingOrientation;
  36028. /**
  36029. * 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)
  36030. */
  36031. private zDragFactor;
  36032. /**
  36033. * If the object should rotate to face the drag origin
  36034. */
  36035. rotateDraggedObject: boolean;
  36036. /**
  36037. * If the behavior is currently in a dragging state
  36038. */
  36039. dragging: boolean;
  36040. /**
  36041. * 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)
  36042. */
  36043. dragDeltaRatio: number;
  36044. /**
  36045. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36046. */
  36047. currentDraggingPointerID: number;
  36048. /**
  36049. * If camera controls should be detached during the drag
  36050. */
  36051. detachCameraControls: boolean;
  36052. /**
  36053. * Fires each time a drag starts
  36054. */
  36055. onDragStartObservable: Observable<{}>;
  36056. /**
  36057. * Fires each time a drag ends (eg. mouse release after drag)
  36058. */
  36059. onDragEndObservable: Observable<{}>;
  36060. /**
  36061. * 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
  36062. */
  36063. constructor();
  36064. /**
  36065. * The name of the behavior
  36066. */
  36067. readonly name: string;
  36068. /**
  36069. * Initializes the behavior
  36070. */
  36071. init(): void;
  36072. /**
  36073. * Attaches the scale behavior the passed in mesh
  36074. * @param ownerNode The mesh that will be scaled around once attached
  36075. */
  36076. attach(ownerNode: Mesh): void;
  36077. /**
  36078. * Detaches the behavior from the mesh
  36079. */
  36080. detach(): void;
  36081. }
  36082. }
  36083. declare module "babylonjs/Behaviors/Meshes/index" {
  36084. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  36085. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  36086. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  36087. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  36088. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  36089. }
  36090. declare module "babylonjs/Behaviors/index" {
  36091. export * from "babylonjs/Behaviors/behavior";
  36092. export * from "babylonjs/Behaviors/Cameras/index";
  36093. export * from "babylonjs/Behaviors/Meshes/index";
  36094. }
  36095. declare module "babylonjs/Bones/boneIKController" {
  36096. import { Bone } from "babylonjs/Bones/bone";
  36097. import { Vector3 } from "babylonjs/Maths/math";
  36098. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36099. import { Nullable } from "babylonjs/types";
  36100. /**
  36101. * Class used to apply inverse kinematics to bones
  36102. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36103. */
  36104. export class BoneIKController {
  36105. private static _tmpVecs;
  36106. private static _tmpQuat;
  36107. private static _tmpMats;
  36108. /**
  36109. * Gets or sets the target mesh
  36110. */
  36111. targetMesh: AbstractMesh;
  36112. /** Gets or sets the mesh used as pole */
  36113. poleTargetMesh: AbstractMesh;
  36114. /**
  36115. * Gets or sets the bone used as pole
  36116. */
  36117. poleTargetBone: Nullable<Bone>;
  36118. /**
  36119. * Gets or sets the target position
  36120. */
  36121. targetPosition: Vector3;
  36122. /**
  36123. * Gets or sets the pole target position
  36124. */
  36125. poleTargetPosition: Vector3;
  36126. /**
  36127. * Gets or sets the pole target local offset
  36128. */
  36129. poleTargetLocalOffset: Vector3;
  36130. /**
  36131. * Gets or sets the pole angle
  36132. */
  36133. poleAngle: number;
  36134. /**
  36135. * Gets or sets the mesh associated with the controller
  36136. */
  36137. mesh: AbstractMesh;
  36138. /**
  36139. * 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)
  36140. */
  36141. slerpAmount: number;
  36142. private _bone1Quat;
  36143. private _bone1Mat;
  36144. private _bone2Ang;
  36145. private _bone1;
  36146. private _bone2;
  36147. private _bone1Length;
  36148. private _bone2Length;
  36149. private _maxAngle;
  36150. private _maxReach;
  36151. private _rightHandedSystem;
  36152. private _bendAxis;
  36153. private _slerping;
  36154. private _adjustRoll;
  36155. /**
  36156. * Gets or sets maximum allowed angle
  36157. */
  36158. maxAngle: number;
  36159. /**
  36160. * Creates a new BoneIKController
  36161. * @param mesh defines the mesh to control
  36162. * @param bone defines the bone to control
  36163. * @param options defines options to set up the controller
  36164. */
  36165. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36166. targetMesh?: AbstractMesh;
  36167. poleTargetMesh?: AbstractMesh;
  36168. poleTargetBone?: Bone;
  36169. poleTargetLocalOffset?: Vector3;
  36170. poleAngle?: number;
  36171. bendAxis?: Vector3;
  36172. maxAngle?: number;
  36173. slerpAmount?: number;
  36174. });
  36175. private _setMaxAngle;
  36176. /**
  36177. * Force the controller to update the bones
  36178. */
  36179. update(): void;
  36180. }
  36181. }
  36182. declare module "babylonjs/Bones/boneLookController" {
  36183. import { Vector3, Space } from "babylonjs/Maths/math";
  36184. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36185. import { Bone } from "babylonjs/Bones/bone";
  36186. /**
  36187. * Class used to make a bone look toward a point in space
  36188. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36189. */
  36190. export class BoneLookController {
  36191. private static _tmpVecs;
  36192. private static _tmpQuat;
  36193. private static _tmpMats;
  36194. /**
  36195. * The target Vector3 that the bone will look at
  36196. */
  36197. target: Vector3;
  36198. /**
  36199. * The mesh that the bone is attached to
  36200. */
  36201. mesh: AbstractMesh;
  36202. /**
  36203. * The bone that will be looking to the target
  36204. */
  36205. bone: Bone;
  36206. /**
  36207. * The up axis of the coordinate system that is used when the bone is rotated
  36208. */
  36209. upAxis: Vector3;
  36210. /**
  36211. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36212. */
  36213. upAxisSpace: Space;
  36214. /**
  36215. * Used to make an adjustment to the yaw of the bone
  36216. */
  36217. adjustYaw: number;
  36218. /**
  36219. * Used to make an adjustment to the pitch of the bone
  36220. */
  36221. adjustPitch: number;
  36222. /**
  36223. * Used to make an adjustment to the roll of the bone
  36224. */
  36225. adjustRoll: number;
  36226. /**
  36227. * 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)
  36228. */
  36229. slerpAmount: number;
  36230. private _minYaw;
  36231. private _maxYaw;
  36232. private _minPitch;
  36233. private _maxPitch;
  36234. private _minYawSin;
  36235. private _minYawCos;
  36236. private _maxYawSin;
  36237. private _maxYawCos;
  36238. private _midYawConstraint;
  36239. private _minPitchTan;
  36240. private _maxPitchTan;
  36241. private _boneQuat;
  36242. private _slerping;
  36243. private _transformYawPitch;
  36244. private _transformYawPitchInv;
  36245. private _firstFrameSkipped;
  36246. private _yawRange;
  36247. private _fowardAxis;
  36248. /**
  36249. * Gets or sets the minimum yaw angle that the bone can look to
  36250. */
  36251. minYaw: number;
  36252. /**
  36253. * Gets or sets the maximum yaw angle that the bone can look to
  36254. */
  36255. maxYaw: number;
  36256. /**
  36257. * Gets or sets the minimum pitch angle that the bone can look to
  36258. */
  36259. minPitch: number;
  36260. /**
  36261. * Gets or sets the maximum pitch angle that the bone can look to
  36262. */
  36263. maxPitch: number;
  36264. /**
  36265. * Create a BoneLookController
  36266. * @param mesh the mesh that the bone belongs to
  36267. * @param bone the bone that will be looking to the target
  36268. * @param target the target Vector3 to look at
  36269. * @param options optional settings:
  36270. * * maxYaw: the maximum angle the bone will yaw to
  36271. * * minYaw: the minimum angle the bone will yaw to
  36272. * * maxPitch: the maximum angle the bone will pitch to
  36273. * * minPitch: the minimum angle the bone will yaw to
  36274. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36275. * * upAxis: the up axis of the coordinate system
  36276. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36277. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36278. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36279. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36280. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36281. * * adjustRoll: used to make an adjustment to the roll of the bone
  36282. **/
  36283. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36284. maxYaw?: number;
  36285. minYaw?: number;
  36286. maxPitch?: number;
  36287. minPitch?: number;
  36288. slerpAmount?: number;
  36289. upAxis?: Vector3;
  36290. upAxisSpace?: Space;
  36291. yawAxis?: Vector3;
  36292. pitchAxis?: Vector3;
  36293. adjustYaw?: number;
  36294. adjustPitch?: number;
  36295. adjustRoll?: number;
  36296. });
  36297. /**
  36298. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36299. */
  36300. update(): void;
  36301. private _getAngleDiff;
  36302. private _getAngleBetween;
  36303. private _isAngleBetween;
  36304. }
  36305. }
  36306. declare module "babylonjs/Bones/index" {
  36307. export * from "babylonjs/Bones/bone";
  36308. export * from "babylonjs/Bones/boneIKController";
  36309. export * from "babylonjs/Bones/boneLookController";
  36310. export * from "babylonjs/Bones/skeleton";
  36311. }
  36312. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  36313. import { Nullable } from "babylonjs/types";
  36314. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36315. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36316. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  36317. /**
  36318. * Manage the gamepad inputs to control an arc rotate camera.
  36319. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36320. */
  36321. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36322. /**
  36323. * Defines the camera the input is attached to.
  36324. */
  36325. camera: ArcRotateCamera;
  36326. /**
  36327. * Defines the gamepad the input is gathering event from.
  36328. */
  36329. gamepad: Nullable<Gamepad>;
  36330. /**
  36331. * Defines the gamepad rotation sensiblity.
  36332. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36333. */
  36334. gamepadRotationSensibility: number;
  36335. /**
  36336. * Defines the gamepad move sensiblity.
  36337. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36338. */
  36339. gamepadMoveSensibility: number;
  36340. private _onGamepadConnectedObserver;
  36341. private _onGamepadDisconnectedObserver;
  36342. /**
  36343. * Attach the input controls to a specific dom element to get the input from.
  36344. * @param element Defines the element the controls should be listened from
  36345. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36346. */
  36347. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36348. /**
  36349. * Detach the current controls from the specified dom element.
  36350. * @param element Defines the element to stop listening the inputs from
  36351. */
  36352. detachControl(element: Nullable<HTMLElement>): void;
  36353. /**
  36354. * Update the current camera state depending on the inputs that have been used this frame.
  36355. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36356. */
  36357. checkInputs(): void;
  36358. /**
  36359. * Gets the class name of the current intput.
  36360. * @returns the class name
  36361. */
  36362. getClassName(): string;
  36363. /**
  36364. * Get the friendly name associated with the input class.
  36365. * @returns the input friendly name
  36366. */
  36367. getSimpleName(): string;
  36368. }
  36369. }
  36370. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  36371. import { Nullable } from "babylonjs/types";
  36372. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36373. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36374. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36375. interface ArcRotateCameraInputsManager {
  36376. /**
  36377. * Add orientation input support to the input manager.
  36378. * @returns the current input manager
  36379. */
  36380. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36381. }
  36382. }
  36383. /**
  36384. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36385. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36386. */
  36387. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36388. /**
  36389. * Defines the camera the input is attached to.
  36390. */
  36391. camera: ArcRotateCamera;
  36392. /**
  36393. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36394. */
  36395. alphaCorrection: number;
  36396. /**
  36397. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36398. */
  36399. gammaCorrection: number;
  36400. private _alpha;
  36401. private _gamma;
  36402. private _dirty;
  36403. private _deviceOrientationHandler;
  36404. /**
  36405. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36406. */
  36407. constructor();
  36408. /**
  36409. * Attach the input controls to a specific dom element to get the input from.
  36410. * @param element Defines the element the controls should be listened from
  36411. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36412. */
  36413. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36414. /** @hidden */
  36415. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36416. /**
  36417. * Update the current camera state depending on the inputs that have been used this frame.
  36418. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36419. */
  36420. checkInputs(): void;
  36421. /**
  36422. * Detach the current controls from the specified dom element.
  36423. * @param element Defines the element to stop listening the inputs from
  36424. */
  36425. detachControl(element: Nullable<HTMLElement>): void;
  36426. /**
  36427. * Gets the class name of the current intput.
  36428. * @returns the class name
  36429. */
  36430. getClassName(): string;
  36431. /**
  36432. * Get the friendly name associated with the input class.
  36433. * @returns the input friendly name
  36434. */
  36435. getSimpleName(): string;
  36436. }
  36437. }
  36438. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  36439. import { Nullable } from "babylonjs/types";
  36440. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36441. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36442. /**
  36443. * Listen to mouse events to control the camera.
  36444. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36445. */
  36446. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36447. /**
  36448. * Defines the camera the input is attached to.
  36449. */
  36450. camera: FlyCamera;
  36451. /**
  36452. * Defines if touch is enabled. (Default is true.)
  36453. */
  36454. touchEnabled: boolean;
  36455. /**
  36456. * Defines the buttons associated with the input to handle camera rotation.
  36457. */
  36458. buttons: number[];
  36459. /**
  36460. * Assign buttons for Yaw control.
  36461. */
  36462. buttonsYaw: number[];
  36463. /**
  36464. * Assign buttons for Pitch control.
  36465. */
  36466. buttonsPitch: number[];
  36467. /**
  36468. * Assign buttons for Roll control.
  36469. */
  36470. buttonsRoll: number[];
  36471. /**
  36472. * Detect if any button is being pressed while mouse is moved.
  36473. * -1 = Mouse locked.
  36474. * 0 = Left button.
  36475. * 1 = Middle Button.
  36476. * 2 = Right Button.
  36477. */
  36478. activeButton: number;
  36479. /**
  36480. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36481. * Higher values reduce its sensitivity.
  36482. */
  36483. angularSensibility: number;
  36484. private _mousemoveCallback;
  36485. private _observer;
  36486. private _rollObserver;
  36487. private previousPosition;
  36488. private noPreventDefault;
  36489. private element;
  36490. /**
  36491. * Listen to mouse events to control the camera.
  36492. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36493. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36494. */
  36495. constructor(touchEnabled?: boolean);
  36496. /**
  36497. * Attach the mouse control to the HTML DOM element.
  36498. * @param element Defines the element that listens to the input events.
  36499. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36500. */
  36501. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36502. /**
  36503. * Detach the current controls from the specified dom element.
  36504. * @param element Defines the element to stop listening the inputs from
  36505. */
  36506. detachControl(element: Nullable<HTMLElement>): void;
  36507. /**
  36508. * Gets the class name of the current input.
  36509. * @returns the class name.
  36510. */
  36511. getClassName(): string;
  36512. /**
  36513. * Get the friendly name associated with the input class.
  36514. * @returns the input's friendly name.
  36515. */
  36516. getSimpleName(): string;
  36517. private _pointerInput;
  36518. private _onMouseMove;
  36519. /**
  36520. * Rotate camera by mouse offset.
  36521. */
  36522. private rotateCamera;
  36523. }
  36524. }
  36525. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  36526. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36527. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36528. /**
  36529. * Default Inputs manager for the FlyCamera.
  36530. * It groups all the default supported inputs for ease of use.
  36531. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36532. */
  36533. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36534. /**
  36535. * Instantiates a new FlyCameraInputsManager.
  36536. * @param camera Defines the camera the inputs belong to.
  36537. */
  36538. constructor(camera: FlyCamera);
  36539. /**
  36540. * Add keyboard input support to the input manager.
  36541. * @returns the new FlyCameraKeyboardMoveInput().
  36542. */
  36543. addKeyboard(): FlyCameraInputsManager;
  36544. /**
  36545. * Add mouse input support to the input manager.
  36546. * @param touchEnabled Enable touch screen support.
  36547. * @returns the new FlyCameraMouseInput().
  36548. */
  36549. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36550. }
  36551. }
  36552. declare module "babylonjs/Cameras/flyCamera" {
  36553. import { Scene } from "babylonjs/scene";
  36554. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  36555. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36556. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36557. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  36558. /**
  36559. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36560. * such as in a 3D Space Shooter or a Flight Simulator.
  36561. */
  36562. export class FlyCamera extends TargetCamera {
  36563. /**
  36564. * Define the collision ellipsoid of the camera.
  36565. * This is helpful for simulating a camera body, like a player's body.
  36566. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36567. */
  36568. ellipsoid: Vector3;
  36569. /**
  36570. * Define an offset for the position of the ellipsoid around the camera.
  36571. * This can be helpful if the camera is attached away from the player's body center,
  36572. * such as at its head.
  36573. */
  36574. ellipsoidOffset: Vector3;
  36575. /**
  36576. * Enable or disable collisions of the camera with the rest of the scene objects.
  36577. */
  36578. checkCollisions: boolean;
  36579. /**
  36580. * Enable or disable gravity on the camera.
  36581. */
  36582. applyGravity: boolean;
  36583. /**
  36584. * Define the current direction the camera is moving to.
  36585. */
  36586. cameraDirection: Vector3;
  36587. /**
  36588. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36589. * This overrides and empties cameraRotation.
  36590. */
  36591. rotationQuaternion: Quaternion;
  36592. /**
  36593. * Track Roll to maintain the wanted Rolling when looking around.
  36594. */
  36595. _trackRoll: number;
  36596. /**
  36597. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36598. */
  36599. rollCorrect: number;
  36600. /**
  36601. * Mimic a banked turn, Rolling the camera when Yawing.
  36602. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36603. */
  36604. bankedTurn: boolean;
  36605. /**
  36606. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36607. */
  36608. bankedTurnLimit: number;
  36609. /**
  36610. * Value of 0 disables the banked Roll.
  36611. * Value of 1 is equal to the Yaw angle in radians.
  36612. */
  36613. bankedTurnMultiplier: number;
  36614. /**
  36615. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36616. */
  36617. inputs: FlyCameraInputsManager;
  36618. /**
  36619. * Gets the input sensibility for mouse input.
  36620. * Higher values reduce sensitivity.
  36621. */
  36622. /**
  36623. * Sets the input sensibility for a mouse input.
  36624. * Higher values reduce sensitivity.
  36625. */
  36626. angularSensibility: number;
  36627. /**
  36628. * Get the keys for camera movement forward.
  36629. */
  36630. /**
  36631. * Set the keys for camera movement forward.
  36632. */
  36633. keysForward: number[];
  36634. /**
  36635. * Get the keys for camera movement backward.
  36636. */
  36637. keysBackward: number[];
  36638. /**
  36639. * Get the keys for camera movement up.
  36640. */
  36641. /**
  36642. * Set the keys for camera movement up.
  36643. */
  36644. keysUp: number[];
  36645. /**
  36646. * Get the keys for camera movement down.
  36647. */
  36648. /**
  36649. * Set the keys for camera movement down.
  36650. */
  36651. keysDown: number[];
  36652. /**
  36653. * Get the keys for camera movement left.
  36654. */
  36655. /**
  36656. * Set the keys for camera movement left.
  36657. */
  36658. keysLeft: number[];
  36659. /**
  36660. * Set the keys for camera movement right.
  36661. */
  36662. /**
  36663. * Set the keys for camera movement right.
  36664. */
  36665. keysRight: number[];
  36666. /**
  36667. * Event raised when the camera collides with a mesh in the scene.
  36668. */
  36669. onCollide: (collidedMesh: AbstractMesh) => void;
  36670. private _collider;
  36671. private _needMoveForGravity;
  36672. private _oldPosition;
  36673. private _diffPosition;
  36674. private _newPosition;
  36675. /** @hidden */
  36676. _localDirection: Vector3;
  36677. /** @hidden */
  36678. _transformedDirection: Vector3;
  36679. /**
  36680. * Instantiates a FlyCamera.
  36681. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36682. * such as in a 3D Space Shooter or a Flight Simulator.
  36683. * @param name Define the name of the camera in the scene.
  36684. * @param position Define the starting position of the camera in the scene.
  36685. * @param scene Define the scene the camera belongs to.
  36686. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36687. */
  36688. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36689. /**
  36690. * Attach a control to the HTML DOM element.
  36691. * @param element Defines the element that listens to the input events.
  36692. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36693. */
  36694. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36695. /**
  36696. * Detach a control from the HTML DOM element.
  36697. * The camera will stop reacting to that input.
  36698. * @param element Defines the element that listens to the input events.
  36699. */
  36700. detachControl(element: HTMLElement): void;
  36701. private _collisionMask;
  36702. /**
  36703. * Get the mask that the camera ignores in collision events.
  36704. */
  36705. /**
  36706. * Set the mask that the camera ignores in collision events.
  36707. */
  36708. collisionMask: number;
  36709. /** @hidden */
  36710. _collideWithWorld(displacement: Vector3): void;
  36711. /** @hidden */
  36712. private _onCollisionPositionChange;
  36713. /** @hidden */
  36714. _checkInputs(): void;
  36715. /** @hidden */
  36716. _decideIfNeedsToMove(): boolean;
  36717. /** @hidden */
  36718. _updatePosition(): void;
  36719. /**
  36720. * Restore the Roll to its target value at the rate specified.
  36721. * @param rate - Higher means slower restoring.
  36722. * @hidden
  36723. */
  36724. restoreRoll(rate: number): void;
  36725. /**
  36726. * Destroy the camera and release the current resources held by it.
  36727. */
  36728. dispose(): void;
  36729. /**
  36730. * Get the current object class name.
  36731. * @returns the class name.
  36732. */
  36733. getClassName(): string;
  36734. }
  36735. }
  36736. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  36737. import { Nullable } from "babylonjs/types";
  36738. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36739. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36740. /**
  36741. * Listen to keyboard events to control the camera.
  36742. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36743. */
  36744. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36745. /**
  36746. * Defines the camera the input is attached to.
  36747. */
  36748. camera: FlyCamera;
  36749. /**
  36750. * The list of keyboard keys used to control the forward move of the camera.
  36751. */
  36752. keysForward: number[];
  36753. /**
  36754. * The list of keyboard keys used to control the backward move of the camera.
  36755. */
  36756. keysBackward: number[];
  36757. /**
  36758. * The list of keyboard keys used to control the forward move of the camera.
  36759. */
  36760. keysUp: number[];
  36761. /**
  36762. * The list of keyboard keys used to control the backward move of the camera.
  36763. */
  36764. keysDown: number[];
  36765. /**
  36766. * The list of keyboard keys used to control the right strafe move of the camera.
  36767. */
  36768. keysRight: number[];
  36769. /**
  36770. * The list of keyboard keys used to control the left strafe move of the camera.
  36771. */
  36772. keysLeft: number[];
  36773. private _keys;
  36774. private _onCanvasBlurObserver;
  36775. private _onKeyboardObserver;
  36776. private _engine;
  36777. private _scene;
  36778. /**
  36779. * Attach the input controls to a specific dom element to get the input from.
  36780. * @param element Defines the element the controls should be listened from
  36781. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36782. */
  36783. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36784. /**
  36785. * Detach the current controls from the specified dom element.
  36786. * @param element Defines the element to stop listening the inputs from
  36787. */
  36788. detachControl(element: Nullable<HTMLElement>): void;
  36789. /**
  36790. * Gets the class name of the current intput.
  36791. * @returns the class name
  36792. */
  36793. getClassName(): string;
  36794. /** @hidden */
  36795. _onLostFocus(e: FocusEvent): void;
  36796. /**
  36797. * Get the friendly name associated with the input class.
  36798. * @returns the input friendly name
  36799. */
  36800. getSimpleName(): string;
  36801. /**
  36802. * Update the current camera state depending on the inputs that have been used this frame.
  36803. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36804. */
  36805. checkInputs(): void;
  36806. }
  36807. }
  36808. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  36809. import { Nullable } from "babylonjs/types";
  36810. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36811. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36812. /**
  36813. * Manage the mouse wheel inputs to control a follow camera.
  36814. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36815. */
  36816. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36817. /**
  36818. * Defines the camera the input is attached to.
  36819. */
  36820. camera: FollowCamera;
  36821. /**
  36822. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  36823. */
  36824. axisControlRadius: boolean;
  36825. /**
  36826. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  36827. */
  36828. axisControlHeight: boolean;
  36829. /**
  36830. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  36831. */
  36832. axisControlRotation: boolean;
  36833. /**
  36834. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36835. * relation to mouseWheel events.
  36836. */
  36837. wheelPrecision: number;
  36838. /**
  36839. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36840. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36841. */
  36842. wheelDeltaPercentage: number;
  36843. private _wheel;
  36844. private _observer;
  36845. /**
  36846. * Attach the input controls to a specific dom element to get the input from.
  36847. * @param element Defines the element the controls should be listened from
  36848. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36849. */
  36850. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36851. /**
  36852. * Detach the current controls from the specified dom element.
  36853. * @param element Defines the element to stop listening the inputs from
  36854. */
  36855. detachControl(element: Nullable<HTMLElement>): void;
  36856. /**
  36857. * Gets the class name of the current intput.
  36858. * @returns the class name
  36859. */
  36860. getClassName(): string;
  36861. /**
  36862. * Get the friendly name associated with the input class.
  36863. * @returns the input friendly name
  36864. */
  36865. getSimpleName(): string;
  36866. }
  36867. }
  36868. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  36869. import { Nullable } from "babylonjs/types";
  36870. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36871. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36872. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36873. /**
  36874. * Manage the pointers inputs to control an follow camera.
  36875. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36876. */
  36877. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36878. /**
  36879. * Defines the camera the input is attached to.
  36880. */
  36881. camera: FollowCamera;
  36882. /**
  36883. * Gets the class name of the current input.
  36884. * @returns the class name
  36885. */
  36886. getClassName(): string;
  36887. /**
  36888. * Defines the pointer angular sensibility along the X axis or how fast is
  36889. * the camera rotating.
  36890. * A negative number will reverse the axis direction.
  36891. */
  36892. angularSensibilityX: number;
  36893. /**
  36894. * Defines the pointer angular sensibility along the Y axis or how fast is
  36895. * the camera rotating.
  36896. * A negative number will reverse the axis direction.
  36897. */
  36898. angularSensibilityY: number;
  36899. /**
  36900. * Defines the pointer pinch precision or how fast is the camera zooming.
  36901. * A negative number will reverse the axis direction.
  36902. */
  36903. pinchPrecision: number;
  36904. /**
  36905. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36906. * from 0.
  36907. * It defines the percentage of current camera.radius to use as delta when
  36908. * pinch zoom is used.
  36909. */
  36910. pinchDeltaPercentage: number;
  36911. /**
  36912. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36913. */
  36914. axisXControlRadius: boolean;
  36915. /**
  36916. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36917. */
  36918. axisXControlHeight: boolean;
  36919. /**
  36920. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36921. */
  36922. axisXControlRotation: boolean;
  36923. /**
  36924. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36925. */
  36926. axisYControlRadius: boolean;
  36927. /**
  36928. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36929. */
  36930. axisYControlHeight: boolean;
  36931. /**
  36932. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36933. */
  36934. axisYControlRotation: boolean;
  36935. /**
  36936. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36937. */
  36938. axisPinchControlRadius: boolean;
  36939. /**
  36940. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36941. */
  36942. axisPinchControlHeight: boolean;
  36943. /**
  36944. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  36945. */
  36946. axisPinchControlRotation: boolean;
  36947. /**
  36948. * Log error messages if basic misconfiguration has occurred.
  36949. */
  36950. warningEnable: boolean;
  36951. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36952. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36953. private _warningCounter;
  36954. private _warning;
  36955. }
  36956. }
  36957. declare module "babylonjs/Cameras/followCameraInputsManager" {
  36958. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36959. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36960. /**
  36961. * Default Inputs manager for the FollowCamera.
  36962. * It groups all the default supported inputs for ease of use.
  36963. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36964. */
  36965. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36966. /**
  36967. * Instantiates a new FollowCameraInputsManager.
  36968. * @param camera Defines the camera the inputs belong to
  36969. */
  36970. constructor(camera: FollowCamera);
  36971. /**
  36972. * Add keyboard input support to the input manager.
  36973. * @returns the current input manager
  36974. */
  36975. addKeyboard(): FollowCameraInputsManager;
  36976. /**
  36977. * Add mouse wheel input support to the input manager.
  36978. * @returns the current input manager
  36979. */
  36980. addMouseWheel(): FollowCameraInputsManager;
  36981. /**
  36982. * Add pointers input support to the input manager.
  36983. * @returns the current input manager
  36984. */
  36985. addPointers(): FollowCameraInputsManager;
  36986. /**
  36987. * Add orientation input support to the input manager.
  36988. * @returns the current input manager
  36989. */
  36990. addVRDeviceOrientation(): FollowCameraInputsManager;
  36991. }
  36992. }
  36993. declare module "babylonjs/Cameras/followCamera" {
  36994. import { Nullable } from "babylonjs/types";
  36995. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36996. import { Scene } from "babylonjs/scene";
  36997. import { Vector3 } from "babylonjs/Maths/math";
  36998. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36999. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  37000. /**
  37001. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37002. * an arc rotate version arcFollowCamera are available.
  37003. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37004. */
  37005. export class FollowCamera extends TargetCamera {
  37006. /**
  37007. * Distance the follow camera should follow an object at
  37008. */
  37009. radius: number;
  37010. /**
  37011. * Minimum allowed distance of the camera to the axis of rotation
  37012. * (The camera can not get closer).
  37013. * This can help limiting how the Camera is able to move in the scene.
  37014. */
  37015. lowerRadiusLimit: Nullable<number>;
  37016. /**
  37017. * Maximum allowed distance of the camera to the axis of rotation
  37018. * (The camera can not get further).
  37019. * This can help limiting how the Camera is able to move in the scene.
  37020. */
  37021. upperRadiusLimit: Nullable<number>;
  37022. /**
  37023. * Define a rotation offset between the camera and the object it follows
  37024. */
  37025. rotationOffset: number;
  37026. /**
  37027. * Minimum allowed angle to camera position relative to target object.
  37028. * This can help limiting how the Camera is able to move in the scene.
  37029. */
  37030. lowerRotationOffsetLimit: Nullable<number>;
  37031. /**
  37032. * Maximum allowed angle to camera position relative to target object.
  37033. * This can help limiting how the Camera is able to move in the scene.
  37034. */
  37035. upperRotationOffsetLimit: Nullable<number>;
  37036. /**
  37037. * Define a height offset between the camera and the object it follows.
  37038. * It can help following an object from the top (like a car chaing a plane)
  37039. */
  37040. heightOffset: number;
  37041. /**
  37042. * Minimum allowed height of camera position relative to target object.
  37043. * This can help limiting how the Camera is able to move in the scene.
  37044. */
  37045. lowerHeightOffsetLimit: Nullable<number>;
  37046. /**
  37047. * Maximum allowed height of camera position relative to target object.
  37048. * This can help limiting how the Camera is able to move in the scene.
  37049. */
  37050. upperHeightOffsetLimit: Nullable<number>;
  37051. /**
  37052. * Define how fast the camera can accelerate to follow it s target.
  37053. */
  37054. cameraAcceleration: number;
  37055. /**
  37056. * Define the speed limit of the camera following an object.
  37057. */
  37058. maxCameraSpeed: number;
  37059. /**
  37060. * Define the target of the camera.
  37061. */
  37062. lockedTarget: Nullable<AbstractMesh>;
  37063. /**
  37064. * Defines the input associated with the camera.
  37065. */
  37066. inputs: FollowCameraInputsManager;
  37067. /**
  37068. * Instantiates the follow camera.
  37069. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37070. * @param name Define the name of the camera in the scene
  37071. * @param position Define the position of the camera
  37072. * @param scene Define the scene the camera belong to
  37073. * @param lockedTarget Define the target of the camera
  37074. */
  37075. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37076. private _follow;
  37077. /**
  37078. * Attached controls to the current camera.
  37079. * @param element Defines the element the controls should be listened from
  37080. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37081. */
  37082. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37083. /**
  37084. * Detach the current controls from the camera.
  37085. * The camera will stop reacting to inputs.
  37086. * @param element Defines the element to stop listening the inputs from
  37087. */
  37088. detachControl(element: HTMLElement): void;
  37089. /** @hidden */
  37090. _checkInputs(): void;
  37091. private _checkLimits;
  37092. /**
  37093. * Gets the camera class name.
  37094. * @returns the class name
  37095. */
  37096. getClassName(): string;
  37097. }
  37098. /**
  37099. * Arc Rotate version of the follow camera.
  37100. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37101. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37102. */
  37103. export class ArcFollowCamera extends TargetCamera {
  37104. /** The longitudinal angle of the camera */
  37105. alpha: number;
  37106. /** The latitudinal angle of the camera */
  37107. beta: number;
  37108. /** The radius of the camera from its target */
  37109. radius: number;
  37110. /** Define the camera target (the messh it should follow) */
  37111. target: Nullable<AbstractMesh>;
  37112. private _cartesianCoordinates;
  37113. /**
  37114. * Instantiates a new ArcFollowCamera
  37115. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37116. * @param name Define the name of the camera
  37117. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37118. * @param beta Define the rotation angle of the camera around the elevation axis
  37119. * @param radius Define the radius of the camera from its target point
  37120. * @param target Define the target of the camera
  37121. * @param scene Define the scene the camera belongs to
  37122. */
  37123. constructor(name: string,
  37124. /** The longitudinal angle of the camera */
  37125. alpha: number,
  37126. /** The latitudinal angle of the camera */
  37127. beta: number,
  37128. /** The radius of the camera from its target */
  37129. radius: number,
  37130. /** Define the camera target (the messh it should follow) */
  37131. target: Nullable<AbstractMesh>, scene: Scene);
  37132. private _follow;
  37133. /** @hidden */
  37134. _checkInputs(): void;
  37135. /**
  37136. * Returns the class name of the object.
  37137. * It is mostly used internally for serialization purposes.
  37138. */
  37139. getClassName(): string;
  37140. }
  37141. }
  37142. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  37143. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37144. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37145. import { Nullable } from "babylonjs/types";
  37146. /**
  37147. * Manage the keyboard inputs to control the movement of a follow camera.
  37148. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37149. */
  37150. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37151. /**
  37152. * Defines the camera the input is attached to.
  37153. */
  37154. camera: FollowCamera;
  37155. /**
  37156. * Defines the list of key codes associated with the up action (increase heightOffset)
  37157. */
  37158. keysHeightOffsetIncr: number[];
  37159. /**
  37160. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37161. */
  37162. keysHeightOffsetDecr: number[];
  37163. /**
  37164. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37165. */
  37166. keysHeightOffsetModifierAlt: boolean;
  37167. /**
  37168. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37169. */
  37170. keysHeightOffsetModifierCtrl: boolean;
  37171. /**
  37172. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37173. */
  37174. keysHeightOffsetModifierShift: boolean;
  37175. /**
  37176. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37177. */
  37178. keysRotationOffsetIncr: number[];
  37179. /**
  37180. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37181. */
  37182. keysRotationOffsetDecr: number[];
  37183. /**
  37184. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37185. */
  37186. keysRotationOffsetModifierAlt: boolean;
  37187. /**
  37188. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37189. */
  37190. keysRotationOffsetModifierCtrl: boolean;
  37191. /**
  37192. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37193. */
  37194. keysRotationOffsetModifierShift: boolean;
  37195. /**
  37196. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37197. */
  37198. keysRadiusIncr: number[];
  37199. /**
  37200. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37201. */
  37202. keysRadiusDecr: number[];
  37203. /**
  37204. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37205. */
  37206. keysRadiusModifierAlt: boolean;
  37207. /**
  37208. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37209. */
  37210. keysRadiusModifierCtrl: boolean;
  37211. /**
  37212. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37213. */
  37214. keysRadiusModifierShift: boolean;
  37215. /**
  37216. * Defines the rate of change of heightOffset.
  37217. */
  37218. heightSensibility: number;
  37219. /**
  37220. * Defines the rate of change of rotationOffset.
  37221. */
  37222. rotationSensibility: number;
  37223. /**
  37224. * Defines the rate of change of radius.
  37225. */
  37226. radiusSensibility: number;
  37227. private _keys;
  37228. private _ctrlPressed;
  37229. private _altPressed;
  37230. private _shiftPressed;
  37231. private _onCanvasBlurObserver;
  37232. private _onKeyboardObserver;
  37233. private _engine;
  37234. private _scene;
  37235. /**
  37236. * Attach the input controls to a specific dom element to get the input from.
  37237. * @param element Defines the element the controls should be listened from
  37238. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37239. */
  37240. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37241. /**
  37242. * Detach the current controls from the specified dom element.
  37243. * @param element Defines the element to stop listening the inputs from
  37244. */
  37245. detachControl(element: Nullable<HTMLElement>): void;
  37246. /**
  37247. * Update the current camera state depending on the inputs that have been used this frame.
  37248. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37249. */
  37250. checkInputs(): void;
  37251. /**
  37252. * Gets the class name of the current input.
  37253. * @returns the class name
  37254. */
  37255. getClassName(): string;
  37256. /**
  37257. * Get the friendly name associated with the input class.
  37258. * @returns the input friendly name
  37259. */
  37260. getSimpleName(): string;
  37261. /**
  37262. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37263. * allow modification of the heightOffset value.
  37264. */
  37265. private _modifierHeightOffset;
  37266. /**
  37267. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37268. * allow modification of the rotationOffset value.
  37269. */
  37270. private _modifierRotationOffset;
  37271. /**
  37272. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37273. * allow modification of the radius value.
  37274. */
  37275. private _modifierRadius;
  37276. }
  37277. }
  37278. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  37279. import { Nullable } from "babylonjs/types";
  37280. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37281. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37282. module "babylonjs/Cameras/freeCameraInputsManager" {
  37283. interface FreeCameraInputsManager {
  37284. /**
  37285. * Add orientation input support to the input manager.
  37286. * @returns the current input manager
  37287. */
  37288. addDeviceOrientation(): FreeCameraInputsManager;
  37289. }
  37290. }
  37291. /**
  37292. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37293. * Screen rotation is taken into account.
  37294. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37295. */
  37296. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37297. private _camera;
  37298. private _screenOrientationAngle;
  37299. private _constantTranform;
  37300. private _screenQuaternion;
  37301. private _alpha;
  37302. private _beta;
  37303. private _gamma;
  37304. /**
  37305. * Instantiates a new input
  37306. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37307. */
  37308. constructor();
  37309. /**
  37310. * Define the camera controlled by the input.
  37311. */
  37312. camera: FreeCamera;
  37313. /**
  37314. * Attach the input controls to a specific dom element to get the input from.
  37315. * @param element Defines the element the controls should be listened from
  37316. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37317. */
  37318. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37319. private _orientationChanged;
  37320. private _deviceOrientation;
  37321. /**
  37322. * Detach the current controls from the specified dom element.
  37323. * @param element Defines the element to stop listening the inputs from
  37324. */
  37325. detachControl(element: Nullable<HTMLElement>): void;
  37326. /**
  37327. * Update the current camera state depending on the inputs that have been used this frame.
  37328. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37329. */
  37330. checkInputs(): void;
  37331. /**
  37332. * Gets the class name of the current intput.
  37333. * @returns the class name
  37334. */
  37335. getClassName(): string;
  37336. /**
  37337. * Get the friendly name associated with the input class.
  37338. * @returns the input friendly name
  37339. */
  37340. getSimpleName(): string;
  37341. }
  37342. }
  37343. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  37344. import { Nullable } from "babylonjs/types";
  37345. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37346. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37347. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37348. /**
  37349. * Manage the gamepad inputs to control a free camera.
  37350. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37351. */
  37352. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37353. /**
  37354. * Define the camera the input is attached to.
  37355. */
  37356. camera: FreeCamera;
  37357. /**
  37358. * Define the Gamepad controlling the input
  37359. */
  37360. gamepad: Nullable<Gamepad>;
  37361. /**
  37362. * Defines the gamepad rotation sensiblity.
  37363. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37364. */
  37365. gamepadAngularSensibility: number;
  37366. /**
  37367. * Defines the gamepad move sensiblity.
  37368. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37369. */
  37370. gamepadMoveSensibility: number;
  37371. private _onGamepadConnectedObserver;
  37372. private _onGamepadDisconnectedObserver;
  37373. private _cameraTransform;
  37374. private _deltaTransform;
  37375. private _vector3;
  37376. private _vector2;
  37377. /**
  37378. * Attach the input controls to a specific dom element to get the input from.
  37379. * @param element Defines the element the controls should be listened from
  37380. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37381. */
  37382. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37383. /**
  37384. * Detach the current controls from the specified dom element.
  37385. * @param element Defines the element to stop listening the inputs from
  37386. */
  37387. detachControl(element: Nullable<HTMLElement>): void;
  37388. /**
  37389. * Update the current camera state depending on the inputs that have been used this frame.
  37390. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37391. */
  37392. checkInputs(): void;
  37393. /**
  37394. * Gets the class name of the current intput.
  37395. * @returns the class name
  37396. */
  37397. getClassName(): string;
  37398. /**
  37399. * Get the friendly name associated with the input class.
  37400. * @returns the input friendly name
  37401. */
  37402. getSimpleName(): string;
  37403. }
  37404. }
  37405. declare module "babylonjs/Misc/virtualJoystick" {
  37406. import { Nullable } from "babylonjs/types";
  37407. import { Vector3 } from "babylonjs/Maths/math";
  37408. /**
  37409. * Defines the potential axis of a Joystick
  37410. */
  37411. export enum JoystickAxis {
  37412. /** X axis */
  37413. X = 0,
  37414. /** Y axis */
  37415. Y = 1,
  37416. /** Z axis */
  37417. Z = 2
  37418. }
  37419. /**
  37420. * Class used to define virtual joystick (used in touch mode)
  37421. */
  37422. export class VirtualJoystick {
  37423. /**
  37424. * Gets or sets a boolean indicating that left and right values must be inverted
  37425. */
  37426. reverseLeftRight: boolean;
  37427. /**
  37428. * Gets or sets a boolean indicating that up and down values must be inverted
  37429. */
  37430. reverseUpDown: boolean;
  37431. /**
  37432. * Gets the offset value for the position (ie. the change of the position value)
  37433. */
  37434. deltaPosition: Vector3;
  37435. /**
  37436. * Gets a boolean indicating if the virtual joystick was pressed
  37437. */
  37438. pressed: boolean;
  37439. /**
  37440. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37441. */
  37442. static Canvas: Nullable<HTMLCanvasElement>;
  37443. private static _globalJoystickIndex;
  37444. private static vjCanvasContext;
  37445. private static vjCanvasWidth;
  37446. private static vjCanvasHeight;
  37447. private static halfWidth;
  37448. private _action;
  37449. private _axisTargetedByLeftAndRight;
  37450. private _axisTargetedByUpAndDown;
  37451. private _joystickSensibility;
  37452. private _inversedSensibility;
  37453. private _joystickPointerID;
  37454. private _joystickColor;
  37455. private _joystickPointerPos;
  37456. private _joystickPreviousPointerPos;
  37457. private _joystickPointerStartPos;
  37458. private _deltaJoystickVector;
  37459. private _leftJoystick;
  37460. private _touches;
  37461. private _onPointerDownHandlerRef;
  37462. private _onPointerMoveHandlerRef;
  37463. private _onPointerUpHandlerRef;
  37464. private _onResize;
  37465. /**
  37466. * Creates a new virtual joystick
  37467. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37468. */
  37469. constructor(leftJoystick?: boolean);
  37470. /**
  37471. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37472. * @param newJoystickSensibility defines the new sensibility
  37473. */
  37474. setJoystickSensibility(newJoystickSensibility: number): void;
  37475. private _onPointerDown;
  37476. private _onPointerMove;
  37477. private _onPointerUp;
  37478. /**
  37479. * Change the color of the virtual joystick
  37480. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37481. */
  37482. setJoystickColor(newColor: string): void;
  37483. /**
  37484. * Defines a callback to call when the joystick is touched
  37485. * @param action defines the callback
  37486. */
  37487. setActionOnTouch(action: () => any): void;
  37488. /**
  37489. * Defines which axis you'd like to control for left & right
  37490. * @param axis defines the axis to use
  37491. */
  37492. setAxisForLeftRight(axis: JoystickAxis): void;
  37493. /**
  37494. * Defines which axis you'd like to control for up & down
  37495. * @param axis defines the axis to use
  37496. */
  37497. setAxisForUpDown(axis: JoystickAxis): void;
  37498. private _drawVirtualJoystick;
  37499. /**
  37500. * Release internal HTML canvas
  37501. */
  37502. releaseCanvas(): void;
  37503. }
  37504. }
  37505. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  37506. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  37507. import { Nullable } from "babylonjs/types";
  37508. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37509. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37510. module "babylonjs/Cameras/freeCameraInputsManager" {
  37511. interface FreeCameraInputsManager {
  37512. /**
  37513. * Add virtual joystick input support to the input manager.
  37514. * @returns the current input manager
  37515. */
  37516. addVirtualJoystick(): FreeCameraInputsManager;
  37517. }
  37518. }
  37519. /**
  37520. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37521. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37522. */
  37523. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37524. /**
  37525. * Defines the camera the input is attached to.
  37526. */
  37527. camera: FreeCamera;
  37528. private _leftjoystick;
  37529. private _rightjoystick;
  37530. /**
  37531. * Gets the left stick of the virtual joystick.
  37532. * @returns The virtual Joystick
  37533. */
  37534. getLeftJoystick(): VirtualJoystick;
  37535. /**
  37536. * Gets the right stick of the virtual joystick.
  37537. * @returns The virtual Joystick
  37538. */
  37539. getRightJoystick(): VirtualJoystick;
  37540. /**
  37541. * Update the current camera state depending on the inputs that have been used this frame.
  37542. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37543. */
  37544. checkInputs(): void;
  37545. /**
  37546. * Attach the input controls to a specific dom element to get the input from.
  37547. * @param element Defines the element the controls should be listened from
  37548. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37549. */
  37550. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37551. /**
  37552. * Detach the current controls from the specified dom element.
  37553. * @param element Defines the element to stop listening the inputs from
  37554. */
  37555. detachControl(element: Nullable<HTMLElement>): void;
  37556. /**
  37557. * Gets the class name of the current intput.
  37558. * @returns the class name
  37559. */
  37560. getClassName(): string;
  37561. /**
  37562. * Get the friendly name associated with the input class.
  37563. * @returns the input friendly name
  37564. */
  37565. getSimpleName(): string;
  37566. }
  37567. }
  37568. declare module "babylonjs/Cameras/Inputs/index" {
  37569. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  37570. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  37571. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  37572. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  37573. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  37574. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  37575. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  37576. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  37577. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  37578. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  37579. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  37580. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  37581. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  37582. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  37583. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  37584. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  37585. }
  37586. declare module "babylonjs/Cameras/touchCamera" {
  37587. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37588. import { Scene } from "babylonjs/scene";
  37589. import { Vector3 } from "babylonjs/Maths/math";
  37590. /**
  37591. * This represents a FPS type of camera controlled by touch.
  37592. * This is like a universal camera minus the Gamepad controls.
  37593. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37594. */
  37595. export class TouchCamera extends FreeCamera {
  37596. /**
  37597. * Defines the touch sensibility for rotation.
  37598. * The higher the faster.
  37599. */
  37600. touchAngularSensibility: number;
  37601. /**
  37602. * Defines the touch sensibility for move.
  37603. * The higher the faster.
  37604. */
  37605. touchMoveSensibility: number;
  37606. /**
  37607. * Instantiates a new touch camera.
  37608. * This represents a FPS type of camera controlled by touch.
  37609. * This is like a universal camera minus the Gamepad controls.
  37610. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37611. * @param name Define the name of the camera in the scene
  37612. * @param position Define the start position of the camera in the scene
  37613. * @param scene Define the scene the camera belongs to
  37614. */
  37615. constructor(name: string, position: Vector3, scene: Scene);
  37616. /**
  37617. * Gets the current object class name.
  37618. * @return the class name
  37619. */
  37620. getClassName(): string;
  37621. /** @hidden */
  37622. _setupInputs(): void;
  37623. }
  37624. }
  37625. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  37626. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37627. import { Scene } from "babylonjs/scene";
  37628. import { Vector3, Axis } from "babylonjs/Maths/math";
  37629. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  37630. /**
  37631. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37632. * being tilted forward or back and left or right.
  37633. */
  37634. export class DeviceOrientationCamera extends FreeCamera {
  37635. private _initialQuaternion;
  37636. private _quaternionCache;
  37637. /**
  37638. * Creates a new device orientation camera
  37639. * @param name The name of the camera
  37640. * @param position The start position camera
  37641. * @param scene The scene the camera belongs to
  37642. */
  37643. constructor(name: string, position: Vector3, scene: Scene);
  37644. /**
  37645. * Gets the current instance class name ("DeviceOrientationCamera").
  37646. * This helps avoiding instanceof at run time.
  37647. * @returns the class name
  37648. */
  37649. getClassName(): string;
  37650. /**
  37651. * @hidden
  37652. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37653. */
  37654. _checkInputs(): void;
  37655. /**
  37656. * Reset the camera to its default orientation on the specified axis only.
  37657. * @param axis The axis to reset
  37658. */
  37659. resetToCurrentRotation(axis?: Axis): void;
  37660. }
  37661. }
  37662. declare module "babylonjs/Cameras/universalCamera" {
  37663. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  37664. import { Scene } from "babylonjs/scene";
  37665. import { Vector3 } from "babylonjs/Maths/math";
  37666. /**
  37667. * 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,
  37668. * which still works and will still be found in many Playgrounds.
  37669. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37670. */
  37671. export class UniversalCamera extends TouchCamera {
  37672. /**
  37673. * Defines the gamepad rotation sensiblity.
  37674. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37675. */
  37676. gamepadAngularSensibility: number;
  37677. /**
  37678. * Defines the gamepad move sensiblity.
  37679. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37680. */
  37681. gamepadMoveSensibility: number;
  37682. /**
  37683. * 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,
  37684. * which still works and will still be found in many Playgrounds.
  37685. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37686. * @param name Define the name of the camera in the scene
  37687. * @param position Define the start position of the camera in the scene
  37688. * @param scene Define the scene the camera belongs to
  37689. */
  37690. constructor(name: string, position: Vector3, scene: Scene);
  37691. /**
  37692. * Gets the current object class name.
  37693. * @return the class name
  37694. */
  37695. getClassName(): string;
  37696. }
  37697. }
  37698. declare module "babylonjs/Cameras/gamepadCamera" {
  37699. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37700. import { Scene } from "babylonjs/scene";
  37701. import { Vector3 } from "babylonjs/Maths/math";
  37702. /**
  37703. * This represents a FPS type of camera. This is only here for back compat purpose.
  37704. * Please use the UniversalCamera instead as both are identical.
  37705. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37706. */
  37707. export class GamepadCamera extends UniversalCamera {
  37708. /**
  37709. * Instantiates a new Gamepad Camera
  37710. * This represents a FPS type of camera. This is only here for back compat purpose.
  37711. * Please use the UniversalCamera instead as both are identical.
  37712. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37713. * @param name Define the name of the camera in the scene
  37714. * @param position Define the start position of the camera in the scene
  37715. * @param scene Define the scene the camera belongs to
  37716. */
  37717. constructor(name: string, position: Vector3, scene: Scene);
  37718. /**
  37719. * Gets the current object class name.
  37720. * @return the class name
  37721. */
  37722. getClassName(): string;
  37723. }
  37724. }
  37725. declare module "babylonjs/Shaders/pass.fragment" {
  37726. /** @hidden */
  37727. export var passPixelShader: {
  37728. name: string;
  37729. shader: string;
  37730. };
  37731. }
  37732. declare module "babylonjs/Shaders/passCube.fragment" {
  37733. /** @hidden */
  37734. export var passCubePixelShader: {
  37735. name: string;
  37736. shader: string;
  37737. };
  37738. }
  37739. declare module "babylonjs/PostProcesses/passPostProcess" {
  37740. import { Nullable } from "babylonjs/types";
  37741. import { Camera } from "babylonjs/Cameras/camera";
  37742. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37743. import { Engine } from "babylonjs/Engines/engine";
  37744. import "babylonjs/Shaders/pass.fragment";
  37745. import "babylonjs/Shaders/passCube.fragment";
  37746. /**
  37747. * PassPostProcess which produces an output the same as it's input
  37748. */
  37749. export class PassPostProcess extends PostProcess {
  37750. /**
  37751. * Creates the PassPostProcess
  37752. * @param name The name of the effect.
  37753. * @param options The required width/height ratio to downsize to before computing the render pass.
  37754. * @param camera The camera to apply the render pass to.
  37755. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37756. * @param engine The engine which the post process will be applied. (default: current engine)
  37757. * @param reusable If the post process can be reused on the same frame. (default: false)
  37758. * @param textureType The type of texture to be used when performing the post processing.
  37759. * @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)
  37760. */
  37761. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37762. }
  37763. /**
  37764. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37765. */
  37766. export class PassCubePostProcess extends PostProcess {
  37767. private _face;
  37768. /**
  37769. * Gets or sets the cube face to display.
  37770. * * 0 is +X
  37771. * * 1 is -X
  37772. * * 2 is +Y
  37773. * * 3 is -Y
  37774. * * 4 is +Z
  37775. * * 5 is -Z
  37776. */
  37777. face: number;
  37778. /**
  37779. * Creates the PassCubePostProcess
  37780. * @param name The name of the effect.
  37781. * @param options The required width/height ratio to downsize to before computing the render pass.
  37782. * @param camera The camera to apply the render pass to.
  37783. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37784. * @param engine The engine which the post process will be applied. (default: current engine)
  37785. * @param reusable If the post process can be reused on the same frame. (default: false)
  37786. * @param textureType The type of texture to be used when performing the post processing.
  37787. * @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)
  37788. */
  37789. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37790. }
  37791. }
  37792. declare module "babylonjs/Shaders/anaglyph.fragment" {
  37793. /** @hidden */
  37794. export var anaglyphPixelShader: {
  37795. name: string;
  37796. shader: string;
  37797. };
  37798. }
  37799. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  37800. import { Engine } from "babylonjs/Engines/engine";
  37801. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37802. import { Camera } from "babylonjs/Cameras/camera";
  37803. import "babylonjs/Shaders/anaglyph.fragment";
  37804. /**
  37805. * Postprocess used to generate anaglyphic rendering
  37806. */
  37807. export class AnaglyphPostProcess extends PostProcess {
  37808. private _passedProcess;
  37809. /**
  37810. * Creates a new AnaglyphPostProcess
  37811. * @param name defines postprocess name
  37812. * @param options defines creation options or target ratio scale
  37813. * @param rigCameras defines cameras using this postprocess
  37814. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  37815. * @param engine defines hosting engine
  37816. * @param reusable defines if the postprocess will be reused multiple times per frame
  37817. */
  37818. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  37819. }
  37820. }
  37821. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  37822. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  37823. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37824. import { Scene } from "babylonjs/scene";
  37825. import { Vector3 } from "babylonjs/Maths/math";
  37826. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37827. /**
  37828. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  37829. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37830. */
  37831. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  37832. /**
  37833. * Creates a new AnaglyphArcRotateCamera
  37834. * @param name defines camera name
  37835. * @param alpha defines alpha angle (in radians)
  37836. * @param beta defines beta angle (in radians)
  37837. * @param radius defines radius
  37838. * @param target defines camera target
  37839. * @param interaxialDistance defines distance between each color axis
  37840. * @param scene defines the hosting scene
  37841. */
  37842. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  37843. /**
  37844. * Gets camera class name
  37845. * @returns AnaglyphArcRotateCamera
  37846. */
  37847. getClassName(): string;
  37848. }
  37849. }
  37850. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  37851. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37852. import { Scene } from "babylonjs/scene";
  37853. import { Vector3 } from "babylonjs/Maths/math";
  37854. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37855. /**
  37856. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  37857. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37858. */
  37859. export class AnaglyphFreeCamera extends FreeCamera {
  37860. /**
  37861. * Creates a new AnaglyphFreeCamera
  37862. * @param name defines camera name
  37863. * @param position defines initial position
  37864. * @param interaxialDistance defines distance between each color axis
  37865. * @param scene defines the hosting scene
  37866. */
  37867. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37868. /**
  37869. * Gets camera class name
  37870. * @returns AnaglyphFreeCamera
  37871. */
  37872. getClassName(): string;
  37873. }
  37874. }
  37875. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  37876. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  37877. import { Scene } from "babylonjs/scene";
  37878. import { Vector3 } from "babylonjs/Maths/math";
  37879. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37880. /**
  37881. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  37882. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37883. */
  37884. export class AnaglyphGamepadCamera extends GamepadCamera {
  37885. /**
  37886. * Creates a new AnaglyphGamepadCamera
  37887. * @param name defines camera name
  37888. * @param position defines initial position
  37889. * @param interaxialDistance defines distance between each color axis
  37890. * @param scene defines the hosting scene
  37891. */
  37892. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37893. /**
  37894. * Gets camera class name
  37895. * @returns AnaglyphGamepadCamera
  37896. */
  37897. getClassName(): string;
  37898. }
  37899. }
  37900. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  37901. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37902. import { Scene } from "babylonjs/scene";
  37903. import { Vector3 } from "babylonjs/Maths/math";
  37904. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37905. /**
  37906. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  37907. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37908. */
  37909. export class AnaglyphUniversalCamera extends UniversalCamera {
  37910. /**
  37911. * Creates a new AnaglyphUniversalCamera
  37912. * @param name defines camera name
  37913. * @param position defines initial position
  37914. * @param interaxialDistance defines distance between each color axis
  37915. * @param scene defines the hosting scene
  37916. */
  37917. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37918. /**
  37919. * Gets camera class name
  37920. * @returns AnaglyphUniversalCamera
  37921. */
  37922. getClassName(): string;
  37923. }
  37924. }
  37925. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  37926. /** @hidden */
  37927. export var stereoscopicInterlacePixelShader: {
  37928. name: string;
  37929. shader: string;
  37930. };
  37931. }
  37932. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  37933. import { Camera } from "babylonjs/Cameras/camera";
  37934. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37935. import { Engine } from "babylonjs/Engines/engine";
  37936. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  37937. /**
  37938. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  37939. */
  37940. export class StereoscopicInterlacePostProcess extends PostProcess {
  37941. private _stepSize;
  37942. private _passedProcess;
  37943. /**
  37944. * Initializes a StereoscopicInterlacePostProcess
  37945. * @param name The name of the effect.
  37946. * @param rigCameras The rig cameras to be appled to the post process
  37947. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  37948. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37949. * @param engine The engine which the post process will be applied. (default: current engine)
  37950. * @param reusable If the post process can be reused on the same frame. (default: false)
  37951. */
  37952. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  37953. }
  37954. }
  37955. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  37956. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  37957. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37958. import { Scene } from "babylonjs/scene";
  37959. import { Vector3 } from "babylonjs/Maths/math";
  37960. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37961. /**
  37962. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37963. * @see http://doc.babylonjs.com/features/cameras
  37964. */
  37965. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37966. /**
  37967. * Creates a new StereoscopicArcRotateCamera
  37968. * @param name defines camera name
  37969. * @param alpha defines alpha angle (in radians)
  37970. * @param beta defines beta angle (in radians)
  37971. * @param radius defines radius
  37972. * @param target defines camera target
  37973. * @param interaxialDistance defines distance between each color axis
  37974. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37975. * @param scene defines the hosting scene
  37976. */
  37977. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37978. /**
  37979. * Gets camera class name
  37980. * @returns StereoscopicArcRotateCamera
  37981. */
  37982. getClassName(): string;
  37983. }
  37984. }
  37985. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  37986. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37987. import { Scene } from "babylonjs/scene";
  37988. import { Vector3 } from "babylonjs/Maths/math";
  37989. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37990. /**
  37991. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37992. * @see http://doc.babylonjs.com/features/cameras
  37993. */
  37994. export class StereoscopicFreeCamera extends FreeCamera {
  37995. /**
  37996. * Creates a new StereoscopicFreeCamera
  37997. * @param name defines camera name
  37998. * @param position defines initial position
  37999. * @param interaxialDistance defines distance between each color axis
  38000. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38001. * @param scene defines the hosting scene
  38002. */
  38003. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38004. /**
  38005. * Gets camera class name
  38006. * @returns StereoscopicFreeCamera
  38007. */
  38008. getClassName(): string;
  38009. }
  38010. }
  38011. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  38012. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38013. import { Scene } from "babylonjs/scene";
  38014. import { Vector3 } from "babylonjs/Maths/math";
  38015. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38016. /**
  38017. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38018. * @see http://doc.babylonjs.com/features/cameras
  38019. */
  38020. export class StereoscopicGamepadCamera extends GamepadCamera {
  38021. /**
  38022. * Creates a new StereoscopicGamepadCamera
  38023. * @param name defines camera name
  38024. * @param position defines initial position
  38025. * @param interaxialDistance defines distance between each color axis
  38026. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38027. * @param scene defines the hosting scene
  38028. */
  38029. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38030. /**
  38031. * Gets camera class name
  38032. * @returns StereoscopicGamepadCamera
  38033. */
  38034. getClassName(): string;
  38035. }
  38036. }
  38037. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  38038. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38039. import { Scene } from "babylonjs/scene";
  38040. import { Vector3 } from "babylonjs/Maths/math";
  38041. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38042. /**
  38043. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38044. * @see http://doc.babylonjs.com/features/cameras
  38045. */
  38046. export class StereoscopicUniversalCamera extends UniversalCamera {
  38047. /**
  38048. * Creates a new StereoscopicUniversalCamera
  38049. * @param name defines camera name
  38050. * @param position defines initial position
  38051. * @param interaxialDistance defines distance between each color axis
  38052. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38053. * @param scene defines the hosting scene
  38054. */
  38055. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38056. /**
  38057. * Gets camera class name
  38058. * @returns StereoscopicUniversalCamera
  38059. */
  38060. getClassName(): string;
  38061. }
  38062. }
  38063. declare module "babylonjs/Cameras/Stereoscopic/index" {
  38064. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  38065. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  38066. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  38067. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  38068. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  38069. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  38070. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  38071. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  38072. }
  38073. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  38074. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38075. import { Scene } from "babylonjs/scene";
  38076. import { Vector3 } from "babylonjs/Maths/math";
  38077. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38078. /**
  38079. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38080. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38081. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38082. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38083. */
  38084. export class VirtualJoysticksCamera extends FreeCamera {
  38085. /**
  38086. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38087. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38088. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38089. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38090. * @param name Define the name of the camera in the scene
  38091. * @param position Define the start position of the camera in the scene
  38092. * @param scene Define the scene the camera belongs to
  38093. */
  38094. constructor(name: string, position: Vector3, scene: Scene);
  38095. /**
  38096. * Gets the current object class name.
  38097. * @return the class name
  38098. */
  38099. getClassName(): string;
  38100. }
  38101. }
  38102. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  38103. import { Matrix } from "babylonjs/Maths/math";
  38104. /**
  38105. * This represents all the required metrics to create a VR camera.
  38106. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38107. */
  38108. export class VRCameraMetrics {
  38109. /**
  38110. * Define the horizontal resolution off the screen.
  38111. */
  38112. hResolution: number;
  38113. /**
  38114. * Define the vertical resolution off the screen.
  38115. */
  38116. vResolution: number;
  38117. /**
  38118. * Define the horizontal screen size.
  38119. */
  38120. hScreenSize: number;
  38121. /**
  38122. * Define the vertical screen size.
  38123. */
  38124. vScreenSize: number;
  38125. /**
  38126. * Define the vertical screen center position.
  38127. */
  38128. vScreenCenter: number;
  38129. /**
  38130. * Define the distance of the eyes to the screen.
  38131. */
  38132. eyeToScreenDistance: number;
  38133. /**
  38134. * Define the distance between both lenses
  38135. */
  38136. lensSeparationDistance: number;
  38137. /**
  38138. * Define the distance between both viewer's eyes.
  38139. */
  38140. interpupillaryDistance: number;
  38141. /**
  38142. * Define the distortion factor of the VR postprocess.
  38143. * Please, touch with care.
  38144. */
  38145. distortionK: number[];
  38146. /**
  38147. * Define the chromatic aberration correction factors for the VR post process.
  38148. */
  38149. chromaAbCorrection: number[];
  38150. /**
  38151. * Define the scale factor of the post process.
  38152. * The smaller the better but the slower.
  38153. */
  38154. postProcessScaleFactor: number;
  38155. /**
  38156. * Define an offset for the lens center.
  38157. */
  38158. lensCenterOffset: number;
  38159. /**
  38160. * Define if the current vr camera should compensate the distortion of the lense or not.
  38161. */
  38162. compensateDistortion: boolean;
  38163. /**
  38164. * Gets the rendering aspect ratio based on the provided resolutions.
  38165. */
  38166. readonly aspectRatio: number;
  38167. /**
  38168. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38169. */
  38170. readonly aspectRatioFov: number;
  38171. /**
  38172. * @hidden
  38173. */
  38174. readonly leftHMatrix: Matrix;
  38175. /**
  38176. * @hidden
  38177. */
  38178. readonly rightHMatrix: Matrix;
  38179. /**
  38180. * @hidden
  38181. */
  38182. readonly leftPreViewMatrix: Matrix;
  38183. /**
  38184. * @hidden
  38185. */
  38186. readonly rightPreViewMatrix: Matrix;
  38187. /**
  38188. * Get the default VRMetrics based on the most generic setup.
  38189. * @returns the default vr metrics
  38190. */
  38191. static GetDefault(): VRCameraMetrics;
  38192. }
  38193. }
  38194. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  38195. /** @hidden */
  38196. export var vrDistortionCorrectionPixelShader: {
  38197. name: string;
  38198. shader: string;
  38199. };
  38200. }
  38201. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  38202. import { Camera } from "babylonjs/Cameras/camera";
  38203. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38204. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38205. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  38206. /**
  38207. * VRDistortionCorrectionPostProcess used for mobile VR
  38208. */
  38209. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38210. private _isRightEye;
  38211. private _distortionFactors;
  38212. private _postProcessScaleFactor;
  38213. private _lensCenterOffset;
  38214. private _scaleIn;
  38215. private _scaleFactor;
  38216. private _lensCenter;
  38217. /**
  38218. * Initializes the VRDistortionCorrectionPostProcess
  38219. * @param name The name of the effect.
  38220. * @param camera The camera to apply the render pass to.
  38221. * @param isRightEye If this is for the right eye distortion
  38222. * @param vrMetrics All the required metrics for the VR camera
  38223. */
  38224. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38225. }
  38226. }
  38227. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  38228. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  38229. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38230. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38231. import { Scene } from "babylonjs/scene";
  38232. import { Vector3 } from "babylonjs/Maths/math";
  38233. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38234. import "babylonjs/Cameras/RigModes/vrRigMode";
  38235. /**
  38236. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38237. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38238. */
  38239. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38240. /**
  38241. * Creates a new VRDeviceOrientationArcRotateCamera
  38242. * @param name defines camera name
  38243. * @param alpha defines the camera rotation along the logitudinal axis
  38244. * @param beta defines the camera rotation along the latitudinal axis
  38245. * @param radius defines the camera distance from its target
  38246. * @param target defines the camera target
  38247. * @param scene defines the scene the camera belongs to
  38248. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38249. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38250. */
  38251. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38252. /**
  38253. * Gets camera class name
  38254. * @returns VRDeviceOrientationArcRotateCamera
  38255. */
  38256. getClassName(): string;
  38257. }
  38258. }
  38259. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  38260. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  38261. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38262. import { Scene } from "babylonjs/scene";
  38263. import { Vector3 } from "babylonjs/Maths/math";
  38264. import "babylonjs/Cameras/RigModes/vrRigMode";
  38265. /**
  38266. * Camera used to simulate VR rendering (based on FreeCamera)
  38267. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38268. */
  38269. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38270. /**
  38271. * Creates a new VRDeviceOrientationFreeCamera
  38272. * @param name defines camera name
  38273. * @param position defines the start position of the camera
  38274. * @param scene defines the scene the camera belongs to
  38275. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38276. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38277. */
  38278. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38279. /**
  38280. * Gets camera class name
  38281. * @returns VRDeviceOrientationFreeCamera
  38282. */
  38283. getClassName(): string;
  38284. }
  38285. }
  38286. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  38287. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  38288. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38289. import { Scene } from "babylonjs/scene";
  38290. import { Vector3 } from "babylonjs/Maths/math";
  38291. /**
  38292. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38293. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38294. */
  38295. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38296. /**
  38297. * Creates a new VRDeviceOrientationGamepadCamera
  38298. * @param name defines camera name
  38299. * @param position defines the start position of the camera
  38300. * @param scene defines the scene the camera belongs to
  38301. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38302. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38303. */
  38304. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38305. /**
  38306. * Gets camera class name
  38307. * @returns VRDeviceOrientationGamepadCamera
  38308. */
  38309. getClassName(): string;
  38310. }
  38311. }
  38312. declare module "babylonjs/Gamepads/xboxGamepad" {
  38313. import { Observable } from "babylonjs/Misc/observable";
  38314. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38315. /**
  38316. * Defines supported buttons for XBox360 compatible gamepads
  38317. */
  38318. export enum Xbox360Button {
  38319. /** A */
  38320. A = 0,
  38321. /** B */
  38322. B = 1,
  38323. /** X */
  38324. X = 2,
  38325. /** Y */
  38326. Y = 3,
  38327. /** Start */
  38328. Start = 4,
  38329. /** Back */
  38330. Back = 5,
  38331. /** Left button */
  38332. LB = 6,
  38333. /** Right button */
  38334. RB = 7,
  38335. /** Left stick */
  38336. LeftStick = 8,
  38337. /** Right stick */
  38338. RightStick = 9
  38339. }
  38340. /** Defines values for XBox360 DPad */
  38341. export enum Xbox360Dpad {
  38342. /** Up */
  38343. Up = 0,
  38344. /** Down */
  38345. Down = 1,
  38346. /** Left */
  38347. Left = 2,
  38348. /** Right */
  38349. Right = 3
  38350. }
  38351. /**
  38352. * Defines a XBox360 gamepad
  38353. */
  38354. export class Xbox360Pad extends Gamepad {
  38355. private _leftTrigger;
  38356. private _rightTrigger;
  38357. private _onlefttriggerchanged;
  38358. private _onrighttriggerchanged;
  38359. private _onbuttondown;
  38360. private _onbuttonup;
  38361. private _ondpaddown;
  38362. private _ondpadup;
  38363. /** Observable raised when a button is pressed */
  38364. onButtonDownObservable: Observable<Xbox360Button>;
  38365. /** Observable raised when a button is released */
  38366. onButtonUpObservable: Observable<Xbox360Button>;
  38367. /** Observable raised when a pad is pressed */
  38368. onPadDownObservable: Observable<Xbox360Dpad>;
  38369. /** Observable raised when a pad is released */
  38370. onPadUpObservable: Observable<Xbox360Dpad>;
  38371. private _buttonA;
  38372. private _buttonB;
  38373. private _buttonX;
  38374. private _buttonY;
  38375. private _buttonBack;
  38376. private _buttonStart;
  38377. private _buttonLB;
  38378. private _buttonRB;
  38379. private _buttonLeftStick;
  38380. private _buttonRightStick;
  38381. private _dPadUp;
  38382. private _dPadDown;
  38383. private _dPadLeft;
  38384. private _dPadRight;
  38385. private _isXboxOnePad;
  38386. /**
  38387. * Creates a new XBox360 gamepad object
  38388. * @param id defines the id of this gamepad
  38389. * @param index defines its index
  38390. * @param gamepad defines the internal HTML gamepad object
  38391. * @param xboxOne defines if it is a XBox One gamepad
  38392. */
  38393. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38394. /**
  38395. * Defines the callback to call when left trigger is pressed
  38396. * @param callback defines the callback to use
  38397. */
  38398. onlefttriggerchanged(callback: (value: number) => void): void;
  38399. /**
  38400. * Defines the callback to call when right trigger is pressed
  38401. * @param callback defines the callback to use
  38402. */
  38403. onrighttriggerchanged(callback: (value: number) => void): void;
  38404. /**
  38405. * Gets the left trigger value
  38406. */
  38407. /**
  38408. * Sets the left trigger value
  38409. */
  38410. leftTrigger: number;
  38411. /**
  38412. * Gets the right trigger value
  38413. */
  38414. /**
  38415. * Sets the right trigger value
  38416. */
  38417. rightTrigger: number;
  38418. /**
  38419. * Defines the callback to call when a button is pressed
  38420. * @param callback defines the callback to use
  38421. */
  38422. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38423. /**
  38424. * Defines the callback to call when a button is released
  38425. * @param callback defines the callback to use
  38426. */
  38427. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38428. /**
  38429. * Defines the callback to call when a pad is pressed
  38430. * @param callback defines the callback to use
  38431. */
  38432. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38433. /**
  38434. * Defines the callback to call when a pad is released
  38435. * @param callback defines the callback to use
  38436. */
  38437. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38438. private _setButtonValue;
  38439. private _setDPadValue;
  38440. /**
  38441. * Gets the value of the `A` button
  38442. */
  38443. /**
  38444. * Sets the value of the `A` button
  38445. */
  38446. buttonA: number;
  38447. /**
  38448. * Gets the value of the `B` button
  38449. */
  38450. /**
  38451. * Sets the value of the `B` button
  38452. */
  38453. buttonB: number;
  38454. /**
  38455. * Gets the value of the `X` button
  38456. */
  38457. /**
  38458. * Sets the value of the `X` button
  38459. */
  38460. buttonX: number;
  38461. /**
  38462. * Gets the value of the `Y` button
  38463. */
  38464. /**
  38465. * Sets the value of the `Y` button
  38466. */
  38467. buttonY: number;
  38468. /**
  38469. * Gets the value of the `Start` button
  38470. */
  38471. /**
  38472. * Sets the value of the `Start` button
  38473. */
  38474. buttonStart: number;
  38475. /**
  38476. * Gets the value of the `Back` button
  38477. */
  38478. /**
  38479. * Sets the value of the `Back` button
  38480. */
  38481. buttonBack: number;
  38482. /**
  38483. * Gets the value of the `Left` button
  38484. */
  38485. /**
  38486. * Sets the value of the `Left` button
  38487. */
  38488. buttonLB: number;
  38489. /**
  38490. * Gets the value of the `Right` button
  38491. */
  38492. /**
  38493. * Sets the value of the `Right` button
  38494. */
  38495. buttonRB: number;
  38496. /**
  38497. * Gets the value of the Left joystick
  38498. */
  38499. /**
  38500. * Sets the value of the Left joystick
  38501. */
  38502. buttonLeftStick: number;
  38503. /**
  38504. * Gets the value of the Right joystick
  38505. */
  38506. /**
  38507. * Sets the value of the Right joystick
  38508. */
  38509. buttonRightStick: number;
  38510. /**
  38511. * Gets the value of D-pad up
  38512. */
  38513. /**
  38514. * Sets the value of D-pad up
  38515. */
  38516. dPadUp: number;
  38517. /**
  38518. * Gets the value of D-pad down
  38519. */
  38520. /**
  38521. * Sets the value of D-pad down
  38522. */
  38523. dPadDown: number;
  38524. /**
  38525. * Gets the value of D-pad left
  38526. */
  38527. /**
  38528. * Sets the value of D-pad left
  38529. */
  38530. dPadLeft: number;
  38531. /**
  38532. * Gets the value of D-pad right
  38533. */
  38534. /**
  38535. * Sets the value of D-pad right
  38536. */
  38537. dPadRight: number;
  38538. /**
  38539. * Force the gamepad to synchronize with device values
  38540. */
  38541. update(): void;
  38542. /**
  38543. * Disposes the gamepad
  38544. */
  38545. dispose(): void;
  38546. }
  38547. }
  38548. declare module "babylonjs/Materials/pushMaterial" {
  38549. import { Nullable } from "babylonjs/types";
  38550. import { Scene } from "babylonjs/scene";
  38551. import { Matrix } from "babylonjs/Maths/math";
  38552. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38553. import { Mesh } from "babylonjs/Meshes/mesh";
  38554. import { Material } from "babylonjs/Materials/material";
  38555. import { Effect } from "babylonjs/Materials/effect";
  38556. /**
  38557. * Base class of materials working in push mode in babylon JS
  38558. * @hidden
  38559. */
  38560. export class PushMaterial extends Material {
  38561. protected _activeEffect: Effect;
  38562. protected _normalMatrix: Matrix;
  38563. /**
  38564. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38565. * This means that the material can keep using a previous shader while a new one is being compiled.
  38566. * This is mostly used when shader parallel compilation is supported (true by default)
  38567. */
  38568. allowShaderHotSwapping: boolean;
  38569. constructor(name: string, scene: Scene);
  38570. getEffect(): Effect;
  38571. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38572. /**
  38573. * Binds the given world matrix to the active effect
  38574. *
  38575. * @param world the matrix to bind
  38576. */
  38577. bindOnlyWorldMatrix(world: Matrix): void;
  38578. /**
  38579. * Binds the given normal matrix to the active effect
  38580. *
  38581. * @param normalMatrix the matrix to bind
  38582. */
  38583. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38584. bind(world: Matrix, mesh?: Mesh): void;
  38585. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38586. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38587. }
  38588. }
  38589. declare module "babylonjs/Materials/materialFlags" {
  38590. /**
  38591. * This groups all the flags used to control the materials channel.
  38592. */
  38593. export class MaterialFlags {
  38594. private static _DiffuseTextureEnabled;
  38595. /**
  38596. * Are diffuse textures enabled in the application.
  38597. */
  38598. static DiffuseTextureEnabled: boolean;
  38599. private static _AmbientTextureEnabled;
  38600. /**
  38601. * Are ambient textures enabled in the application.
  38602. */
  38603. static AmbientTextureEnabled: boolean;
  38604. private static _OpacityTextureEnabled;
  38605. /**
  38606. * Are opacity textures enabled in the application.
  38607. */
  38608. static OpacityTextureEnabled: boolean;
  38609. private static _ReflectionTextureEnabled;
  38610. /**
  38611. * Are reflection textures enabled in the application.
  38612. */
  38613. static ReflectionTextureEnabled: boolean;
  38614. private static _EmissiveTextureEnabled;
  38615. /**
  38616. * Are emissive textures enabled in the application.
  38617. */
  38618. static EmissiveTextureEnabled: boolean;
  38619. private static _SpecularTextureEnabled;
  38620. /**
  38621. * Are specular textures enabled in the application.
  38622. */
  38623. static SpecularTextureEnabled: boolean;
  38624. private static _BumpTextureEnabled;
  38625. /**
  38626. * Are bump textures enabled in the application.
  38627. */
  38628. static BumpTextureEnabled: boolean;
  38629. private static _LightmapTextureEnabled;
  38630. /**
  38631. * Are lightmap textures enabled in the application.
  38632. */
  38633. static LightmapTextureEnabled: boolean;
  38634. private static _RefractionTextureEnabled;
  38635. /**
  38636. * Are refraction textures enabled in the application.
  38637. */
  38638. static RefractionTextureEnabled: boolean;
  38639. private static _ColorGradingTextureEnabled;
  38640. /**
  38641. * Are color grading textures enabled in the application.
  38642. */
  38643. static ColorGradingTextureEnabled: boolean;
  38644. private static _FresnelEnabled;
  38645. /**
  38646. * Are fresnels enabled in the application.
  38647. */
  38648. static FresnelEnabled: boolean;
  38649. private static _ClearCoatTextureEnabled;
  38650. /**
  38651. * Are clear coat textures enabled in the application.
  38652. */
  38653. static ClearCoatTextureEnabled: boolean;
  38654. private static _ClearCoatBumpTextureEnabled;
  38655. /**
  38656. * Are clear coat bump textures enabled in the application.
  38657. */
  38658. static ClearCoatBumpTextureEnabled: boolean;
  38659. private static _ClearCoatTintTextureEnabled;
  38660. /**
  38661. * Are clear coat tint textures enabled in the application.
  38662. */
  38663. static ClearCoatTintTextureEnabled: boolean;
  38664. private static _SheenTextureEnabled;
  38665. /**
  38666. * Are sheen textures enabled in the application.
  38667. */
  38668. static SheenTextureEnabled: boolean;
  38669. private static _AnisotropicTextureEnabled;
  38670. /**
  38671. * Are anisotropic textures enabled in the application.
  38672. */
  38673. static AnisotropicTextureEnabled: boolean;
  38674. }
  38675. }
  38676. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  38677. /** @hidden */
  38678. export var defaultFragmentDeclaration: {
  38679. name: string;
  38680. shader: string;
  38681. };
  38682. }
  38683. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  38684. /** @hidden */
  38685. export var defaultUboDeclaration: {
  38686. name: string;
  38687. shader: string;
  38688. };
  38689. }
  38690. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  38691. /** @hidden */
  38692. export var lightFragmentDeclaration: {
  38693. name: string;
  38694. shader: string;
  38695. };
  38696. }
  38697. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  38698. /** @hidden */
  38699. export var lightUboDeclaration: {
  38700. name: string;
  38701. shader: string;
  38702. };
  38703. }
  38704. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  38705. /** @hidden */
  38706. export var lightsFragmentFunctions: {
  38707. name: string;
  38708. shader: string;
  38709. };
  38710. }
  38711. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  38712. /** @hidden */
  38713. export var shadowsFragmentFunctions: {
  38714. name: string;
  38715. shader: string;
  38716. };
  38717. }
  38718. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  38719. /** @hidden */
  38720. export var fresnelFunction: {
  38721. name: string;
  38722. shader: string;
  38723. };
  38724. }
  38725. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  38726. /** @hidden */
  38727. export var reflectionFunction: {
  38728. name: string;
  38729. shader: string;
  38730. };
  38731. }
  38732. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  38733. /** @hidden */
  38734. export var bumpFragmentFunctions: {
  38735. name: string;
  38736. shader: string;
  38737. };
  38738. }
  38739. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  38740. /** @hidden */
  38741. export var logDepthDeclaration: {
  38742. name: string;
  38743. shader: string;
  38744. };
  38745. }
  38746. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  38747. /** @hidden */
  38748. export var bumpFragment: {
  38749. name: string;
  38750. shader: string;
  38751. };
  38752. }
  38753. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  38754. /** @hidden */
  38755. export var depthPrePass: {
  38756. name: string;
  38757. shader: string;
  38758. };
  38759. }
  38760. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  38761. /** @hidden */
  38762. export var lightFragment: {
  38763. name: string;
  38764. shader: string;
  38765. };
  38766. }
  38767. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  38768. /** @hidden */
  38769. export var logDepthFragment: {
  38770. name: string;
  38771. shader: string;
  38772. };
  38773. }
  38774. declare module "babylonjs/Shaders/default.fragment" {
  38775. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  38776. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38777. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38778. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38779. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38780. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  38781. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  38782. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  38783. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  38784. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  38785. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  38786. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  38787. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  38788. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38789. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  38790. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  38791. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  38792. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  38793. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  38794. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  38795. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  38796. /** @hidden */
  38797. export var defaultPixelShader: {
  38798. name: string;
  38799. shader: string;
  38800. };
  38801. }
  38802. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  38803. /** @hidden */
  38804. export var defaultVertexDeclaration: {
  38805. name: string;
  38806. shader: string;
  38807. };
  38808. }
  38809. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  38810. /** @hidden */
  38811. export var bumpVertexDeclaration: {
  38812. name: string;
  38813. shader: string;
  38814. };
  38815. }
  38816. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  38817. /** @hidden */
  38818. export var bumpVertex: {
  38819. name: string;
  38820. shader: string;
  38821. };
  38822. }
  38823. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  38824. /** @hidden */
  38825. export var fogVertex: {
  38826. name: string;
  38827. shader: string;
  38828. };
  38829. }
  38830. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  38831. /** @hidden */
  38832. export var shadowsVertex: {
  38833. name: string;
  38834. shader: string;
  38835. };
  38836. }
  38837. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  38838. /** @hidden */
  38839. export var pointCloudVertex: {
  38840. name: string;
  38841. shader: string;
  38842. };
  38843. }
  38844. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  38845. /** @hidden */
  38846. export var logDepthVertex: {
  38847. name: string;
  38848. shader: string;
  38849. };
  38850. }
  38851. declare module "babylonjs/Shaders/default.vertex" {
  38852. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  38853. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38854. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38855. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  38856. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  38857. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  38858. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  38859. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  38860. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38861. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38862. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  38863. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  38864. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38865. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  38866. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  38867. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  38868. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  38869. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  38870. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  38871. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  38872. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  38873. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  38874. /** @hidden */
  38875. export var defaultVertexShader: {
  38876. name: string;
  38877. shader: string;
  38878. };
  38879. }
  38880. declare module "babylonjs/Materials/standardMaterial" {
  38881. import { SmartArray } from "babylonjs/Misc/smartArray";
  38882. import { IAnimatable } from "babylonjs/Misc/tools";
  38883. import { Nullable } from "babylonjs/types";
  38884. import { Scene } from "babylonjs/scene";
  38885. import { Matrix, Color3 } from "babylonjs/Maths/math";
  38886. import { SubMesh } from "babylonjs/Meshes/subMesh";
  38887. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38888. import { Mesh } from "babylonjs/Meshes/mesh";
  38889. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  38890. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  38891. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  38892. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  38893. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  38894. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38895. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38896. import "babylonjs/Shaders/default.fragment";
  38897. import "babylonjs/Shaders/default.vertex";
  38898. /** @hidden */
  38899. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38900. MAINUV1: boolean;
  38901. MAINUV2: boolean;
  38902. DIFFUSE: boolean;
  38903. DIFFUSEDIRECTUV: number;
  38904. AMBIENT: boolean;
  38905. AMBIENTDIRECTUV: number;
  38906. OPACITY: boolean;
  38907. OPACITYDIRECTUV: number;
  38908. OPACITYRGB: boolean;
  38909. REFLECTION: boolean;
  38910. EMISSIVE: boolean;
  38911. EMISSIVEDIRECTUV: number;
  38912. SPECULAR: boolean;
  38913. SPECULARDIRECTUV: number;
  38914. BUMP: boolean;
  38915. BUMPDIRECTUV: number;
  38916. PARALLAX: boolean;
  38917. PARALLAXOCCLUSION: boolean;
  38918. SPECULAROVERALPHA: boolean;
  38919. CLIPPLANE: boolean;
  38920. CLIPPLANE2: boolean;
  38921. CLIPPLANE3: boolean;
  38922. CLIPPLANE4: boolean;
  38923. ALPHATEST: boolean;
  38924. DEPTHPREPASS: boolean;
  38925. ALPHAFROMDIFFUSE: boolean;
  38926. POINTSIZE: boolean;
  38927. FOG: boolean;
  38928. SPECULARTERM: boolean;
  38929. DIFFUSEFRESNEL: boolean;
  38930. OPACITYFRESNEL: boolean;
  38931. REFLECTIONFRESNEL: boolean;
  38932. REFRACTIONFRESNEL: boolean;
  38933. EMISSIVEFRESNEL: boolean;
  38934. FRESNEL: boolean;
  38935. NORMAL: boolean;
  38936. UV1: boolean;
  38937. UV2: boolean;
  38938. VERTEXCOLOR: boolean;
  38939. VERTEXALPHA: boolean;
  38940. NUM_BONE_INFLUENCERS: number;
  38941. BonesPerMesh: number;
  38942. BONETEXTURE: boolean;
  38943. INSTANCES: boolean;
  38944. GLOSSINESS: boolean;
  38945. ROUGHNESS: boolean;
  38946. EMISSIVEASILLUMINATION: boolean;
  38947. LINKEMISSIVEWITHDIFFUSE: boolean;
  38948. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38949. LIGHTMAP: boolean;
  38950. LIGHTMAPDIRECTUV: number;
  38951. OBJECTSPACE_NORMALMAP: boolean;
  38952. USELIGHTMAPASSHADOWMAP: boolean;
  38953. REFLECTIONMAP_3D: boolean;
  38954. REFLECTIONMAP_SPHERICAL: boolean;
  38955. REFLECTIONMAP_PLANAR: boolean;
  38956. REFLECTIONMAP_CUBIC: boolean;
  38957. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38958. REFLECTIONMAP_PROJECTION: boolean;
  38959. REFLECTIONMAP_SKYBOX: boolean;
  38960. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38961. REFLECTIONMAP_EXPLICIT: boolean;
  38962. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38963. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38964. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38965. INVERTCUBICMAP: boolean;
  38966. LOGARITHMICDEPTH: boolean;
  38967. REFRACTION: boolean;
  38968. REFRACTIONMAP_3D: boolean;
  38969. REFLECTIONOVERALPHA: boolean;
  38970. TWOSIDEDLIGHTING: boolean;
  38971. SHADOWFLOAT: boolean;
  38972. MORPHTARGETS: boolean;
  38973. MORPHTARGETS_NORMAL: boolean;
  38974. MORPHTARGETS_TANGENT: boolean;
  38975. NUM_MORPH_INFLUENCERS: number;
  38976. NONUNIFORMSCALING: boolean;
  38977. PREMULTIPLYALPHA: boolean;
  38978. IMAGEPROCESSING: boolean;
  38979. VIGNETTE: boolean;
  38980. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38981. VIGNETTEBLENDMODEOPAQUE: boolean;
  38982. TONEMAPPING: boolean;
  38983. TONEMAPPING_ACES: boolean;
  38984. CONTRAST: boolean;
  38985. COLORCURVES: boolean;
  38986. COLORGRADING: boolean;
  38987. COLORGRADING3D: boolean;
  38988. SAMPLER3DGREENDEPTH: boolean;
  38989. SAMPLER3DBGRMAP: boolean;
  38990. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38991. /**
  38992. * If the reflection texture on this material is in linear color space
  38993. * @hidden
  38994. */
  38995. IS_REFLECTION_LINEAR: boolean;
  38996. /**
  38997. * If the refraction texture on this material is in linear color space
  38998. * @hidden
  38999. */
  39000. IS_REFRACTION_LINEAR: boolean;
  39001. EXPOSURE: boolean;
  39002. constructor();
  39003. setReflectionMode(modeToEnable: string): void;
  39004. }
  39005. /**
  39006. * This is the default material used in Babylon. It is the best trade off between quality
  39007. * and performances.
  39008. * @see http://doc.babylonjs.com/babylon101/materials
  39009. */
  39010. export class StandardMaterial extends PushMaterial {
  39011. private _diffuseTexture;
  39012. /**
  39013. * The basic texture of the material as viewed under a light.
  39014. */
  39015. diffuseTexture: Nullable<BaseTexture>;
  39016. private _ambientTexture;
  39017. /**
  39018. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39019. */
  39020. ambientTexture: Nullable<BaseTexture>;
  39021. private _opacityTexture;
  39022. /**
  39023. * Define the transparency of the material from a texture.
  39024. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39025. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39026. */
  39027. opacityTexture: Nullable<BaseTexture>;
  39028. private _reflectionTexture;
  39029. /**
  39030. * Define the texture used to display the reflection.
  39031. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39032. */
  39033. reflectionTexture: Nullable<BaseTexture>;
  39034. private _emissiveTexture;
  39035. /**
  39036. * Define texture of the material as if self lit.
  39037. * This will be mixed in the final result even in the absence of light.
  39038. */
  39039. emissiveTexture: Nullable<BaseTexture>;
  39040. private _specularTexture;
  39041. /**
  39042. * Define how the color and intensity of the highlight given by the light in the material.
  39043. */
  39044. specularTexture: Nullable<BaseTexture>;
  39045. private _bumpTexture;
  39046. /**
  39047. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39048. * 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.
  39049. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39050. */
  39051. bumpTexture: Nullable<BaseTexture>;
  39052. private _lightmapTexture;
  39053. /**
  39054. * Complex lighting can be computationally expensive to compute at runtime.
  39055. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39056. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39057. */
  39058. lightmapTexture: Nullable<BaseTexture>;
  39059. private _refractionTexture;
  39060. /**
  39061. * Define the texture used to display the refraction.
  39062. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39063. */
  39064. refractionTexture: Nullable<BaseTexture>;
  39065. /**
  39066. * The color of the material lit by the environmental background lighting.
  39067. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39068. */
  39069. ambientColor: Color3;
  39070. /**
  39071. * The basic color of the material as viewed under a light.
  39072. */
  39073. diffuseColor: Color3;
  39074. /**
  39075. * Define how the color and intensity of the highlight given by the light in the material.
  39076. */
  39077. specularColor: Color3;
  39078. /**
  39079. * Define the color of the material as if self lit.
  39080. * This will be mixed in the final result even in the absence of light.
  39081. */
  39082. emissiveColor: Color3;
  39083. /**
  39084. * Defines how sharp are the highlights in the material.
  39085. * The bigger the value the sharper giving a more glossy feeling to the result.
  39086. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39087. */
  39088. specularPower: number;
  39089. private _useAlphaFromDiffuseTexture;
  39090. /**
  39091. * Does the transparency come from the diffuse texture alpha channel.
  39092. */
  39093. useAlphaFromDiffuseTexture: boolean;
  39094. private _useEmissiveAsIllumination;
  39095. /**
  39096. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39097. */
  39098. useEmissiveAsIllumination: boolean;
  39099. private _linkEmissiveWithDiffuse;
  39100. /**
  39101. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39102. * the emissive level when the final color is close to one.
  39103. */
  39104. linkEmissiveWithDiffuse: boolean;
  39105. private _useSpecularOverAlpha;
  39106. /**
  39107. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39108. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39109. */
  39110. useSpecularOverAlpha: boolean;
  39111. private _useReflectionOverAlpha;
  39112. /**
  39113. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39114. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39115. */
  39116. useReflectionOverAlpha: boolean;
  39117. private _disableLighting;
  39118. /**
  39119. * Does lights from the scene impacts this material.
  39120. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39121. */
  39122. disableLighting: boolean;
  39123. private _useObjectSpaceNormalMap;
  39124. /**
  39125. * Allows using an object space normal map (instead of tangent space).
  39126. */
  39127. useObjectSpaceNormalMap: boolean;
  39128. private _useParallax;
  39129. /**
  39130. * Is parallax enabled or not.
  39131. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39132. */
  39133. useParallax: boolean;
  39134. private _useParallaxOcclusion;
  39135. /**
  39136. * Is parallax occlusion enabled or not.
  39137. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39138. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39139. */
  39140. useParallaxOcclusion: boolean;
  39141. /**
  39142. * 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.
  39143. */
  39144. parallaxScaleBias: number;
  39145. private _roughness;
  39146. /**
  39147. * Helps to define how blurry the reflections should appears in the material.
  39148. */
  39149. roughness: number;
  39150. /**
  39151. * In case of refraction, define the value of the indice of refraction.
  39152. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39153. */
  39154. indexOfRefraction: number;
  39155. /**
  39156. * Invert the refraction texture alongside the y axis.
  39157. * It can be useful with procedural textures or probe for instance.
  39158. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39159. */
  39160. invertRefractionY: boolean;
  39161. /**
  39162. * Defines the alpha limits in alpha test mode.
  39163. */
  39164. alphaCutOff: number;
  39165. private _useLightmapAsShadowmap;
  39166. /**
  39167. * In case of light mapping, define whether the map contains light or shadow informations.
  39168. */
  39169. useLightmapAsShadowmap: boolean;
  39170. private _diffuseFresnelParameters;
  39171. /**
  39172. * Define the diffuse fresnel parameters of the material.
  39173. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39174. */
  39175. diffuseFresnelParameters: FresnelParameters;
  39176. private _opacityFresnelParameters;
  39177. /**
  39178. * Define the opacity fresnel parameters of the material.
  39179. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39180. */
  39181. opacityFresnelParameters: FresnelParameters;
  39182. private _reflectionFresnelParameters;
  39183. /**
  39184. * Define the reflection fresnel parameters of the material.
  39185. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39186. */
  39187. reflectionFresnelParameters: FresnelParameters;
  39188. private _refractionFresnelParameters;
  39189. /**
  39190. * Define the refraction fresnel parameters of the material.
  39191. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39192. */
  39193. refractionFresnelParameters: FresnelParameters;
  39194. private _emissiveFresnelParameters;
  39195. /**
  39196. * Define the emissive fresnel parameters of the material.
  39197. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39198. */
  39199. emissiveFresnelParameters: FresnelParameters;
  39200. private _useReflectionFresnelFromSpecular;
  39201. /**
  39202. * If true automatically deducts the fresnels values from the material specularity.
  39203. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39204. */
  39205. useReflectionFresnelFromSpecular: boolean;
  39206. private _useGlossinessFromSpecularMapAlpha;
  39207. /**
  39208. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39209. */
  39210. useGlossinessFromSpecularMapAlpha: boolean;
  39211. private _maxSimultaneousLights;
  39212. /**
  39213. * Defines the maximum number of lights that can be used in the material
  39214. */
  39215. maxSimultaneousLights: number;
  39216. private _invertNormalMapX;
  39217. /**
  39218. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39219. */
  39220. invertNormalMapX: boolean;
  39221. private _invertNormalMapY;
  39222. /**
  39223. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39224. */
  39225. invertNormalMapY: boolean;
  39226. private _twoSidedLighting;
  39227. /**
  39228. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39229. */
  39230. twoSidedLighting: boolean;
  39231. /**
  39232. * Default configuration related to image processing available in the standard Material.
  39233. */
  39234. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39235. /**
  39236. * Gets the image processing configuration used either in this material.
  39237. */
  39238. /**
  39239. * Sets the Default image processing configuration used either in the this material.
  39240. *
  39241. * If sets to null, the scene one is in use.
  39242. */
  39243. imageProcessingConfiguration: ImageProcessingConfiguration;
  39244. /**
  39245. * Keep track of the image processing observer to allow dispose and replace.
  39246. */
  39247. private _imageProcessingObserver;
  39248. /**
  39249. * Attaches a new image processing configuration to the Standard Material.
  39250. * @param configuration
  39251. */
  39252. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39253. /**
  39254. * Gets wether the color curves effect is enabled.
  39255. */
  39256. /**
  39257. * Sets wether the color curves effect is enabled.
  39258. */
  39259. cameraColorCurvesEnabled: boolean;
  39260. /**
  39261. * Gets wether the color grading effect is enabled.
  39262. */
  39263. /**
  39264. * Gets wether the color grading effect is enabled.
  39265. */
  39266. cameraColorGradingEnabled: boolean;
  39267. /**
  39268. * Gets wether tonemapping is enabled or not.
  39269. */
  39270. /**
  39271. * Sets wether tonemapping is enabled or not
  39272. */
  39273. cameraToneMappingEnabled: boolean;
  39274. /**
  39275. * The camera exposure used on this material.
  39276. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39277. * This corresponds to a photographic exposure.
  39278. */
  39279. /**
  39280. * The camera exposure used on this material.
  39281. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39282. * This corresponds to a photographic exposure.
  39283. */
  39284. cameraExposure: number;
  39285. /**
  39286. * Gets The camera contrast used on this material.
  39287. */
  39288. /**
  39289. * Sets The camera contrast used on this material.
  39290. */
  39291. cameraContrast: number;
  39292. /**
  39293. * Gets the Color Grading 2D Lookup Texture.
  39294. */
  39295. /**
  39296. * Sets the Color Grading 2D Lookup Texture.
  39297. */
  39298. cameraColorGradingTexture: Nullable<BaseTexture>;
  39299. /**
  39300. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39301. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39302. * 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;
  39303. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39304. */
  39305. /**
  39306. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39307. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39308. * 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;
  39309. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39310. */
  39311. cameraColorCurves: Nullable<ColorCurves>;
  39312. /**
  39313. * Custom callback helping to override the default shader used in the material.
  39314. */
  39315. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39316. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39317. protected _worldViewProjectionMatrix: Matrix;
  39318. protected _globalAmbientColor: Color3;
  39319. protected _useLogarithmicDepth: boolean;
  39320. /**
  39321. * Instantiates a new standard material.
  39322. * This is the default material used in Babylon. It is the best trade off between quality
  39323. * and performances.
  39324. * @see http://doc.babylonjs.com/babylon101/materials
  39325. * @param name Define the name of the material in the scene
  39326. * @param scene Define the scene the material belong to
  39327. */
  39328. constructor(name: string, scene: Scene);
  39329. /**
  39330. * Gets a boolean indicating that current material needs to register RTT
  39331. */
  39332. readonly hasRenderTargetTextures: boolean;
  39333. /**
  39334. * Gets the current class name of the material e.g. "StandardMaterial"
  39335. * Mainly use in serialization.
  39336. * @returns the class name
  39337. */
  39338. getClassName(): string;
  39339. /**
  39340. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39341. * You can try switching to logarithmic depth.
  39342. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39343. */
  39344. useLogarithmicDepth: boolean;
  39345. /**
  39346. * Specifies if the material will require alpha blending
  39347. * @returns a boolean specifying if alpha blending is needed
  39348. */
  39349. needAlphaBlending(): boolean;
  39350. /**
  39351. * Specifies if this material should be rendered in alpha test mode
  39352. * @returns a boolean specifying if an alpha test is needed.
  39353. */
  39354. needAlphaTesting(): boolean;
  39355. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39356. /**
  39357. * Get the texture used for alpha test purpose.
  39358. * @returns the diffuse texture in case of the standard material.
  39359. */
  39360. getAlphaTestTexture(): Nullable<BaseTexture>;
  39361. /**
  39362. * Get if the submesh is ready to be used and all its information available.
  39363. * Child classes can use it to update shaders
  39364. * @param mesh defines the mesh to check
  39365. * @param subMesh defines which submesh to check
  39366. * @param useInstances specifies that instances should be used
  39367. * @returns a boolean indicating that the submesh is ready or not
  39368. */
  39369. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39370. /**
  39371. * Builds the material UBO layouts.
  39372. * Used internally during the effect preparation.
  39373. */
  39374. buildUniformLayout(): void;
  39375. /**
  39376. * Unbinds the material from the mesh
  39377. */
  39378. unbind(): void;
  39379. /**
  39380. * Binds the submesh to this material by preparing the effect and shader to draw
  39381. * @param world defines the world transformation matrix
  39382. * @param mesh defines the mesh containing the submesh
  39383. * @param subMesh defines the submesh to bind the material to
  39384. */
  39385. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39386. /**
  39387. * Get the list of animatables in the material.
  39388. * @returns the list of animatables object used in the material
  39389. */
  39390. getAnimatables(): IAnimatable[];
  39391. /**
  39392. * Gets the active textures from the material
  39393. * @returns an array of textures
  39394. */
  39395. getActiveTextures(): BaseTexture[];
  39396. /**
  39397. * Specifies if the material uses a texture
  39398. * @param texture defines the texture to check against the material
  39399. * @returns a boolean specifying if the material uses the texture
  39400. */
  39401. hasTexture(texture: BaseTexture): boolean;
  39402. /**
  39403. * Disposes the material
  39404. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39405. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39406. */
  39407. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39408. /**
  39409. * Makes a duplicate of the material, and gives it a new name
  39410. * @param name defines the new name for the duplicated material
  39411. * @returns the cloned material
  39412. */
  39413. clone(name: string): StandardMaterial;
  39414. /**
  39415. * Serializes this material in a JSON representation
  39416. * @returns the serialized material object
  39417. */
  39418. serialize(): any;
  39419. /**
  39420. * Creates a standard material from parsed material data
  39421. * @param source defines the JSON representation of the material
  39422. * @param scene defines the hosting scene
  39423. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39424. * @returns a new standard material
  39425. */
  39426. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39427. /**
  39428. * Are diffuse textures enabled in the application.
  39429. */
  39430. static DiffuseTextureEnabled: boolean;
  39431. /**
  39432. * Are ambient textures enabled in the application.
  39433. */
  39434. static AmbientTextureEnabled: boolean;
  39435. /**
  39436. * Are opacity textures enabled in the application.
  39437. */
  39438. static OpacityTextureEnabled: boolean;
  39439. /**
  39440. * Are reflection textures enabled in the application.
  39441. */
  39442. static ReflectionTextureEnabled: boolean;
  39443. /**
  39444. * Are emissive textures enabled in the application.
  39445. */
  39446. static EmissiveTextureEnabled: boolean;
  39447. /**
  39448. * Are specular textures enabled in the application.
  39449. */
  39450. static SpecularTextureEnabled: boolean;
  39451. /**
  39452. * Are bump textures enabled in the application.
  39453. */
  39454. static BumpTextureEnabled: boolean;
  39455. /**
  39456. * Are lightmap textures enabled in the application.
  39457. */
  39458. static LightmapTextureEnabled: boolean;
  39459. /**
  39460. * Are refraction textures enabled in the application.
  39461. */
  39462. static RefractionTextureEnabled: boolean;
  39463. /**
  39464. * Are color grading textures enabled in the application.
  39465. */
  39466. static ColorGradingTextureEnabled: boolean;
  39467. /**
  39468. * Are fresnels enabled in the application.
  39469. */
  39470. static FresnelEnabled: boolean;
  39471. }
  39472. }
  39473. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  39474. import { Scene } from "babylonjs/scene";
  39475. import { Texture } from "babylonjs/Materials/Textures/texture";
  39476. /**
  39477. * A class extending Texture allowing drawing on a texture
  39478. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39479. */
  39480. export class DynamicTexture extends Texture {
  39481. private _generateMipMaps;
  39482. private _canvas;
  39483. private _context;
  39484. private _engine;
  39485. /**
  39486. * Creates a DynamicTexture
  39487. * @param name defines the name of the texture
  39488. * @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
  39489. * @param scene defines the scene where you want the texture
  39490. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39491. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39492. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39493. */
  39494. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39495. /**
  39496. * Get the current class name of the texture useful for serialization or dynamic coding.
  39497. * @returns "DynamicTexture"
  39498. */
  39499. getClassName(): string;
  39500. /**
  39501. * Gets the current state of canRescale
  39502. */
  39503. readonly canRescale: boolean;
  39504. private _recreate;
  39505. /**
  39506. * Scales the texture
  39507. * @param ratio the scale factor to apply to both width and height
  39508. */
  39509. scale(ratio: number): void;
  39510. /**
  39511. * Resizes the texture
  39512. * @param width the new width
  39513. * @param height the new height
  39514. */
  39515. scaleTo(width: number, height: number): void;
  39516. /**
  39517. * Gets the context of the canvas used by the texture
  39518. * @returns the canvas context of the dynamic texture
  39519. */
  39520. getContext(): CanvasRenderingContext2D;
  39521. /**
  39522. * Clears the texture
  39523. */
  39524. clear(): void;
  39525. /**
  39526. * Updates the texture
  39527. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39528. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39529. */
  39530. update(invertY?: boolean, premulAlpha?: boolean): void;
  39531. /**
  39532. * Draws text onto the texture
  39533. * @param text defines the text to be drawn
  39534. * @param x defines the placement of the text from the left
  39535. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39536. * @param font defines the font to be used with font-style, font-size, font-name
  39537. * @param color defines the color used for the text
  39538. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39539. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39540. * @param update defines whether texture is immediately update (default is true)
  39541. */
  39542. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39543. /**
  39544. * Clones the texture
  39545. * @returns the clone of the texture.
  39546. */
  39547. clone(): DynamicTexture;
  39548. /**
  39549. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39550. * @returns a serialized dynamic texture object
  39551. */
  39552. serialize(): any;
  39553. /** @hidden */
  39554. _rebuild(): void;
  39555. }
  39556. }
  39557. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  39558. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39559. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39560. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39561. /** @hidden */
  39562. export var imageProcessingPixelShader: {
  39563. name: string;
  39564. shader: string;
  39565. };
  39566. }
  39567. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  39568. import { Nullable } from "babylonjs/types";
  39569. import { Color4 } from "babylonjs/Maths/math";
  39570. import { Camera } from "babylonjs/Cameras/camera";
  39571. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39572. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39573. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39574. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39575. import { Engine } from "babylonjs/Engines/engine";
  39576. import "babylonjs/Shaders/imageProcessing.fragment";
  39577. import "babylonjs/Shaders/postprocess.vertex";
  39578. /**
  39579. * ImageProcessingPostProcess
  39580. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39581. */
  39582. export class ImageProcessingPostProcess extends PostProcess {
  39583. /**
  39584. * Default configuration related to image processing available in the PBR Material.
  39585. */
  39586. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39587. /**
  39588. * Gets the image processing configuration used either in this material.
  39589. */
  39590. /**
  39591. * Sets the Default image processing configuration used either in the this material.
  39592. *
  39593. * If sets to null, the scene one is in use.
  39594. */
  39595. imageProcessingConfiguration: ImageProcessingConfiguration;
  39596. /**
  39597. * Keep track of the image processing observer to allow dispose and replace.
  39598. */
  39599. private _imageProcessingObserver;
  39600. /**
  39601. * Attaches a new image processing configuration to the PBR Material.
  39602. * @param configuration
  39603. */
  39604. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39605. /**
  39606. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39607. */
  39608. /**
  39609. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39610. */
  39611. colorCurves: Nullable<ColorCurves>;
  39612. /**
  39613. * Gets wether the color curves effect is enabled.
  39614. */
  39615. /**
  39616. * Sets wether the color curves effect is enabled.
  39617. */
  39618. colorCurvesEnabled: boolean;
  39619. /**
  39620. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39621. */
  39622. /**
  39623. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39624. */
  39625. colorGradingTexture: Nullable<BaseTexture>;
  39626. /**
  39627. * Gets wether the color grading effect is enabled.
  39628. */
  39629. /**
  39630. * Gets wether the color grading effect is enabled.
  39631. */
  39632. colorGradingEnabled: boolean;
  39633. /**
  39634. * Gets exposure used in the effect.
  39635. */
  39636. /**
  39637. * Sets exposure used in the effect.
  39638. */
  39639. exposure: number;
  39640. /**
  39641. * Gets wether tonemapping is enabled or not.
  39642. */
  39643. /**
  39644. * Sets wether tonemapping is enabled or not
  39645. */
  39646. toneMappingEnabled: boolean;
  39647. /**
  39648. * Gets the type of tone mapping effect.
  39649. */
  39650. /**
  39651. * Sets the type of tone mapping effect.
  39652. */
  39653. toneMappingType: number;
  39654. /**
  39655. * Gets contrast used in the effect.
  39656. */
  39657. /**
  39658. * Sets contrast used in the effect.
  39659. */
  39660. contrast: number;
  39661. /**
  39662. * Gets Vignette stretch size.
  39663. */
  39664. /**
  39665. * Sets Vignette stretch size.
  39666. */
  39667. vignetteStretch: number;
  39668. /**
  39669. * Gets Vignette centre X Offset.
  39670. */
  39671. /**
  39672. * Sets Vignette centre X Offset.
  39673. */
  39674. vignetteCentreX: number;
  39675. /**
  39676. * Gets Vignette centre Y Offset.
  39677. */
  39678. /**
  39679. * Sets Vignette centre Y Offset.
  39680. */
  39681. vignetteCentreY: number;
  39682. /**
  39683. * Gets Vignette weight or intensity of the vignette effect.
  39684. */
  39685. /**
  39686. * Sets Vignette weight or intensity of the vignette effect.
  39687. */
  39688. vignetteWeight: number;
  39689. /**
  39690. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39691. * if vignetteEnabled is set to true.
  39692. */
  39693. /**
  39694. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39695. * if vignetteEnabled is set to true.
  39696. */
  39697. vignetteColor: Color4;
  39698. /**
  39699. * Gets Camera field of view used by the Vignette effect.
  39700. */
  39701. /**
  39702. * Sets Camera field of view used by the Vignette effect.
  39703. */
  39704. vignetteCameraFov: number;
  39705. /**
  39706. * Gets the vignette blend mode allowing different kind of effect.
  39707. */
  39708. /**
  39709. * Sets the vignette blend mode allowing different kind of effect.
  39710. */
  39711. vignetteBlendMode: number;
  39712. /**
  39713. * Gets wether the vignette effect is enabled.
  39714. */
  39715. /**
  39716. * Sets wether the vignette effect is enabled.
  39717. */
  39718. vignetteEnabled: boolean;
  39719. private _fromLinearSpace;
  39720. /**
  39721. * Gets wether the input of the processing is in Gamma or Linear Space.
  39722. */
  39723. /**
  39724. * Sets wether the input of the processing is in Gamma or Linear Space.
  39725. */
  39726. fromLinearSpace: boolean;
  39727. /**
  39728. * Defines cache preventing GC.
  39729. */
  39730. private _defines;
  39731. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39732. /**
  39733. * "ImageProcessingPostProcess"
  39734. * @returns "ImageProcessingPostProcess"
  39735. */
  39736. getClassName(): string;
  39737. protected _updateParameters(): void;
  39738. dispose(camera?: Camera): void;
  39739. }
  39740. }
  39741. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  39742. import { Scene } from "babylonjs/scene";
  39743. import { Color3 } from "babylonjs/Maths/math";
  39744. import { Mesh } from "babylonjs/Meshes/mesh";
  39745. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  39746. /**
  39747. * Class containing static functions to help procedurally build meshes
  39748. */
  39749. export class GroundBuilder {
  39750. /**
  39751. * Creates a ground mesh
  39752. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39753. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39754. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39755. * @param name defines the name of the mesh
  39756. * @param options defines the options used to create the mesh
  39757. * @param scene defines the hosting scene
  39758. * @returns the ground mesh
  39759. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39760. */
  39761. static CreateGround(name: string, options: {
  39762. width?: number;
  39763. height?: number;
  39764. subdivisions?: number;
  39765. subdivisionsX?: number;
  39766. subdivisionsY?: number;
  39767. updatable?: boolean;
  39768. }, scene: any): Mesh;
  39769. /**
  39770. * Creates a tiled ground mesh
  39771. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39772. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39773. * * 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
  39774. * * 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
  39775. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39776. * @param name defines the name of the mesh
  39777. * @param options defines the options used to create the mesh
  39778. * @param scene defines the hosting scene
  39779. * @returns the tiled ground mesh
  39780. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39781. */
  39782. static CreateTiledGround(name: string, options: {
  39783. xmin: number;
  39784. zmin: number;
  39785. xmax: number;
  39786. zmax: number;
  39787. subdivisions?: {
  39788. w: number;
  39789. h: number;
  39790. };
  39791. precision?: {
  39792. w: number;
  39793. h: number;
  39794. };
  39795. updatable?: boolean;
  39796. }, scene: Scene): Mesh;
  39797. /**
  39798. * Creates a ground mesh from a height map
  39799. * * The parameter `url` sets the URL of the height map image resource.
  39800. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39801. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39802. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39803. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39804. * * 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.
  39805. * * 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).
  39806. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39807. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39808. * @param name defines the name of the mesh
  39809. * @param url defines the url to the height map
  39810. * @param options defines the options used to create the mesh
  39811. * @param scene defines the hosting scene
  39812. * @returns the ground mesh
  39813. * @see https://doc.babylonjs.com/babylon101/height_map
  39814. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39815. */
  39816. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39817. width?: number;
  39818. height?: number;
  39819. subdivisions?: number;
  39820. minHeight?: number;
  39821. maxHeight?: number;
  39822. colorFilter?: Color3;
  39823. alphaFilter?: number;
  39824. updatable?: boolean;
  39825. onReady?: (mesh: GroundMesh) => void;
  39826. }, scene: Scene): GroundMesh;
  39827. }
  39828. }
  39829. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  39830. import { Vector4 } from "babylonjs/Maths/math";
  39831. import { Mesh } from "babylonjs/Meshes/mesh";
  39832. /**
  39833. * Class containing static functions to help procedurally build meshes
  39834. */
  39835. export class TorusBuilder {
  39836. /**
  39837. * Creates a torus mesh
  39838. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39839. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39840. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39841. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39842. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39844. * @param name defines the name of the mesh
  39845. * @param options defines the options used to create the mesh
  39846. * @param scene defines the hosting scene
  39847. * @returns the torus mesh
  39848. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39849. */
  39850. static CreateTorus(name: string, options: {
  39851. diameter?: number;
  39852. thickness?: number;
  39853. tessellation?: number;
  39854. updatable?: boolean;
  39855. sideOrientation?: number;
  39856. frontUVs?: Vector4;
  39857. backUVs?: Vector4;
  39858. }, scene: any): Mesh;
  39859. }
  39860. }
  39861. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  39862. import { Color4, Vector4 } from "babylonjs/Maths/math";
  39863. import { Mesh } from "babylonjs/Meshes/mesh";
  39864. /**
  39865. * Class containing static functions to help procedurally build meshes
  39866. */
  39867. export class CylinderBuilder {
  39868. /**
  39869. * Creates a cylinder or a cone mesh
  39870. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39871. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39872. * * 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.
  39873. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39874. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39875. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39876. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39877. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39878. * * 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).
  39879. * * 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
  39880. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39881. * * 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
  39882. * * 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.
  39883. * * If `enclose` is false, a ring surface is one element.
  39884. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39885. * * 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
  39886. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39887. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39889. * @param name defines the name of the mesh
  39890. * @param options defines the options used to create the mesh
  39891. * @param scene defines the hosting scene
  39892. * @returns the cylinder mesh
  39893. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39894. */
  39895. static CreateCylinder(name: string, options: {
  39896. height?: number;
  39897. diameterTop?: number;
  39898. diameterBottom?: number;
  39899. diameter?: number;
  39900. tessellation?: number;
  39901. subdivisions?: number;
  39902. arc?: number;
  39903. faceColors?: Color4[];
  39904. faceUV?: Vector4[];
  39905. updatable?: boolean;
  39906. hasRings?: boolean;
  39907. enclose?: boolean;
  39908. sideOrientation?: number;
  39909. frontUVs?: Vector4;
  39910. backUVs?: Vector4;
  39911. }, scene: any): Mesh;
  39912. }
  39913. }
  39914. declare module "babylonjs/Gamepads/gamepadManager" {
  39915. import { Observable } from "babylonjs/Misc/observable";
  39916. import { Nullable } from "babylonjs/types";
  39917. import { Scene } from "babylonjs/scene";
  39918. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39919. /**
  39920. * Manager for handling gamepads
  39921. */
  39922. export class GamepadManager {
  39923. private _scene?;
  39924. private _babylonGamepads;
  39925. private _oneGamepadConnected;
  39926. /** @hidden */
  39927. _isMonitoring: boolean;
  39928. private _gamepadEventSupported;
  39929. private _gamepadSupport;
  39930. /**
  39931. * observable to be triggered when the gamepad controller has been connected
  39932. */
  39933. onGamepadConnectedObservable: Observable<Gamepad>;
  39934. /**
  39935. * observable to be triggered when the gamepad controller has been disconnected
  39936. */
  39937. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39938. private _onGamepadConnectedEvent;
  39939. private _onGamepadDisconnectedEvent;
  39940. /**
  39941. * Initializes the gamepad manager
  39942. * @param _scene BabylonJS scene
  39943. */
  39944. constructor(_scene?: Scene | undefined);
  39945. /**
  39946. * The gamepads in the game pad manager
  39947. */
  39948. readonly gamepads: Gamepad[];
  39949. /**
  39950. * Get the gamepad controllers based on type
  39951. * @param type The type of gamepad controller
  39952. * @returns Nullable gamepad
  39953. */
  39954. getGamepadByType(type?: number): Nullable<Gamepad>;
  39955. /**
  39956. * Disposes the gamepad manager
  39957. */
  39958. dispose(): void;
  39959. private _addNewGamepad;
  39960. private _startMonitoringGamepads;
  39961. private _stopMonitoringGamepads;
  39962. /** @hidden */
  39963. _checkGamepadsStatus(): void;
  39964. private _updateGamepadObjects;
  39965. }
  39966. }
  39967. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39968. import { Nullable } from "babylonjs/types";
  39969. import { Scene } from "babylonjs/scene";
  39970. import { ISceneComponent } from "babylonjs/sceneComponent";
  39971. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39972. module "babylonjs/scene" {
  39973. interface Scene {
  39974. /** @hidden */
  39975. _gamepadManager: Nullable<GamepadManager>;
  39976. /**
  39977. * Gets the gamepad manager associated with the scene
  39978. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39979. */
  39980. gamepadManager: GamepadManager;
  39981. }
  39982. }
  39983. module "babylonjs/Cameras/freeCameraInputsManager" {
  39984. /**
  39985. * Interface representing a free camera inputs manager
  39986. */
  39987. interface FreeCameraInputsManager {
  39988. /**
  39989. * Adds gamepad input support to the FreeCameraInputsManager.
  39990. * @returns the FreeCameraInputsManager
  39991. */
  39992. addGamepad(): FreeCameraInputsManager;
  39993. }
  39994. }
  39995. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39996. /**
  39997. * Interface representing an arc rotate camera inputs manager
  39998. */
  39999. interface ArcRotateCameraInputsManager {
  40000. /**
  40001. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40002. * @returns the camera inputs manager
  40003. */
  40004. addGamepad(): ArcRotateCameraInputsManager;
  40005. }
  40006. }
  40007. /**
  40008. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40009. */
  40010. export class GamepadSystemSceneComponent implements ISceneComponent {
  40011. /**
  40012. * The component name helpfull to identify the component in the list of scene components.
  40013. */
  40014. readonly name: string;
  40015. /**
  40016. * The scene the component belongs to.
  40017. */
  40018. scene: Scene;
  40019. /**
  40020. * Creates a new instance of the component for the given scene
  40021. * @param scene Defines the scene to register the component in
  40022. */
  40023. constructor(scene: Scene);
  40024. /**
  40025. * Registers the component in a given scene
  40026. */
  40027. register(): void;
  40028. /**
  40029. * Rebuilds the elements related to this component in case of
  40030. * context lost for instance.
  40031. */
  40032. rebuild(): void;
  40033. /**
  40034. * Disposes the component and the associated ressources
  40035. */
  40036. dispose(): void;
  40037. private _beforeCameraUpdate;
  40038. }
  40039. }
  40040. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  40041. import { Observable } from "babylonjs/Misc/observable";
  40042. import { Nullable } from "babylonjs/types";
  40043. import { Camera } from "babylonjs/Cameras/camera";
  40044. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40045. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40046. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  40047. import { Scene } from "babylonjs/scene";
  40048. import { Vector3, Color3 } from "babylonjs/Maths/math";
  40049. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  40050. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40051. import { Mesh } from "babylonjs/Meshes/mesh";
  40052. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40053. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40054. import "babylonjs/Meshes/Builders/groundBuilder";
  40055. import "babylonjs/Meshes/Builders/torusBuilder";
  40056. import "babylonjs/Meshes/Builders/cylinderBuilder";
  40057. import "babylonjs/Gamepads/gamepadSceneComponent";
  40058. import "babylonjs/Animations/animatable";
  40059. /**
  40060. * Options to modify the vr teleportation behavior.
  40061. */
  40062. export interface VRTeleportationOptions {
  40063. /**
  40064. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40065. */
  40066. floorMeshName?: string;
  40067. /**
  40068. * A list of meshes to be used as the teleportation floor. (default: empty)
  40069. */
  40070. floorMeshes?: Mesh[];
  40071. }
  40072. /**
  40073. * Options to modify the vr experience helper's behavior.
  40074. */
  40075. export interface VRExperienceHelperOptions extends WebVROptions {
  40076. /**
  40077. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40078. */
  40079. createDeviceOrientationCamera?: boolean;
  40080. /**
  40081. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40082. */
  40083. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40084. /**
  40085. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40086. */
  40087. laserToggle?: boolean;
  40088. /**
  40089. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40090. */
  40091. floorMeshes?: Mesh[];
  40092. /**
  40093. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40094. */
  40095. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40096. }
  40097. /**
  40098. * Event containing information after VR has been entered
  40099. */
  40100. export class OnAfterEnteringVRObservableEvent {
  40101. /**
  40102. * If entering vr was successful
  40103. */
  40104. success: boolean;
  40105. }
  40106. /**
  40107. * Helps to quickly add VR support to an existing scene.
  40108. * See http://doc.babylonjs.com/how_to/webvr_helper
  40109. */
  40110. export class VRExperienceHelper {
  40111. /** Options to modify the vr experience helper's behavior. */
  40112. webVROptions: VRExperienceHelperOptions;
  40113. private _scene;
  40114. private _position;
  40115. private _btnVR;
  40116. private _btnVRDisplayed;
  40117. private _webVRsupported;
  40118. private _webVRready;
  40119. private _webVRrequesting;
  40120. private _webVRpresenting;
  40121. private _hasEnteredVR;
  40122. private _fullscreenVRpresenting;
  40123. private _canvas;
  40124. private _webVRCamera;
  40125. private _vrDeviceOrientationCamera;
  40126. private _deviceOrientationCamera;
  40127. private _existingCamera;
  40128. private _onKeyDown;
  40129. private _onVrDisplayPresentChange;
  40130. private _onVRDisplayChanged;
  40131. private _onVRRequestPresentStart;
  40132. private _onVRRequestPresentComplete;
  40133. /**
  40134. * Observable raised right before entering VR.
  40135. */
  40136. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40137. /**
  40138. * Observable raised when entering VR has completed.
  40139. */
  40140. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40141. /**
  40142. * Observable raised when exiting VR.
  40143. */
  40144. onExitingVRObservable: Observable<VRExperienceHelper>;
  40145. /**
  40146. * Observable raised when controller mesh is loaded.
  40147. */
  40148. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40149. /** Return this.onEnteringVRObservable
  40150. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40151. */
  40152. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40153. /** Return this.onExitingVRObservable
  40154. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40155. */
  40156. readonly onExitingVR: Observable<VRExperienceHelper>;
  40157. /** Return this.onControllerMeshLoadedObservable
  40158. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40159. */
  40160. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40161. private _rayLength;
  40162. private _useCustomVRButton;
  40163. private _teleportationRequested;
  40164. private _teleportActive;
  40165. private _floorMeshName;
  40166. private _floorMeshesCollection;
  40167. private _rotationAllowed;
  40168. private _teleportBackwardsVector;
  40169. private _teleportationTarget;
  40170. private _isDefaultTeleportationTarget;
  40171. private _postProcessMove;
  40172. private _teleportationFillColor;
  40173. private _teleportationBorderColor;
  40174. private _rotationAngle;
  40175. private _haloCenter;
  40176. private _cameraGazer;
  40177. private _padSensibilityUp;
  40178. private _padSensibilityDown;
  40179. private _leftController;
  40180. private _rightController;
  40181. /**
  40182. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40183. */
  40184. onNewMeshSelected: Observable<AbstractMesh>;
  40185. /**
  40186. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40187. */
  40188. onNewMeshPicked: Observable<PickingInfo>;
  40189. private _circleEase;
  40190. /**
  40191. * Observable raised before camera teleportation
  40192. */
  40193. onBeforeCameraTeleport: Observable<Vector3>;
  40194. /**
  40195. * Observable raised after camera teleportation
  40196. */
  40197. onAfterCameraTeleport: Observable<Vector3>;
  40198. /**
  40199. * Observable raised when current selected mesh gets unselected
  40200. */
  40201. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40202. private _raySelectionPredicate;
  40203. /**
  40204. * To be optionaly changed by user to define custom ray selection
  40205. */
  40206. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40207. /**
  40208. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40209. */
  40210. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40211. /**
  40212. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40213. */
  40214. teleportationEnabled: boolean;
  40215. private _defaultHeight;
  40216. private _teleportationInitialized;
  40217. private _interactionsEnabled;
  40218. private _interactionsRequested;
  40219. private _displayGaze;
  40220. private _displayLaserPointer;
  40221. /**
  40222. * The mesh used to display where the user is going to teleport.
  40223. */
  40224. /**
  40225. * Sets the mesh to be used to display where the user is going to teleport.
  40226. */
  40227. teleportationTarget: Mesh;
  40228. /**
  40229. * 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
  40230. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40231. * See http://doc.babylonjs.com/resources/baking_transformations
  40232. */
  40233. gazeTrackerMesh: Mesh;
  40234. /**
  40235. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40236. */
  40237. updateGazeTrackerScale: boolean;
  40238. /**
  40239. * If the gaze trackers color should be updated when selecting meshes
  40240. */
  40241. updateGazeTrackerColor: boolean;
  40242. /**
  40243. * The gaze tracking mesh corresponding to the left controller
  40244. */
  40245. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40246. /**
  40247. * The gaze tracking mesh corresponding to the right controller
  40248. */
  40249. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40250. /**
  40251. * If the ray of the gaze should be displayed.
  40252. */
  40253. /**
  40254. * Sets if the ray of the gaze should be displayed.
  40255. */
  40256. displayGaze: boolean;
  40257. /**
  40258. * If the ray of the LaserPointer should be displayed.
  40259. */
  40260. /**
  40261. * Sets if the ray of the LaserPointer should be displayed.
  40262. */
  40263. displayLaserPointer: boolean;
  40264. /**
  40265. * The deviceOrientationCamera used as the camera when not in VR.
  40266. */
  40267. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40268. /**
  40269. * Based on the current WebVR support, returns the current VR camera used.
  40270. */
  40271. readonly currentVRCamera: Nullable<Camera>;
  40272. /**
  40273. * The webVRCamera which is used when in VR.
  40274. */
  40275. readonly webVRCamera: WebVRFreeCamera;
  40276. /**
  40277. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40278. */
  40279. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40280. private readonly _teleportationRequestInitiated;
  40281. /**
  40282. * Defines wether or not Pointer lock should be requested when switching to
  40283. * full screen.
  40284. */
  40285. requestPointerLockOnFullScreen: boolean;
  40286. /**
  40287. * Instantiates a VRExperienceHelper.
  40288. * Helps to quickly add VR support to an existing scene.
  40289. * @param scene The scene the VRExperienceHelper belongs to.
  40290. * @param webVROptions Options to modify the vr experience helper's behavior.
  40291. */
  40292. constructor(scene: Scene,
  40293. /** Options to modify the vr experience helper's behavior. */
  40294. webVROptions?: VRExperienceHelperOptions);
  40295. private _onDefaultMeshLoaded;
  40296. private _onResize;
  40297. private _onFullscreenChange;
  40298. /**
  40299. * Gets a value indicating if we are currently in VR mode.
  40300. */
  40301. readonly isInVRMode: boolean;
  40302. private onVrDisplayPresentChange;
  40303. private onVRDisplayChanged;
  40304. private moveButtonToBottomRight;
  40305. private displayVRButton;
  40306. private updateButtonVisibility;
  40307. private _cachedAngularSensibility;
  40308. /**
  40309. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40310. * Otherwise, will use the fullscreen API.
  40311. */
  40312. enterVR(): void;
  40313. /**
  40314. * Attempt to exit VR, or fullscreen.
  40315. */
  40316. exitVR(): void;
  40317. /**
  40318. * The position of the vr experience helper.
  40319. */
  40320. /**
  40321. * Sets the position of the vr experience helper.
  40322. */
  40323. position: Vector3;
  40324. /**
  40325. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40326. */
  40327. enableInteractions(): void;
  40328. private readonly _noControllerIsActive;
  40329. private beforeRender;
  40330. private _isTeleportationFloor;
  40331. /**
  40332. * Adds a floor mesh to be used for teleportation.
  40333. * @param floorMesh the mesh to be used for teleportation.
  40334. */
  40335. addFloorMesh(floorMesh: Mesh): void;
  40336. /**
  40337. * Removes a floor mesh from being used for teleportation.
  40338. * @param floorMesh the mesh to be removed.
  40339. */
  40340. removeFloorMesh(floorMesh: Mesh): void;
  40341. /**
  40342. * Enables interactions and teleportation using the VR controllers and gaze.
  40343. * @param vrTeleportationOptions options to modify teleportation behavior.
  40344. */
  40345. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40346. private _onNewGamepadConnected;
  40347. private _tryEnableInteractionOnController;
  40348. private _onNewGamepadDisconnected;
  40349. private _enableInteractionOnController;
  40350. private _checkTeleportWithRay;
  40351. private _checkRotate;
  40352. private _checkTeleportBackwards;
  40353. private _enableTeleportationOnController;
  40354. private _createTeleportationCircles;
  40355. private _displayTeleportationTarget;
  40356. private _hideTeleportationTarget;
  40357. private _rotateCamera;
  40358. private _moveTeleportationSelectorTo;
  40359. private _workingVector;
  40360. private _workingQuaternion;
  40361. private _workingMatrix;
  40362. /**
  40363. * Teleports the users feet to the desired location
  40364. * @param location The location where the user's feet should be placed
  40365. */
  40366. teleportCamera(location: Vector3): void;
  40367. private _convertNormalToDirectionOfRay;
  40368. private _castRayAndSelectObject;
  40369. private _notifySelectedMeshUnselected;
  40370. /**
  40371. * Sets the color of the laser ray from the vr controllers.
  40372. * @param color new color for the ray.
  40373. */
  40374. changeLaserColor(color: Color3): void;
  40375. /**
  40376. * Sets the color of the ray from the vr headsets gaze.
  40377. * @param color new color for the ray.
  40378. */
  40379. changeGazeColor(color: Color3): void;
  40380. /**
  40381. * Exits VR and disposes of the vr experience helper
  40382. */
  40383. dispose(): void;
  40384. /**
  40385. * Gets the name of the VRExperienceHelper class
  40386. * @returns "VRExperienceHelper"
  40387. */
  40388. getClassName(): string;
  40389. }
  40390. }
  40391. declare module "babylonjs/Cameras/VR/index" {
  40392. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  40393. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  40394. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40395. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  40396. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  40397. export * from "babylonjs/Cameras/VR/webVRCamera";
  40398. }
  40399. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  40400. import { Observable } from "babylonjs/Misc/observable";
  40401. import { Nullable } from "babylonjs/types";
  40402. import { IDisposable, Scene } from "babylonjs/scene";
  40403. import { Vector3 } from "babylonjs/Maths/math";
  40404. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40405. import { Ray } from "babylonjs/Culling/ray";
  40406. /**
  40407. * Manages an XRSession
  40408. * @see https://doc.babylonjs.com/how_to/webxr
  40409. */
  40410. export class WebXRSessionManager implements IDisposable {
  40411. private scene;
  40412. /**
  40413. * Fires every time a new xrFrame arrives which can be used to update the camera
  40414. */
  40415. onXRFrameObservable: Observable<any>;
  40416. /**
  40417. * Fires when the xr session is ended either by the device or manually done
  40418. */
  40419. onXRSessionEnded: Observable<any>;
  40420. /** @hidden */
  40421. _xrSession: XRSession;
  40422. /** @hidden */
  40423. _frameOfReference: XRFrameOfReference;
  40424. /** @hidden */
  40425. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40426. /** @hidden */
  40427. _currentXRFrame: Nullable<XRFrame>;
  40428. private _xrNavigator;
  40429. private _xrDevice;
  40430. private _tmpMatrix;
  40431. /**
  40432. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40433. * @param scene The scene which the session should be created for
  40434. */
  40435. constructor(scene: Scene);
  40436. /**
  40437. * Initializes the manager
  40438. * After initialization enterXR can be called to start an XR session
  40439. * @returns Promise which resolves after it is initialized
  40440. */
  40441. initializeAsync(): Promise<void>;
  40442. /**
  40443. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  40444. * @param sessionCreationOptions xr options to create the session with
  40445. * @param frameOfReferenceType option to configure how the xr pose is expressed
  40446. * @returns Promise which resolves after it enters XR
  40447. */
  40448. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  40449. /**
  40450. * Stops the xrSession and restores the renderloop
  40451. * @returns Promise which resolves after it exits XR
  40452. */
  40453. exitXRAsync(): Promise<void>;
  40454. /**
  40455. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40456. * @param ray ray to cast into the environment
  40457. * @returns Promise which resolves with a collision point in the environment if it exists
  40458. */
  40459. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40460. /**
  40461. * Checks if a session would be supported for the creation options specified
  40462. * @param options creation options to check if they are supported
  40463. * @returns true if supported
  40464. */
  40465. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40466. /**
  40467. * @hidden
  40468. * Converts the render layer of xrSession to a render target
  40469. * @param session session to create render target for
  40470. * @param scene scene the new render target should be created for
  40471. */
  40472. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  40473. /**
  40474. * Disposes of the session manager
  40475. */
  40476. dispose(): void;
  40477. }
  40478. }
  40479. declare module "babylonjs/Cameras/XR/webXRCamera" {
  40480. import { Scene } from "babylonjs/scene";
  40481. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40482. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40483. /**
  40484. * WebXR Camera which holds the views for the xrSession
  40485. * @see https://doc.babylonjs.com/how_to/webxr
  40486. */
  40487. export class WebXRCamera extends FreeCamera {
  40488. private static _TmpMatrix;
  40489. /**
  40490. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40491. * @param name the name of the camera
  40492. * @param scene the scene to add the camera to
  40493. */
  40494. constructor(name: string, scene: Scene);
  40495. private _updateNumberOfRigCameras;
  40496. /** @hidden */
  40497. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40498. /**
  40499. * Updates the cameras position from the current pose information of the XR session
  40500. * @param xrSessionManager the session containing pose information
  40501. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40502. */
  40503. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40504. }
  40505. }
  40506. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  40507. import { Nullable } from "babylonjs/types";
  40508. import { Observable } from "babylonjs/Misc/observable";
  40509. import { IDisposable, Scene } from "babylonjs/scene";
  40510. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  40511. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40512. import { Ray } from "babylonjs/Culling/ray";
  40513. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40514. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  40515. /**
  40516. * States of the webXR experience
  40517. */
  40518. export enum WebXRState {
  40519. /**
  40520. * Transitioning to being in XR mode
  40521. */
  40522. ENTERING_XR = 0,
  40523. /**
  40524. * Transitioning to non XR mode
  40525. */
  40526. EXITING_XR = 1,
  40527. /**
  40528. * In XR mode and presenting
  40529. */
  40530. IN_XR = 2,
  40531. /**
  40532. * Not entered XR mode
  40533. */
  40534. NOT_IN_XR = 3
  40535. }
  40536. /**
  40537. * Helper class used to enable XR
  40538. * @see https://doc.babylonjs.com/how_to/webxr
  40539. */
  40540. export class WebXRExperienceHelper implements IDisposable {
  40541. private scene;
  40542. /**
  40543. * 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
  40544. */
  40545. container: AbstractMesh;
  40546. /**
  40547. * Camera used to render xr content
  40548. */
  40549. camera: WebXRCamera;
  40550. /**
  40551. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40552. */
  40553. state: WebXRState;
  40554. private _setState;
  40555. private static _TmpVector;
  40556. /**
  40557. * Fires when the state of the experience helper has changed
  40558. */
  40559. onStateChangedObservable: Observable<WebXRState>;
  40560. /** @hidden */
  40561. _sessionManager: WebXRSessionManager;
  40562. private _nonVRCamera;
  40563. private _originalSceneAutoClear;
  40564. private _supported;
  40565. /**
  40566. * Creates the experience helper
  40567. * @param scene the scene to attach the experience helper to
  40568. * @returns a promise for the experience helper
  40569. */
  40570. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40571. /**
  40572. * Creates a WebXRExperienceHelper
  40573. * @param scene The scene the helper should be created in
  40574. */
  40575. private constructor();
  40576. /**
  40577. * Exits XR mode and returns the scene to its original state
  40578. * @returns promise that resolves after xr mode has exited
  40579. */
  40580. exitXRAsync(): Promise<void>;
  40581. /**
  40582. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40583. * @param sessionCreationOptions options for the XR session
  40584. * @param frameOfReference frame of reference of the XR session
  40585. * @returns promise that resolves after xr mode has entered
  40586. */
  40587. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40588. /**
  40589. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40590. * @param ray ray to cast into the environment
  40591. * @returns Promise which resolves with a collision point in the environment if it exists
  40592. */
  40593. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40594. /**
  40595. * Updates the global position of the camera by moving the camera's container
  40596. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40597. * @param position The desired global position of the camera
  40598. */
  40599. setPositionOfCameraUsingContainer(position: Vector3): void;
  40600. /**
  40601. * Rotates the xr camera by rotating the camera's container around the camera's position
  40602. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40603. * @param rotation the desired quaternion rotation to apply to the camera
  40604. */
  40605. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40606. /**
  40607. * Checks if the creation options are supported by the xr session
  40608. * @param options creation options
  40609. * @returns true if supported
  40610. */
  40611. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40612. /**
  40613. * Disposes of the experience helper
  40614. */
  40615. dispose(): void;
  40616. }
  40617. }
  40618. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  40619. import { Nullable } from "babylonjs/types";
  40620. import { Observable } from "babylonjs/Misc/observable";
  40621. import { IDisposable, Scene } from "babylonjs/scene";
  40622. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40623. /**
  40624. * Button which can be used to enter a different mode of XR
  40625. */
  40626. export class WebXREnterExitUIButton {
  40627. /** button element */
  40628. element: HTMLElement;
  40629. /** XR initialization options for the button */
  40630. initializationOptions: XRSessionCreationOptions;
  40631. /**
  40632. * Creates a WebXREnterExitUIButton
  40633. * @param element button element
  40634. * @param initializationOptions XR initialization options for the button
  40635. */
  40636. constructor(
  40637. /** button element */
  40638. element: HTMLElement,
  40639. /** XR initialization options for the button */
  40640. initializationOptions: XRSessionCreationOptions);
  40641. /**
  40642. * Overwritable function which can be used to update the button's visuals when the state changes
  40643. * @param activeButton the current active button in the UI
  40644. */
  40645. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40646. }
  40647. /**
  40648. * Options to create the webXR UI
  40649. */
  40650. export class WebXREnterExitUIOptions {
  40651. /**
  40652. * Context to enter xr with
  40653. */
  40654. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40655. /**
  40656. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40657. */
  40658. customButtons?: Array<WebXREnterExitUIButton>;
  40659. }
  40660. /**
  40661. * UI to allow the user to enter/exit XR mode
  40662. */
  40663. export class WebXREnterExitUI implements IDisposable {
  40664. private scene;
  40665. private _overlay;
  40666. private _buttons;
  40667. private _activeButton;
  40668. /**
  40669. * Fired every time the active button is changed.
  40670. *
  40671. * When xr is entered via a button that launches xr that button will be the callback parameter
  40672. *
  40673. * When exiting xr the callback parameter will be null)
  40674. */
  40675. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40676. /**
  40677. * Creates UI to allow the user to enter/exit XR mode
  40678. * @param scene the scene to add the ui to
  40679. * @param helper the xr experience helper to enter/exit xr with
  40680. * @param options options to configure the UI
  40681. * @returns the created ui
  40682. */
  40683. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40684. private constructor();
  40685. private _updateButtons;
  40686. /**
  40687. * Disposes of the object
  40688. */
  40689. dispose(): void;
  40690. }
  40691. }
  40692. declare module "babylonjs/Cameras/XR/webXRInput" {
  40693. import { IDisposable, Scene } from "babylonjs/scene";
  40694. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40695. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40696. /**
  40697. * Represents an XR input
  40698. */
  40699. export class WebXRController {
  40700. /**
  40701. * 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
  40702. */
  40703. grip?: AbstractMesh;
  40704. /**
  40705. * Pointer which can be used to select objects or attach a visible laser to
  40706. */
  40707. pointer: AbstractMesh;
  40708. /**
  40709. * Creates the controller
  40710. * @see https://doc.babylonjs.com/how_to/webxr
  40711. * @param scene the scene which the controller should be associated to
  40712. */
  40713. constructor(scene: Scene);
  40714. /**
  40715. * Disposes of the object
  40716. */
  40717. dispose(): void;
  40718. }
  40719. /**
  40720. * XR input used to track XR inputs such as controllers/rays
  40721. */
  40722. export class WebXRInput implements IDisposable {
  40723. private helper;
  40724. /**
  40725. * XR controllers being tracked
  40726. */
  40727. controllers: Array<WebXRController>;
  40728. private _tmpMatrix;
  40729. private _frameObserver;
  40730. /**
  40731. * Initializes the WebXRInput
  40732. * @param helper experience helper which the input should be created for
  40733. */
  40734. constructor(helper: WebXRExperienceHelper);
  40735. /**
  40736. * Disposes of the object
  40737. */
  40738. dispose(): void;
  40739. }
  40740. }
  40741. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  40742. import { Nullable } from "babylonjs/types";
  40743. import { IDisposable } from "babylonjs/scene";
  40744. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40745. /**
  40746. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40747. */
  40748. export class WebXRManagedOutputCanvas implements IDisposable {
  40749. private _canvas;
  40750. /**
  40751. * xrpresent context of the canvas which can be used to display/mirror xr content
  40752. */
  40753. canvasContext: Nullable<WebGLRenderingContext>;
  40754. /**
  40755. * Initializes the canvas to be added/removed upon entering/exiting xr
  40756. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40757. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40758. */
  40759. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40760. /**
  40761. * Disposes of the object
  40762. */
  40763. dispose(): void;
  40764. private _setManagedOutputCanvas;
  40765. private _addCanvas;
  40766. private _removeCanvas;
  40767. }
  40768. }
  40769. declare module "babylonjs/Cameras/XR/index" {
  40770. export * from "babylonjs/Cameras/XR/webXRCamera";
  40771. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  40772. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40773. export * from "babylonjs/Cameras/XR/webXRInput";
  40774. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  40775. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  40776. }
  40777. declare module "babylonjs/Cameras/RigModes/index" {
  40778. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40779. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40780. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  40781. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  40782. }
  40783. declare module "babylonjs/Cameras/index" {
  40784. export * from "babylonjs/Cameras/Inputs/index";
  40785. export * from "babylonjs/Cameras/cameraInputsManager";
  40786. export * from "babylonjs/Cameras/camera";
  40787. export * from "babylonjs/Cameras/targetCamera";
  40788. export * from "babylonjs/Cameras/freeCamera";
  40789. export * from "babylonjs/Cameras/freeCameraInputsManager";
  40790. export * from "babylonjs/Cameras/touchCamera";
  40791. export * from "babylonjs/Cameras/arcRotateCamera";
  40792. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  40793. export * from "babylonjs/Cameras/deviceOrientationCamera";
  40794. export * from "babylonjs/Cameras/flyCamera";
  40795. export * from "babylonjs/Cameras/flyCameraInputsManager";
  40796. export * from "babylonjs/Cameras/followCamera";
  40797. export * from "babylonjs/Cameras/gamepadCamera";
  40798. export * from "babylonjs/Cameras/Stereoscopic/index";
  40799. export * from "babylonjs/Cameras/universalCamera";
  40800. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  40801. export * from "babylonjs/Cameras/VR/index";
  40802. export * from "babylonjs/Cameras/XR/index";
  40803. export * from "babylonjs/Cameras/RigModes/index";
  40804. }
  40805. declare module "babylonjs/Collisions/index" {
  40806. export * from "babylonjs/Collisions/collider";
  40807. export * from "babylonjs/Collisions/collisionCoordinator";
  40808. export * from "babylonjs/Collisions/pickingInfo";
  40809. export * from "babylonjs/Collisions/intersectionInfo";
  40810. }
  40811. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  40812. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  40813. import { Vector3, Plane } from "babylonjs/Maths/math";
  40814. import { Ray } from "babylonjs/Culling/ray";
  40815. /**
  40816. * Contains an array of blocks representing the octree
  40817. */
  40818. export interface IOctreeContainer<T> {
  40819. /**
  40820. * Blocks within the octree
  40821. */
  40822. blocks: Array<OctreeBlock<T>>;
  40823. }
  40824. /**
  40825. * Class used to store a cell in an octree
  40826. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40827. */
  40828. export class OctreeBlock<T> {
  40829. /**
  40830. * Gets the content of the current block
  40831. */
  40832. entries: T[];
  40833. /**
  40834. * Gets the list of block children
  40835. */
  40836. blocks: Array<OctreeBlock<T>>;
  40837. private _depth;
  40838. private _maxDepth;
  40839. private _capacity;
  40840. private _minPoint;
  40841. private _maxPoint;
  40842. private _boundingVectors;
  40843. private _creationFunc;
  40844. /**
  40845. * Creates a new block
  40846. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40847. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40848. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40849. * @param depth defines the current depth of this block in the octree
  40850. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40851. * @param creationFunc defines a callback to call when an element is added to the block
  40852. */
  40853. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40854. /**
  40855. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40856. */
  40857. readonly capacity: number;
  40858. /**
  40859. * Gets the minimum vector (in world space) of the block's bounding box
  40860. */
  40861. readonly minPoint: Vector3;
  40862. /**
  40863. * Gets the maximum vector (in world space) of the block's bounding box
  40864. */
  40865. readonly maxPoint: Vector3;
  40866. /**
  40867. * Add a new element to this block
  40868. * @param entry defines the element to add
  40869. */
  40870. addEntry(entry: T): void;
  40871. /**
  40872. * Remove an element from this block
  40873. * @param entry defines the element to remove
  40874. */
  40875. removeEntry(entry: T): void;
  40876. /**
  40877. * Add an array of elements to this block
  40878. * @param entries defines the array of elements to add
  40879. */
  40880. addEntries(entries: T[]): void;
  40881. /**
  40882. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40883. * @param frustumPlanes defines the frustum planes to test
  40884. * @param selection defines the array to store current content if selection is positive
  40885. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40886. */
  40887. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40888. /**
  40889. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40890. * @param sphereCenter defines the bounding sphere center
  40891. * @param sphereRadius defines the bounding sphere radius
  40892. * @param selection defines the array to store current content if selection is positive
  40893. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40894. */
  40895. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40896. /**
  40897. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40898. * @param ray defines the ray to test with
  40899. * @param selection defines the array to store current content if selection is positive
  40900. */
  40901. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40902. /**
  40903. * Subdivide the content into child blocks (this block will then be empty)
  40904. */
  40905. createInnerBlocks(): void;
  40906. /**
  40907. * @hidden
  40908. */
  40909. 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;
  40910. }
  40911. }
  40912. declare module "babylonjs/Culling/Octrees/octree" {
  40913. import { SmartArray } from "babylonjs/Misc/smartArray";
  40914. import { Vector3, Plane } from "babylonjs/Maths/math";
  40915. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40916. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40917. import { Ray } from "babylonjs/Culling/ray";
  40918. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  40919. /**
  40920. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40921. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40922. */
  40923. export class Octree<T> {
  40924. /** 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.) */
  40925. maxDepth: number;
  40926. /**
  40927. * Blocks within the octree containing objects
  40928. */
  40929. blocks: Array<OctreeBlock<T>>;
  40930. /**
  40931. * Content stored in the octree
  40932. */
  40933. dynamicContent: T[];
  40934. private _maxBlockCapacity;
  40935. private _selectionContent;
  40936. private _creationFunc;
  40937. /**
  40938. * Creates a octree
  40939. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40940. * @param creationFunc function to be used to instatiate the octree
  40941. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40942. * @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.)
  40943. */
  40944. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40945. /** 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.) */
  40946. maxDepth?: number);
  40947. /**
  40948. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40949. * @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);
  40950. * @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);
  40951. * @param entries meshes to be added to the octree blocks
  40952. */
  40953. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40954. /**
  40955. * Adds a mesh to the octree
  40956. * @param entry Mesh to add to the octree
  40957. */
  40958. addMesh(entry: T): void;
  40959. /**
  40960. * Remove an element from the octree
  40961. * @param entry defines the element to remove
  40962. */
  40963. removeMesh(entry: T): void;
  40964. /**
  40965. * Selects an array of meshes within the frustum
  40966. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40967. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40968. * @returns array of meshes within the frustum
  40969. */
  40970. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40971. /**
  40972. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40973. * @param sphereCenter defines the bounding sphere center
  40974. * @param sphereRadius defines the bounding sphere radius
  40975. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40976. * @returns an array of objects that intersect the sphere
  40977. */
  40978. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40979. /**
  40980. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40981. * @param ray defines the ray to test with
  40982. * @returns array of intersected objects
  40983. */
  40984. intersectsRay(ray: Ray): SmartArray<T>;
  40985. /**
  40986. * Adds a mesh into the octree block if it intersects the block
  40987. */
  40988. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40989. /**
  40990. * Adds a submesh into the octree block if it intersects the block
  40991. */
  40992. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40993. }
  40994. }
  40995. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  40996. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40997. import { Scene } from "babylonjs/scene";
  40998. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40999. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41000. import { Ray } from "babylonjs/Culling/ray";
  41001. import { Octree } from "babylonjs/Culling/Octrees/octree";
  41002. import { Collider } from "babylonjs/Collisions/collider";
  41003. module "babylonjs/scene" {
  41004. interface Scene {
  41005. /**
  41006. * @hidden
  41007. * Backing Filed
  41008. */
  41009. _selectionOctree: Octree<AbstractMesh>;
  41010. /**
  41011. * Gets the octree used to boost mesh selection (picking)
  41012. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41013. */
  41014. selectionOctree: Octree<AbstractMesh>;
  41015. /**
  41016. * Creates or updates the octree used to boost selection (picking)
  41017. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41018. * @param maxCapacity defines the maximum capacity per leaf
  41019. * @param maxDepth defines the maximum depth of the octree
  41020. * @returns an octree of AbstractMesh
  41021. */
  41022. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41023. }
  41024. }
  41025. module "babylonjs/Meshes/abstractMesh" {
  41026. interface AbstractMesh {
  41027. /**
  41028. * @hidden
  41029. * Backing Field
  41030. */
  41031. _submeshesOctree: Octree<SubMesh>;
  41032. /**
  41033. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41034. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41035. * @param maxCapacity defines the maximum size of each block (64 by default)
  41036. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41037. * @returns the new octree
  41038. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41039. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41040. */
  41041. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41042. }
  41043. }
  41044. /**
  41045. * Defines the octree scene component responsible to manage any octrees
  41046. * in a given scene.
  41047. */
  41048. export class OctreeSceneComponent {
  41049. /**
  41050. * The component name helpfull to identify the component in the list of scene components.
  41051. */
  41052. readonly name: string;
  41053. /**
  41054. * The scene the component belongs to.
  41055. */
  41056. scene: Scene;
  41057. /**
  41058. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41059. */
  41060. readonly checksIsEnabled: boolean;
  41061. /**
  41062. * Creates a new instance of the component for the given scene
  41063. * @param scene Defines the scene to register the component in
  41064. */
  41065. constructor(scene: Scene);
  41066. /**
  41067. * Registers the component in a given scene
  41068. */
  41069. register(): void;
  41070. /**
  41071. * Return the list of active meshes
  41072. * @returns the list of active meshes
  41073. */
  41074. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41075. /**
  41076. * Return the list of active sub meshes
  41077. * @param mesh The mesh to get the candidates sub meshes from
  41078. * @returns the list of active sub meshes
  41079. */
  41080. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41081. private _tempRay;
  41082. /**
  41083. * Return the list of sub meshes intersecting with a given local ray
  41084. * @param mesh defines the mesh to find the submesh for
  41085. * @param localRay defines the ray in local space
  41086. * @returns the list of intersecting sub meshes
  41087. */
  41088. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41089. /**
  41090. * Return the list of sub meshes colliding with a collider
  41091. * @param mesh defines the mesh to find the submesh for
  41092. * @param collider defines the collider to evaluate the collision against
  41093. * @returns the list of colliding sub meshes
  41094. */
  41095. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41096. /**
  41097. * Rebuilds the elements related to this component in case of
  41098. * context lost for instance.
  41099. */
  41100. rebuild(): void;
  41101. /**
  41102. * Disposes the component and the associated ressources.
  41103. */
  41104. dispose(): void;
  41105. }
  41106. }
  41107. declare module "babylonjs/Culling/Octrees/index" {
  41108. export * from "babylonjs/Culling/Octrees/octree";
  41109. export * from "babylonjs/Culling/Octrees/octreeBlock";
  41110. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  41111. }
  41112. declare module "babylonjs/Culling/index" {
  41113. export * from "babylonjs/Culling/boundingBox";
  41114. export * from "babylonjs/Culling/boundingInfo";
  41115. export * from "babylonjs/Culling/boundingSphere";
  41116. export * from "babylonjs/Culling/Octrees/index";
  41117. export * from "babylonjs/Culling/ray";
  41118. }
  41119. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  41120. import { Vector3, Color4 } from "babylonjs/Maths/math";
  41121. import { Nullable } from "babylonjs/types";
  41122. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41123. import { Scene } from "babylonjs/scene";
  41124. /**
  41125. * Class containing static functions to help procedurally build meshes
  41126. */
  41127. export class LinesBuilder {
  41128. /**
  41129. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  41130. * * 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
  41131. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  41132. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  41133. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  41134. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  41135. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  41136. * * 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
  41137. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  41138. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41139. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  41140. * @param name defines the name of the new line system
  41141. * @param options defines the options used to create the line system
  41142. * @param scene defines the hosting scene
  41143. * @returns a new line system mesh
  41144. */
  41145. static CreateLineSystem(name: string, options: {
  41146. lines: Vector3[][];
  41147. updatable?: boolean;
  41148. instance?: Nullable<LinesMesh>;
  41149. colors?: Nullable<Color4[][]>;
  41150. useVertexAlpha?: boolean;
  41151. }, scene: Nullable<Scene>): LinesMesh;
  41152. /**
  41153. * Creates a line mesh
  41154. * 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
  41155. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41156. * * The parameter `points` is an array successive Vector3
  41157. * * 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
  41158. * * The optional parameter `colors` is an array of successive Color4, one per line point
  41159. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  41160. * * When updating an instance, remember that only point positions can change, not the number of points
  41161. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41162. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  41163. * @param name defines the name of the new line system
  41164. * @param options defines the options used to create the line system
  41165. * @param scene defines the hosting scene
  41166. * @returns a new line mesh
  41167. */
  41168. static CreateLines(name: string, options: {
  41169. points: Vector3[];
  41170. updatable?: boolean;
  41171. instance?: Nullable<LinesMesh>;
  41172. colors?: Color4[];
  41173. useVertexAlpha?: boolean;
  41174. }, scene?: Nullable<Scene>): LinesMesh;
  41175. /**
  41176. * Creates a dashed line mesh
  41177. * * 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
  41178. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41179. * * The parameter `points` is an array successive Vector3
  41180. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  41181. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  41182. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  41183. * * 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
  41184. * * When updating an instance, remember that only point positions can change, not the number of points
  41185. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41186. * @param name defines the name of the mesh
  41187. * @param options defines the options used to create the mesh
  41188. * @param scene defines the hosting scene
  41189. * @returns the dashed line mesh
  41190. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  41191. */
  41192. static CreateDashedLines(name: string, options: {
  41193. points: Vector3[];
  41194. dashSize?: number;
  41195. gapSize?: number;
  41196. dashNb?: number;
  41197. updatable?: boolean;
  41198. instance?: LinesMesh;
  41199. }, scene?: Nullable<Scene>): LinesMesh;
  41200. }
  41201. }
  41202. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  41203. import { IDisposable, Scene } from "babylonjs/scene";
  41204. import { Nullable } from "babylonjs/types";
  41205. import { Observable } from "babylonjs/Misc/observable";
  41206. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41207. /**
  41208. * Renders a layer on top of an existing scene
  41209. */
  41210. export class UtilityLayerRenderer implements IDisposable {
  41211. /** the original scene that will be rendered on top of */
  41212. originalScene: Scene;
  41213. private _pointerCaptures;
  41214. private _lastPointerEvents;
  41215. private static _DefaultUtilityLayer;
  41216. private static _DefaultKeepDepthUtilityLayer;
  41217. /**
  41218. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41219. */
  41220. pickUtilitySceneFirst: boolean;
  41221. /**
  41222. * 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)
  41223. */
  41224. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41225. /**
  41226. * 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)
  41227. */
  41228. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41229. /**
  41230. * The scene that is rendered on top of the original scene
  41231. */
  41232. utilityLayerScene: Scene;
  41233. /**
  41234. * If the utility layer should automatically be rendered on top of existing scene
  41235. */
  41236. shouldRender: boolean;
  41237. /**
  41238. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41239. */
  41240. onlyCheckPointerDownEvents: boolean;
  41241. /**
  41242. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41243. */
  41244. processAllEvents: boolean;
  41245. /**
  41246. * Observable raised when the pointer move from the utility layer scene to the main scene
  41247. */
  41248. onPointerOutObservable: Observable<number>;
  41249. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41250. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41251. private _afterRenderObserver;
  41252. private _sceneDisposeObserver;
  41253. private _originalPointerObserver;
  41254. /**
  41255. * Instantiates a UtilityLayerRenderer
  41256. * @param originalScene the original scene that will be rendered on top of
  41257. * @param handleEvents boolean indicating if the utility layer should handle events
  41258. */
  41259. constructor(
  41260. /** the original scene that will be rendered on top of */
  41261. originalScene: Scene, handleEvents?: boolean);
  41262. private _notifyObservers;
  41263. /**
  41264. * Renders the utility layers scene on top of the original scene
  41265. */
  41266. render(): void;
  41267. /**
  41268. * Disposes of the renderer
  41269. */
  41270. dispose(): void;
  41271. private _updateCamera;
  41272. }
  41273. }
  41274. declare module "babylonjs/Gizmos/gizmo" {
  41275. import { Nullable } from "babylonjs/types";
  41276. import { IDisposable } from "babylonjs/scene";
  41277. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41278. import { Mesh } from "babylonjs/Meshes/mesh";
  41279. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41280. /**
  41281. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41282. */
  41283. export class Gizmo implements IDisposable {
  41284. /** The utility layer the gizmo will be added to */
  41285. gizmoLayer: UtilityLayerRenderer;
  41286. /**
  41287. * The root mesh of the gizmo
  41288. */
  41289. _rootMesh: Mesh;
  41290. private _attachedMesh;
  41291. /**
  41292. * Ratio for the scale of the gizmo (Default: 1)
  41293. */
  41294. scaleRatio: number;
  41295. private _tmpMatrix;
  41296. /**
  41297. * If a custom mesh has been set (Default: false)
  41298. */
  41299. protected _customMeshSet: boolean;
  41300. /**
  41301. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41302. * * When set, interactions will be enabled
  41303. */
  41304. attachedMesh: Nullable<AbstractMesh>;
  41305. /**
  41306. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41307. * @param mesh The mesh to replace the default mesh of the gizmo
  41308. */
  41309. setCustomMesh(mesh: Mesh): void;
  41310. /**
  41311. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41312. */
  41313. updateGizmoRotationToMatchAttachedMesh: boolean;
  41314. /**
  41315. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41316. */
  41317. updateGizmoPositionToMatchAttachedMesh: boolean;
  41318. /**
  41319. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  41320. */
  41321. protected _updateScale: boolean;
  41322. protected _interactionsEnabled: boolean;
  41323. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41324. private _beforeRenderObserver;
  41325. /**
  41326. * Creates a gizmo
  41327. * @param gizmoLayer The utility layer the gizmo will be added to
  41328. */
  41329. constructor(
  41330. /** The utility layer the gizmo will be added to */
  41331. gizmoLayer?: UtilityLayerRenderer);
  41332. private _tempVector;
  41333. /**
  41334. * @hidden
  41335. * Updates the gizmo to match the attached mesh's position/rotation
  41336. */
  41337. protected _update(): void;
  41338. /**
  41339. * Disposes of the gizmo
  41340. */
  41341. dispose(): void;
  41342. }
  41343. }
  41344. declare module "babylonjs/Gizmos/axisDragGizmo" {
  41345. import { Observable } from "babylonjs/Misc/observable";
  41346. import { Nullable } from "babylonjs/types";
  41347. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41348. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41349. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41350. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41351. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  41352. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41353. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  41354. import { Scene } from "babylonjs/scene";
  41355. /**
  41356. * Single axis drag gizmo
  41357. */
  41358. export class AxisDragGizmo extends Gizmo {
  41359. /**
  41360. * Drag behavior responsible for the gizmos dragging interactions
  41361. */
  41362. dragBehavior: PointerDragBehavior;
  41363. private _pointerObserver;
  41364. /**
  41365. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41366. */
  41367. snapDistance: number;
  41368. /**
  41369. * Event that fires each time the gizmo snaps to a new location.
  41370. * * snapDistance is the the change in distance
  41371. */
  41372. onSnapObservable: Observable<{
  41373. snapDistance: number;
  41374. }>;
  41375. /** @hidden */
  41376. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41377. /** @hidden */
  41378. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41379. /**
  41380. * Creates an AxisDragGizmo
  41381. * @param gizmoLayer The utility layer the gizmo will be added to
  41382. * @param dragAxis The axis which the gizmo will be able to drag on
  41383. * @param color The color of the gizmo
  41384. */
  41385. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41386. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41387. /**
  41388. * Disposes of the gizmo
  41389. */
  41390. dispose(): void;
  41391. }
  41392. }
  41393. declare module "babylonjs/Debug/axesViewer" {
  41394. import { Vector3 } from "babylonjs/Maths/math";
  41395. import { Nullable } from "babylonjs/types";
  41396. import { Scene } from "babylonjs/scene";
  41397. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41398. /**
  41399. * The Axes viewer will show 3 axes in a specific point in space
  41400. */
  41401. export class AxesViewer {
  41402. private _xAxis;
  41403. private _yAxis;
  41404. private _zAxis;
  41405. private _scaleLinesFactor;
  41406. private _instanced;
  41407. /**
  41408. * Gets the hosting scene
  41409. */
  41410. scene: Scene;
  41411. /**
  41412. * Gets or sets a number used to scale line length
  41413. */
  41414. scaleLines: number;
  41415. /** Gets the node hierarchy used to render x-axis */
  41416. readonly xAxis: TransformNode;
  41417. /** Gets the node hierarchy used to render y-axis */
  41418. readonly yAxis: TransformNode;
  41419. /** Gets the node hierarchy used to render z-axis */
  41420. readonly zAxis: TransformNode;
  41421. /**
  41422. * Creates a new AxesViewer
  41423. * @param scene defines the hosting scene
  41424. * @param scaleLines defines a number used to scale line length (1 by default)
  41425. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  41426. * @param xAxis defines the node hierarchy used to render the x-axis
  41427. * @param yAxis defines the node hierarchy used to render the y-axis
  41428. * @param zAxis defines the node hierarchy used to render the z-axis
  41429. */
  41430. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  41431. /**
  41432. * Force the viewer to update
  41433. * @param position defines the position of the viewer
  41434. * @param xaxis defines the x axis of the viewer
  41435. * @param yaxis defines the y axis of the viewer
  41436. * @param zaxis defines the z axis of the viewer
  41437. */
  41438. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  41439. /**
  41440. * Creates an instance of this axes viewer.
  41441. * @returns a new axes viewer with instanced meshes
  41442. */
  41443. createInstance(): AxesViewer;
  41444. /** Releases resources */
  41445. dispose(): void;
  41446. private static _SetRenderingGroupId;
  41447. }
  41448. }
  41449. declare module "babylonjs/Debug/boneAxesViewer" {
  41450. import { Nullable } from "babylonjs/types";
  41451. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  41452. import { Vector3 } from "babylonjs/Maths/math";
  41453. import { Mesh } from "babylonjs/Meshes/mesh";
  41454. import { Bone } from "babylonjs/Bones/bone";
  41455. import { Scene } from "babylonjs/scene";
  41456. /**
  41457. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  41458. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  41459. */
  41460. export class BoneAxesViewer extends AxesViewer {
  41461. /**
  41462. * Gets or sets the target mesh where to display the axes viewer
  41463. */
  41464. mesh: Nullable<Mesh>;
  41465. /**
  41466. * Gets or sets the target bone where to display the axes viewer
  41467. */
  41468. bone: Nullable<Bone>;
  41469. /** Gets current position */
  41470. pos: Vector3;
  41471. /** Gets direction of X axis */
  41472. xaxis: Vector3;
  41473. /** Gets direction of Y axis */
  41474. yaxis: Vector3;
  41475. /** Gets direction of Z axis */
  41476. zaxis: Vector3;
  41477. /**
  41478. * Creates a new BoneAxesViewer
  41479. * @param scene defines the hosting scene
  41480. * @param bone defines the target bone
  41481. * @param mesh defines the target mesh
  41482. * @param scaleLines defines a scaling factor for line length (1 by default)
  41483. */
  41484. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  41485. /**
  41486. * Force the viewer to update
  41487. */
  41488. update(): void;
  41489. /** Releases resources */
  41490. dispose(): void;
  41491. }
  41492. }
  41493. declare module "babylonjs/Debug/debugLayer" {
  41494. import { Observable } from "babylonjs/Misc/observable";
  41495. import { Scene } from "babylonjs/scene";
  41496. /**
  41497. * Interface used to define scene explorer extensibility option
  41498. */
  41499. export interface IExplorerExtensibilityOption {
  41500. /**
  41501. * Define the option label
  41502. */
  41503. label: string;
  41504. /**
  41505. * Defines the action to execute on click
  41506. */
  41507. action: (entity: any) => void;
  41508. }
  41509. /**
  41510. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  41511. */
  41512. export interface IExplorerExtensibilityGroup {
  41513. /**
  41514. * Defines a predicate to test if a given type mut be extended
  41515. */
  41516. predicate: (entity: any) => boolean;
  41517. /**
  41518. * Gets the list of options added to a type
  41519. */
  41520. entries: IExplorerExtensibilityOption[];
  41521. }
  41522. /**
  41523. * Interface used to define the options to use to create the Inspector
  41524. */
  41525. export interface IInspectorOptions {
  41526. /**
  41527. * Display in overlay mode (default: false)
  41528. */
  41529. overlay?: boolean;
  41530. /**
  41531. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  41532. */
  41533. globalRoot?: HTMLElement;
  41534. /**
  41535. * Display the Scene explorer
  41536. */
  41537. showExplorer?: boolean;
  41538. /**
  41539. * Display the property inspector
  41540. */
  41541. showInspector?: boolean;
  41542. /**
  41543. * Display in embed mode (both panes on the right)
  41544. */
  41545. embedMode?: boolean;
  41546. /**
  41547. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  41548. */
  41549. handleResize?: boolean;
  41550. /**
  41551. * Allow the panes to popup (default: true)
  41552. */
  41553. enablePopup?: boolean;
  41554. /**
  41555. * Allow the panes to be closed by users (default: true)
  41556. */
  41557. enableClose?: boolean;
  41558. /**
  41559. * Optional list of extensibility entries
  41560. */
  41561. explorerExtensibility?: IExplorerExtensibilityGroup[];
  41562. /**
  41563. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  41564. */
  41565. inspectorURL?: string;
  41566. }
  41567. module "babylonjs/scene" {
  41568. interface Scene {
  41569. /**
  41570. * @hidden
  41571. * Backing field
  41572. */
  41573. _debugLayer: DebugLayer;
  41574. /**
  41575. * Gets the debug layer (aka Inspector) associated with the scene
  41576. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41577. */
  41578. debugLayer: DebugLayer;
  41579. }
  41580. }
  41581. /**
  41582. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41583. * what is happening in your scene
  41584. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41585. */
  41586. export class DebugLayer {
  41587. /**
  41588. * Define the url to get the inspector script from.
  41589. * By default it uses the babylonjs CDN.
  41590. * @ignoreNaming
  41591. */
  41592. static InspectorURL: string;
  41593. private _scene;
  41594. private BJSINSPECTOR;
  41595. /**
  41596. * Observable triggered when a property is changed through the inspector.
  41597. */
  41598. onPropertyChangedObservable: Observable<{
  41599. object: any;
  41600. property: string;
  41601. value: any;
  41602. initialValue: any;
  41603. }>;
  41604. /**
  41605. * Instantiates a new debug layer.
  41606. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41607. * what is happening in your scene
  41608. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41609. * @param scene Defines the scene to inspect
  41610. */
  41611. constructor(scene: Scene);
  41612. /** Creates the inspector window. */
  41613. private _createInspector;
  41614. /**
  41615. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  41616. * @param entity defines the entity to select
  41617. * @param lineContainerTitle defines the specific block to highlight
  41618. */
  41619. select(entity: any, lineContainerTitle?: string): void;
  41620. /** Get the inspector from bundle or global */
  41621. private _getGlobalInspector;
  41622. /**
  41623. * Get if the inspector is visible or not.
  41624. * @returns true if visible otherwise, false
  41625. */
  41626. isVisible(): boolean;
  41627. /**
  41628. * Hide the inspector and close its window.
  41629. */
  41630. hide(): void;
  41631. /**
  41632. * Launch the debugLayer.
  41633. * @param config Define the configuration of the inspector
  41634. * @return a promise fulfilled when the debug layer is visible
  41635. */
  41636. show(config?: IInspectorOptions): Promise<DebugLayer>;
  41637. }
  41638. }
  41639. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  41640. import { Nullable } from "babylonjs/types";
  41641. import { Scene } from "babylonjs/scene";
  41642. import { Vector4, Color4 } from "babylonjs/Maths/math";
  41643. import { Mesh } from "babylonjs/Meshes/mesh";
  41644. /**
  41645. * Class containing static functions to help procedurally build meshes
  41646. */
  41647. export class BoxBuilder {
  41648. /**
  41649. * Creates a box mesh
  41650. * * The parameter `size` sets the size (float) of each box side (default 1)
  41651. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  41652. * * 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)
  41653. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  41654. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41655. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41656. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41657. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  41658. * @param name defines the name of the mesh
  41659. * @param options defines the options used to create the mesh
  41660. * @param scene defines the hosting scene
  41661. * @returns the box mesh
  41662. */
  41663. static CreateBox(name: string, options: {
  41664. size?: number;
  41665. width?: number;
  41666. height?: number;
  41667. depth?: number;
  41668. faceUV?: Vector4[];
  41669. faceColors?: Color4[];
  41670. sideOrientation?: number;
  41671. frontUVs?: Vector4;
  41672. backUVs?: Vector4;
  41673. updatable?: boolean;
  41674. }, scene?: Nullable<Scene>): Mesh;
  41675. }
  41676. }
  41677. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  41678. import { Vector4 } from "babylonjs/Maths/math";
  41679. import { Mesh } from "babylonjs/Meshes/mesh";
  41680. /**
  41681. * Class containing static functions to help procedurally build meshes
  41682. */
  41683. export class SphereBuilder {
  41684. /**
  41685. * Creates a sphere mesh
  41686. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  41687. * * 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`)
  41688. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  41689. * * 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
  41690. * * 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)
  41691. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41692. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41693. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41694. * @param name defines the name of the mesh
  41695. * @param options defines the options used to create the mesh
  41696. * @param scene defines the hosting scene
  41697. * @returns the sphere mesh
  41698. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  41699. */
  41700. static CreateSphere(name: string, options: {
  41701. segments?: number;
  41702. diameter?: number;
  41703. diameterX?: number;
  41704. diameterY?: number;
  41705. diameterZ?: number;
  41706. arc?: number;
  41707. slice?: number;
  41708. sideOrientation?: number;
  41709. frontUVs?: Vector4;
  41710. backUVs?: Vector4;
  41711. updatable?: boolean;
  41712. }, scene: any): Mesh;
  41713. }
  41714. }
  41715. declare module "babylonjs/Debug/physicsViewer" {
  41716. import { Nullable } from "babylonjs/types";
  41717. import { Scene } from "babylonjs/scene";
  41718. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41719. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  41720. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  41721. /**
  41722. * Used to show the physics impostor around the specific mesh
  41723. */
  41724. export class PhysicsViewer {
  41725. /** @hidden */
  41726. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  41727. /** @hidden */
  41728. protected _meshes: Array<Nullable<AbstractMesh>>;
  41729. /** @hidden */
  41730. protected _scene: Nullable<Scene>;
  41731. /** @hidden */
  41732. protected _numMeshes: number;
  41733. /** @hidden */
  41734. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  41735. private _renderFunction;
  41736. private _utilityLayer;
  41737. private _debugBoxMesh;
  41738. private _debugSphereMesh;
  41739. private _debugMaterial;
  41740. /**
  41741. * Creates a new PhysicsViewer
  41742. * @param scene defines the hosting scene
  41743. */
  41744. constructor(scene: Scene);
  41745. /** @hidden */
  41746. protected _updateDebugMeshes(): void;
  41747. /**
  41748. * Renders a specified physic impostor
  41749. * @param impostor defines the impostor to render
  41750. * @returns the new debug mesh used to render the impostor
  41751. */
  41752. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  41753. /**
  41754. * Hides a specified physic impostor
  41755. * @param impostor defines the impostor to hide
  41756. */
  41757. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41758. private _getDebugMaterial;
  41759. private _getDebugBoxMesh;
  41760. private _getDebugSphereMesh;
  41761. private _getDebugMesh;
  41762. /** Releases all resources */
  41763. dispose(): void;
  41764. }
  41765. }
  41766. declare module "babylonjs/Debug/rayHelper" {
  41767. import { Nullable } from "babylonjs/types";
  41768. import { Ray } from "babylonjs/Culling/ray";
  41769. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41770. import { Scene } from "babylonjs/scene";
  41771. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41772. import "babylonjs/Meshes/Builders/linesBuilder";
  41773. /**
  41774. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41775. * in order to better appreciate the issue one might have.
  41776. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41777. */
  41778. export class RayHelper {
  41779. /**
  41780. * Defines the ray we are currently tryin to visualize.
  41781. */
  41782. ray: Nullable<Ray>;
  41783. private _renderPoints;
  41784. private _renderLine;
  41785. private _renderFunction;
  41786. private _scene;
  41787. private _updateToMeshFunction;
  41788. private _attachedToMesh;
  41789. private _meshSpaceDirection;
  41790. private _meshSpaceOrigin;
  41791. /**
  41792. * Helper function to create a colored helper in a scene in one line.
  41793. * @param ray Defines the ray we are currently tryin to visualize
  41794. * @param scene Defines the scene the ray is used in
  41795. * @param color Defines the color we want to see the ray in
  41796. * @returns The newly created ray helper.
  41797. */
  41798. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41799. /**
  41800. * Instantiate a new ray helper.
  41801. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41802. * in order to better appreciate the issue one might have.
  41803. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41804. * @param ray Defines the ray we are currently tryin to visualize
  41805. */
  41806. constructor(ray: Ray);
  41807. /**
  41808. * Shows the ray we are willing to debug.
  41809. * @param scene Defines the scene the ray needs to be rendered in
  41810. * @param color Defines the color the ray needs to be rendered in
  41811. */
  41812. show(scene: Scene, color?: Color3): void;
  41813. /**
  41814. * Hides the ray we are debugging.
  41815. */
  41816. hide(): void;
  41817. private _render;
  41818. /**
  41819. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41820. * @param mesh Defines the mesh we want the helper attached to
  41821. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41822. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41823. * @param length Defines the length of the ray
  41824. */
  41825. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41826. /**
  41827. * Detach the ray helper from the mesh it has previously been attached to.
  41828. */
  41829. detachFromMesh(): void;
  41830. private _updateToMesh;
  41831. /**
  41832. * Dispose the helper and release its associated resources.
  41833. */
  41834. dispose(): void;
  41835. }
  41836. }
  41837. declare module "babylonjs/Debug/skeletonViewer" {
  41838. import { Color3 } from "babylonjs/Maths/math";
  41839. import { Scene } from "babylonjs/scene";
  41840. import { Nullable } from "babylonjs/types";
  41841. import { Skeleton } from "babylonjs/Bones/skeleton";
  41842. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41843. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41844. /**
  41845. * Class used to render a debug view of a given skeleton
  41846. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41847. */
  41848. export class SkeletonViewer {
  41849. /** defines the skeleton to render */
  41850. skeleton: Skeleton;
  41851. /** defines the mesh attached to the skeleton */
  41852. mesh: AbstractMesh;
  41853. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41854. autoUpdateBonesMatrices: boolean;
  41855. /** defines the rendering group id to use with the viewer */
  41856. renderingGroupId: number;
  41857. /** Gets or sets the color used to render the skeleton */
  41858. color: Color3;
  41859. private _scene;
  41860. private _debugLines;
  41861. private _debugMesh;
  41862. private _isEnabled;
  41863. private _renderFunction;
  41864. private _utilityLayer;
  41865. /**
  41866. * Returns the mesh used to render the bones
  41867. */
  41868. readonly debugMesh: Nullable<LinesMesh>;
  41869. /**
  41870. * Creates a new SkeletonViewer
  41871. * @param skeleton defines the skeleton to render
  41872. * @param mesh defines the mesh attached to the skeleton
  41873. * @param scene defines the hosting scene
  41874. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41875. * @param renderingGroupId defines the rendering group id to use with the viewer
  41876. */
  41877. constructor(
  41878. /** defines the skeleton to render */
  41879. skeleton: Skeleton,
  41880. /** defines the mesh attached to the skeleton */
  41881. mesh: AbstractMesh, scene: Scene,
  41882. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41883. autoUpdateBonesMatrices?: boolean,
  41884. /** defines the rendering group id to use with the viewer */
  41885. renderingGroupId?: number);
  41886. /** Gets or sets a boolean indicating if the viewer is enabled */
  41887. isEnabled: boolean;
  41888. private _getBonePosition;
  41889. private _getLinesForBonesWithLength;
  41890. private _getLinesForBonesNoLength;
  41891. /** Update the viewer to sync with current skeleton state */
  41892. update(): void;
  41893. /** Release associated resources */
  41894. dispose(): void;
  41895. }
  41896. }
  41897. declare module "babylonjs/Debug/index" {
  41898. export * from "babylonjs/Debug/axesViewer";
  41899. export * from "babylonjs/Debug/boneAxesViewer";
  41900. export * from "babylonjs/Debug/debugLayer";
  41901. export * from "babylonjs/Debug/physicsViewer";
  41902. export * from "babylonjs/Debug/rayHelper";
  41903. export * from "babylonjs/Debug/skeletonViewer";
  41904. }
  41905. declare module "babylonjs/Engines/nullEngine" {
  41906. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  41907. import { Scene } from "babylonjs/scene";
  41908. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  41909. import { Engine } from "babylonjs/Engines/engine";
  41910. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  41911. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  41912. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41913. import { Effect } from "babylonjs/Materials/effect";
  41914. /**
  41915. * Options to create the null engine
  41916. */
  41917. export class NullEngineOptions {
  41918. /**
  41919. * Render width (Default: 512)
  41920. */
  41921. renderWidth: number;
  41922. /**
  41923. * Render height (Default: 256)
  41924. */
  41925. renderHeight: number;
  41926. /**
  41927. * Texture size (Default: 512)
  41928. */
  41929. textureSize: number;
  41930. /**
  41931. * If delta time between frames should be constant
  41932. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41933. */
  41934. deterministicLockstep: boolean;
  41935. /**
  41936. * Maximum about of steps between frames (Default: 4)
  41937. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41938. */
  41939. lockstepMaxSteps: number;
  41940. }
  41941. /**
  41942. * The null engine class provides support for headless version of babylon.js.
  41943. * This can be used in server side scenario or for testing purposes
  41944. */
  41945. export class NullEngine extends Engine {
  41946. private _options;
  41947. /**
  41948. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41949. */
  41950. isDeterministicLockStep(): boolean;
  41951. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41952. getLockstepMaxSteps(): number;
  41953. /**
  41954. * Sets hardware scaling, used to save performance if needed
  41955. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41956. */
  41957. getHardwareScalingLevel(): number;
  41958. constructor(options?: NullEngineOptions);
  41959. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41960. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  41961. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41962. getRenderWidth(useScreen?: boolean): number;
  41963. getRenderHeight(useScreen?: boolean): number;
  41964. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41965. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41966. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  41967. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  41968. bindSamplers(effect: Effect): void;
  41969. enableEffect(effect: Effect): void;
  41970. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41971. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41972. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41973. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41974. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41975. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41976. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41977. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41978. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41979. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41980. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41981. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41982. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41983. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41984. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41985. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41986. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41987. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41988. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41989. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41990. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41991. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41992. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41993. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41994. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41995. bindBuffers(vertexBuffers: {
  41996. [key: string]: VertexBuffer;
  41997. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  41998. wipeCaches(bruteForce?: boolean): void;
  41999. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42000. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42001. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42002. /** @hidden */
  42003. _createTexture(): WebGLTexture;
  42004. /** @hidden */
  42005. _releaseTexture(texture: InternalTexture): void;
  42006. 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;
  42007. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42008. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42009. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42010. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42011. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  42012. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42013. areAllEffectsReady(): boolean;
  42014. /**
  42015. * @hidden
  42016. * Get the current error code of the webGL context
  42017. * @returns the error code
  42018. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42019. */
  42020. getError(): number;
  42021. /** @hidden */
  42022. _getUnpackAlignement(): number;
  42023. /** @hidden */
  42024. _unpackFlipY(value: boolean): void;
  42025. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42026. /**
  42027. * Updates a dynamic vertex buffer.
  42028. * @param vertexBuffer the vertex buffer to update
  42029. * @param data the data used to update the vertex buffer
  42030. * @param byteOffset the byte offset of the data (optional)
  42031. * @param byteLength the byte length of the data (optional)
  42032. */
  42033. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  42034. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42035. /** @hidden */
  42036. _bindTexture(channel: number, texture: InternalTexture): void;
  42037. /** @hidden */
  42038. _releaseBuffer(buffer: WebGLBuffer): boolean;
  42039. releaseEffects(): void;
  42040. displayLoadingUI(): void;
  42041. hideLoadingUI(): void;
  42042. /** @hidden */
  42043. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42044. /** @hidden */
  42045. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42046. /** @hidden */
  42047. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42048. /** @hidden */
  42049. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42050. }
  42051. }
  42052. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  42053. import { Nullable, int } from "babylonjs/types";
  42054. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  42055. /** @hidden */
  42056. export class _OcclusionDataStorage {
  42057. /** @hidden */
  42058. occlusionInternalRetryCounter: number;
  42059. /** @hidden */
  42060. isOcclusionQueryInProgress: boolean;
  42061. /** @hidden */
  42062. isOccluded: boolean;
  42063. /** @hidden */
  42064. occlusionRetryCount: number;
  42065. /** @hidden */
  42066. occlusionType: number;
  42067. /** @hidden */
  42068. occlusionQueryAlgorithmType: number;
  42069. }
  42070. module "babylonjs/Engines/engine" {
  42071. interface Engine {
  42072. /**
  42073. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42074. * @return the new query
  42075. */
  42076. createQuery(): WebGLQuery;
  42077. /**
  42078. * Delete and release a webGL query
  42079. * @param query defines the query to delete
  42080. * @return the current engine
  42081. */
  42082. deleteQuery(query: WebGLQuery): Engine;
  42083. /**
  42084. * Check if a given query has resolved and got its value
  42085. * @param query defines the query to check
  42086. * @returns true if the query got its value
  42087. */
  42088. isQueryResultAvailable(query: WebGLQuery): boolean;
  42089. /**
  42090. * Gets the value of a given query
  42091. * @param query defines the query to check
  42092. * @returns the value of the query
  42093. */
  42094. getQueryResult(query: WebGLQuery): number;
  42095. /**
  42096. * Initiates an occlusion query
  42097. * @param algorithmType defines the algorithm to use
  42098. * @param query defines the query to use
  42099. * @returns the current engine
  42100. * @see http://doc.babylonjs.com/features/occlusionquery
  42101. */
  42102. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42103. /**
  42104. * Ends an occlusion query
  42105. * @see http://doc.babylonjs.com/features/occlusionquery
  42106. * @param algorithmType defines the algorithm to use
  42107. * @returns the current engine
  42108. */
  42109. endOcclusionQuery(algorithmType: number): Engine;
  42110. /**
  42111. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42112. * Please note that only one query can be issued at a time
  42113. * @returns a time token used to track the time span
  42114. */
  42115. startTimeQuery(): Nullable<_TimeToken>;
  42116. /**
  42117. * Ends a time query
  42118. * @param token defines the token used to measure the time span
  42119. * @returns the time spent (in ns)
  42120. */
  42121. endTimeQuery(token: _TimeToken): int;
  42122. /** @hidden */
  42123. _currentNonTimestampToken: Nullable<_TimeToken>;
  42124. /** @hidden */
  42125. _createTimeQuery(): WebGLQuery;
  42126. /** @hidden */
  42127. _deleteTimeQuery(query: WebGLQuery): void;
  42128. /** @hidden */
  42129. _getGlAlgorithmType(algorithmType: number): number;
  42130. /** @hidden */
  42131. _getTimeQueryResult(query: WebGLQuery): any;
  42132. /** @hidden */
  42133. _getTimeQueryAvailability(query: WebGLQuery): any;
  42134. }
  42135. }
  42136. module "babylonjs/Meshes/abstractMesh" {
  42137. interface AbstractMesh {
  42138. /**
  42139. * Backing filed
  42140. * @hidden
  42141. */
  42142. __occlusionDataStorage: _OcclusionDataStorage;
  42143. /**
  42144. * Access property
  42145. * @hidden
  42146. */
  42147. _occlusionDataStorage: _OcclusionDataStorage;
  42148. /**
  42149. * 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.
  42150. * The default value is -1 which means don't break the query and wait till the result
  42151. * @see http://doc.babylonjs.com/features/occlusionquery
  42152. */
  42153. occlusionRetryCount: number;
  42154. /**
  42155. * 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:
  42156. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42157. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42158. * * 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.
  42159. * @see http://doc.babylonjs.com/features/occlusionquery
  42160. */
  42161. occlusionType: number;
  42162. /**
  42163. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42164. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42165. * * 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.
  42166. * @see http://doc.babylonjs.com/features/occlusionquery
  42167. */
  42168. occlusionQueryAlgorithmType: number;
  42169. /**
  42170. * 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
  42171. * @see http://doc.babylonjs.com/features/occlusionquery
  42172. */
  42173. isOccluded: boolean;
  42174. /**
  42175. * Flag to check the progress status of the query
  42176. * @see http://doc.babylonjs.com/features/occlusionquery
  42177. */
  42178. isOcclusionQueryInProgress: boolean;
  42179. }
  42180. }
  42181. }
  42182. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  42183. import { Nullable } from "babylonjs/types";
  42184. /** @hidden */
  42185. export var _forceTransformFeedbackToBundle: boolean;
  42186. module "babylonjs/Engines/engine" {
  42187. interface Engine {
  42188. /**
  42189. * Creates a webGL transform feedback object
  42190. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42191. * @returns the webGL transform feedback object
  42192. */
  42193. createTransformFeedback(): WebGLTransformFeedback;
  42194. /**
  42195. * Delete a webGL transform feedback object
  42196. * @param value defines the webGL transform feedback object to delete
  42197. */
  42198. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42199. /**
  42200. * Bind a webGL transform feedback object to the webgl context
  42201. * @param value defines the webGL transform feedback object to bind
  42202. */
  42203. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42204. /**
  42205. * Begins a transform feedback operation
  42206. * @param usePoints defines if points or triangles must be used
  42207. */
  42208. beginTransformFeedback(usePoints: boolean): void;
  42209. /**
  42210. * Ends a transform feedback operation
  42211. */
  42212. endTransformFeedback(): void;
  42213. /**
  42214. * Specify the varyings to use with transform feedback
  42215. * @param program defines the associated webGL program
  42216. * @param value defines the list of strings representing the varying names
  42217. */
  42218. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42219. /**
  42220. * Bind a webGL buffer for a transform feedback operation
  42221. * @param value defines the webGL buffer to bind
  42222. */
  42223. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  42224. }
  42225. }
  42226. }
  42227. declare module "babylonjs/Engines/Extensions/index" {
  42228. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  42229. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  42230. }
  42231. declare module "babylonjs/Engines/index" {
  42232. export * from "babylonjs/Engines/constants";
  42233. export * from "babylonjs/Engines/engine";
  42234. export * from "babylonjs/Engines/engineStore";
  42235. export * from "babylonjs/Engines/nullEngine";
  42236. export * from "babylonjs/Engines/Extensions/index";
  42237. }
  42238. declare module "babylonjs/Events/clipboardEvents" {
  42239. /**
  42240. * Gather the list of clipboard event types as constants.
  42241. */
  42242. export class ClipboardEventTypes {
  42243. /**
  42244. * The clipboard event is fired when a copy command is active (pressed).
  42245. */
  42246. static readonly COPY: number;
  42247. /**
  42248. * The clipboard event is fired when a cut command is active (pressed).
  42249. */
  42250. static readonly CUT: number;
  42251. /**
  42252. * The clipboard event is fired when a paste command is active (pressed).
  42253. */
  42254. static readonly PASTE: number;
  42255. }
  42256. /**
  42257. * This class is used to store clipboard related info for the onClipboardObservable event.
  42258. */
  42259. export class ClipboardInfo {
  42260. /**
  42261. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42262. */
  42263. type: number;
  42264. /**
  42265. * Defines the related dom event
  42266. */
  42267. event: ClipboardEvent;
  42268. /**
  42269. *Creates an instance of ClipboardInfo.
  42270. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  42271. * @param event Defines the related dom event
  42272. */
  42273. constructor(
  42274. /**
  42275. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42276. */
  42277. type: number,
  42278. /**
  42279. * Defines the related dom event
  42280. */
  42281. event: ClipboardEvent);
  42282. /**
  42283. * Get the clipboard event's type from the keycode.
  42284. * @param keyCode Defines the keyCode for the current keyboard event.
  42285. * @return {number}
  42286. */
  42287. static GetTypeFromCharacter(keyCode: number): number;
  42288. }
  42289. }
  42290. declare module "babylonjs/Events/index" {
  42291. export * from "babylonjs/Events/keyboardEvents";
  42292. export * from "babylonjs/Events/pointerEvents";
  42293. export * from "babylonjs/Events/clipboardEvents";
  42294. }
  42295. declare module "babylonjs/Loading/sceneLoader" {
  42296. import { Observable } from "babylonjs/Misc/observable";
  42297. import { Nullable } from "babylonjs/types";
  42298. import { Scene } from "babylonjs/scene";
  42299. import { Engine } from "babylonjs/Engines/engine";
  42300. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42301. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42302. import { AssetContainer } from "babylonjs/assetContainer";
  42303. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42304. import { Skeleton } from "babylonjs/Bones/skeleton";
  42305. /**
  42306. * Class used to represent data loading progression
  42307. */
  42308. export class SceneLoaderProgressEvent {
  42309. /** defines if data length to load can be evaluated */
  42310. readonly lengthComputable: boolean;
  42311. /** defines the loaded data length */
  42312. readonly loaded: number;
  42313. /** defines the data length to load */
  42314. readonly total: number;
  42315. /**
  42316. * Create a new progress event
  42317. * @param lengthComputable defines if data length to load can be evaluated
  42318. * @param loaded defines the loaded data length
  42319. * @param total defines the data length to load
  42320. */
  42321. constructor(
  42322. /** defines if data length to load can be evaluated */
  42323. lengthComputable: boolean,
  42324. /** defines the loaded data length */
  42325. loaded: number,
  42326. /** defines the data length to load */
  42327. total: number);
  42328. /**
  42329. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42330. * @param event defines the source event
  42331. * @returns a new SceneLoaderProgressEvent
  42332. */
  42333. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42334. }
  42335. /**
  42336. * Interface used by SceneLoader plugins to define supported file extensions
  42337. */
  42338. export interface ISceneLoaderPluginExtensions {
  42339. /**
  42340. * Defines the list of supported extensions
  42341. */
  42342. [extension: string]: {
  42343. isBinary: boolean;
  42344. };
  42345. }
  42346. /**
  42347. * Interface used by SceneLoader plugin factory
  42348. */
  42349. export interface ISceneLoaderPluginFactory {
  42350. /**
  42351. * Defines the name of the factory
  42352. */
  42353. name: string;
  42354. /**
  42355. * Function called to create a new plugin
  42356. * @return the new plugin
  42357. */
  42358. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42359. /**
  42360. * Boolean indicating if the plugin can direct load specific data
  42361. */
  42362. canDirectLoad?: (data: string) => boolean;
  42363. }
  42364. /**
  42365. * Interface used to define a SceneLoader plugin
  42366. */
  42367. export interface ISceneLoaderPlugin {
  42368. /**
  42369. * The friendly name of this plugin.
  42370. */
  42371. name: string;
  42372. /**
  42373. * The file extensions supported by this plugin.
  42374. */
  42375. extensions: string | ISceneLoaderPluginExtensions;
  42376. /**
  42377. * Import meshes into a scene.
  42378. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42379. * @param scene The scene to import into
  42380. * @param data The data to import
  42381. * @param rootUrl The root url for scene and resources
  42382. * @param meshes The meshes array to import into
  42383. * @param particleSystems The particle systems array to import into
  42384. * @param skeletons The skeletons array to import into
  42385. * @param onError The callback when import fails
  42386. * @returns True if successful or false otherwise
  42387. */
  42388. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42389. /**
  42390. * Load into a scene.
  42391. * @param scene The scene to load into
  42392. * @param data The data to import
  42393. * @param rootUrl The root url for scene and resources
  42394. * @param onError The callback when import fails
  42395. * @returns true if successful or false otherwise
  42396. */
  42397. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42398. /**
  42399. * The callback that returns true if the data can be directly loaded.
  42400. */
  42401. canDirectLoad?: (data: string) => boolean;
  42402. /**
  42403. * The callback that allows custom handling of the root url based on the response url.
  42404. */
  42405. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42406. /**
  42407. * Load into an asset container.
  42408. * @param scene The scene to load into
  42409. * @param data The data to import
  42410. * @param rootUrl The root url for scene and resources
  42411. * @param onError The callback when import fails
  42412. * @returns The loaded asset container
  42413. */
  42414. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42415. }
  42416. /**
  42417. * Interface used to define an async SceneLoader plugin
  42418. */
  42419. export interface ISceneLoaderPluginAsync {
  42420. /**
  42421. * The friendly name of this plugin.
  42422. */
  42423. name: string;
  42424. /**
  42425. * The file extensions supported by this plugin.
  42426. */
  42427. extensions: string | ISceneLoaderPluginExtensions;
  42428. /**
  42429. * Import meshes into a scene.
  42430. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42431. * @param scene The scene to import into
  42432. * @param data The data to import
  42433. * @param rootUrl The root url for scene and resources
  42434. * @param onProgress The callback when the load progresses
  42435. * @param fileName Defines the name of the file to load
  42436. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42437. */
  42438. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42439. meshes: AbstractMesh[];
  42440. particleSystems: IParticleSystem[];
  42441. skeletons: Skeleton[];
  42442. animationGroups: AnimationGroup[];
  42443. }>;
  42444. /**
  42445. * Load into a scene.
  42446. * @param scene The scene to load into
  42447. * @param data The data to import
  42448. * @param rootUrl The root url for scene and resources
  42449. * @param onProgress The callback when the load progresses
  42450. * @param fileName Defines the name of the file to load
  42451. * @returns Nothing
  42452. */
  42453. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42454. /**
  42455. * The callback that returns true if the data can be directly loaded.
  42456. */
  42457. canDirectLoad?: (data: string) => boolean;
  42458. /**
  42459. * The callback that allows custom handling of the root url based on the response url.
  42460. */
  42461. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42462. /**
  42463. * Load into an asset container.
  42464. * @param scene The scene to load into
  42465. * @param data The data to import
  42466. * @param rootUrl The root url for scene and resources
  42467. * @param onProgress The callback when the load progresses
  42468. * @param fileName Defines the name of the file to load
  42469. * @returns The loaded asset container
  42470. */
  42471. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42472. }
  42473. /**
  42474. * Class used to load scene from various file formats using registered plugins
  42475. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42476. */
  42477. export class SceneLoader {
  42478. /**
  42479. * No logging while loading
  42480. */
  42481. static readonly NO_LOGGING: number;
  42482. /**
  42483. * Minimal logging while loading
  42484. */
  42485. static readonly MINIMAL_LOGGING: number;
  42486. /**
  42487. * Summary logging while loading
  42488. */
  42489. static readonly SUMMARY_LOGGING: number;
  42490. /**
  42491. * Detailled logging while loading
  42492. */
  42493. static readonly DETAILED_LOGGING: number;
  42494. /**
  42495. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42496. */
  42497. static ForceFullSceneLoadingForIncremental: boolean;
  42498. /**
  42499. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42500. */
  42501. static ShowLoadingScreen: boolean;
  42502. /**
  42503. * Defines the current logging level (while loading the scene)
  42504. * @ignorenaming
  42505. */
  42506. static loggingLevel: number;
  42507. /**
  42508. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42509. */
  42510. static CleanBoneMatrixWeights: boolean;
  42511. /**
  42512. * Event raised when a plugin is used to load a scene
  42513. */
  42514. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42515. private static _registeredPlugins;
  42516. private static _getDefaultPlugin;
  42517. private static _getPluginForExtension;
  42518. private static _getPluginForDirectLoad;
  42519. private static _getPluginForFilename;
  42520. private static _getDirectLoad;
  42521. private static _loadData;
  42522. private static _getFileInfo;
  42523. /**
  42524. * Gets a plugin that can load the given extension
  42525. * @param extension defines the extension to load
  42526. * @returns a plugin or null if none works
  42527. */
  42528. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42529. /**
  42530. * Gets a boolean indicating that the given extension can be loaded
  42531. * @param extension defines the extension to load
  42532. * @returns true if the extension is supported
  42533. */
  42534. static IsPluginForExtensionAvailable(extension: string): boolean;
  42535. /**
  42536. * Adds a new plugin to the list of registered plugins
  42537. * @param plugin defines the plugin to add
  42538. */
  42539. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42540. /**
  42541. * Import meshes into a scene
  42542. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  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 or a File object (default: empty string)
  42545. * @param scene the instance of BABYLON.Scene to append to
  42546. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42547. * @param onProgress a callback with a progress event for each file being loaded
  42548. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42549. * @param pluginExtension the extension used to determine the plugin
  42550. * @returns The loaded plugin
  42551. */
  42552. 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>;
  42553. /**
  42554. * Import meshes into a scene
  42555. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42556. * @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)
  42557. * @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)
  42558. * @param scene the instance of BABYLON.Scene to append to
  42559. * @param onProgress a callback with a progress event for each file being loaded
  42560. * @param pluginExtension the extension used to determine the plugin
  42561. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42562. */
  42563. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42564. meshes: AbstractMesh[];
  42565. particleSystems: IParticleSystem[];
  42566. skeletons: Skeleton[];
  42567. animationGroups: AnimationGroup[];
  42568. }>;
  42569. /**
  42570. * Load a scene
  42571. * @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)
  42572. * @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)
  42573. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42574. * @param onSuccess a callback with the scene when import succeeds
  42575. * @param onProgress a callback with a progress event for each file being loaded
  42576. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42577. * @param pluginExtension the extension used to determine the plugin
  42578. * @returns The loaded plugin
  42579. */
  42580. 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>;
  42581. /**
  42582. * Load a scene
  42583. * @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)
  42584. * @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)
  42585. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42586. * @param onProgress a callback with a progress event for each file being loaded
  42587. * @param pluginExtension the extension used to determine the plugin
  42588. * @returns The loaded scene
  42589. */
  42590. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42591. /**
  42592. * Append a scene
  42593. * @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)
  42594. * @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)
  42595. * @param scene is the instance of BABYLON.Scene to append to
  42596. * @param onSuccess a callback with the scene when import succeeds
  42597. * @param onProgress a callback with a progress event for each file being loaded
  42598. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42599. * @param pluginExtension the extension used to determine the plugin
  42600. * @returns The loaded plugin
  42601. */
  42602. 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>;
  42603. /**
  42604. * Append a scene
  42605. * @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)
  42606. * @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)
  42607. * @param scene is the instance of BABYLON.Scene to append to
  42608. * @param onProgress a callback with a progress event for each file being loaded
  42609. * @param pluginExtension the extension used to determine the plugin
  42610. * @returns The given scene
  42611. */
  42612. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42613. /**
  42614. * Load a scene into an asset container
  42615. * @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)
  42616. * @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)
  42617. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42618. * @param onSuccess a callback with the scene when import succeeds
  42619. * @param onProgress a callback with a progress event for each file being loaded
  42620. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42621. * @param pluginExtension the extension used to determine the plugin
  42622. * @returns The loaded plugin
  42623. */
  42624. 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>;
  42625. /**
  42626. * Load a scene into an asset container
  42627. * @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)
  42628. * @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)
  42629. * @param scene is the instance of Scene to append to
  42630. * @param onProgress a callback with a progress event for each file being loaded
  42631. * @param pluginExtension the extension used to determine the plugin
  42632. * @returns The loaded asset container
  42633. */
  42634. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42635. }
  42636. }
  42637. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  42638. import { Scene } from "babylonjs/scene";
  42639. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42640. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42641. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42642. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42643. /**
  42644. * Google Daydream controller
  42645. */
  42646. export class DaydreamController extends WebVRController {
  42647. /**
  42648. * Base Url for the controller model.
  42649. */
  42650. static MODEL_BASE_URL: string;
  42651. /**
  42652. * File name for the controller model.
  42653. */
  42654. static MODEL_FILENAME: string;
  42655. /**
  42656. * Gamepad Id prefix used to identify Daydream Controller.
  42657. */
  42658. static readonly GAMEPAD_ID_PREFIX: string;
  42659. /**
  42660. * Creates a new DaydreamController from a gamepad
  42661. * @param vrGamepad the gamepad that the controller should be created from
  42662. */
  42663. constructor(vrGamepad: any);
  42664. /**
  42665. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42666. * @param scene scene in which to add meshes
  42667. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42668. */
  42669. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42670. /**
  42671. * Called once for each button that changed state since the last frame
  42672. * @param buttonIdx Which button index changed
  42673. * @param state New state of the button
  42674. * @param changes Which properties on the state changed since last frame
  42675. */
  42676. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42677. }
  42678. }
  42679. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  42680. import { Scene } from "babylonjs/scene";
  42681. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42682. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42683. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42684. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42685. /**
  42686. * Gear VR Controller
  42687. */
  42688. export class GearVRController extends WebVRController {
  42689. /**
  42690. * Base Url for the controller model.
  42691. */
  42692. static MODEL_BASE_URL: string;
  42693. /**
  42694. * File name for the controller model.
  42695. */
  42696. static MODEL_FILENAME: string;
  42697. /**
  42698. * Gamepad Id prefix used to identify this controller.
  42699. */
  42700. static readonly GAMEPAD_ID_PREFIX: string;
  42701. private readonly _buttonIndexToObservableNameMap;
  42702. /**
  42703. * Creates a new GearVRController from a gamepad
  42704. * @param vrGamepad the gamepad that the controller should be created from
  42705. */
  42706. constructor(vrGamepad: any);
  42707. /**
  42708. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42709. * @param scene scene in which to add meshes
  42710. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42711. */
  42712. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42713. /**
  42714. * Called once for each button that changed state since the last frame
  42715. * @param buttonIdx Which button index changed
  42716. * @param state New state of the button
  42717. * @param changes Which properties on the state changed since last frame
  42718. */
  42719. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42720. }
  42721. }
  42722. declare module "babylonjs/Gamepads/Controllers/genericController" {
  42723. import { Scene } from "babylonjs/scene";
  42724. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42725. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42726. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42727. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42728. /**
  42729. * Generic Controller
  42730. */
  42731. export class GenericController extends WebVRController {
  42732. /**
  42733. * Base Url for the controller model.
  42734. */
  42735. static readonly MODEL_BASE_URL: string;
  42736. /**
  42737. * File name for the controller model.
  42738. */
  42739. static readonly MODEL_FILENAME: string;
  42740. /**
  42741. * Creates a new GenericController from a gamepad
  42742. * @param vrGamepad the gamepad that the controller should be created from
  42743. */
  42744. constructor(vrGamepad: any);
  42745. /**
  42746. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42747. * @param scene scene in which to add meshes
  42748. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42749. */
  42750. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42751. /**
  42752. * Called once for each button that changed state since the last frame
  42753. * @param buttonIdx Which button index changed
  42754. * @param state New state of the button
  42755. * @param changes Which properties on the state changed since last frame
  42756. */
  42757. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42758. }
  42759. }
  42760. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  42761. import { Observable } from "babylonjs/Misc/observable";
  42762. import { Scene } from "babylonjs/scene";
  42763. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42764. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42765. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42766. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42767. /**
  42768. * Oculus Touch Controller
  42769. */
  42770. export class OculusTouchController extends WebVRController {
  42771. /**
  42772. * Base Url for the controller model.
  42773. */
  42774. static MODEL_BASE_URL: string;
  42775. /**
  42776. * File name for the left controller model.
  42777. */
  42778. static MODEL_LEFT_FILENAME: string;
  42779. /**
  42780. * File name for the right controller model.
  42781. */
  42782. static MODEL_RIGHT_FILENAME: string;
  42783. /**
  42784. * Fired when the secondary trigger on this controller is modified
  42785. */
  42786. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42787. /**
  42788. * Fired when the thumb rest on this controller is modified
  42789. */
  42790. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42791. /**
  42792. * Creates a new OculusTouchController from a gamepad
  42793. * @param vrGamepad the gamepad that the controller should be created from
  42794. */
  42795. constructor(vrGamepad: any);
  42796. /**
  42797. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42798. * @param scene scene in which to add meshes
  42799. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42800. */
  42801. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42802. /**
  42803. * Fired when the A button on this controller is modified
  42804. */
  42805. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42806. /**
  42807. * Fired when the B button on this controller is modified
  42808. */
  42809. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42810. /**
  42811. * Fired when the X button on this controller is modified
  42812. */
  42813. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42814. /**
  42815. * Fired when the Y button on this controller is modified
  42816. */
  42817. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42818. /**
  42819. * Called once for each button that changed state since the last frame
  42820. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42821. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42822. * 2) secondary trigger (same)
  42823. * 3) A (right) X (left), touch, pressed = value
  42824. * 4) B / Y
  42825. * 5) thumb rest
  42826. * @param buttonIdx Which button index changed
  42827. * @param state New state of the button
  42828. * @param changes Which properties on the state changed since last frame
  42829. */
  42830. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42831. }
  42832. }
  42833. declare module "babylonjs/Gamepads/Controllers/viveController" {
  42834. import { Scene } from "babylonjs/scene";
  42835. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42836. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42837. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42838. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42839. import { Observable } from "babylonjs/Misc/observable";
  42840. /**
  42841. * Vive Controller
  42842. */
  42843. export class ViveController extends WebVRController {
  42844. /**
  42845. * Base Url for the controller model.
  42846. */
  42847. static MODEL_BASE_URL: string;
  42848. /**
  42849. * File name for the controller model.
  42850. */
  42851. static MODEL_FILENAME: string;
  42852. /**
  42853. * Creates a new ViveController from a gamepad
  42854. * @param vrGamepad the gamepad that the controller should be created from
  42855. */
  42856. constructor(vrGamepad: any);
  42857. /**
  42858. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42859. * @param scene scene in which to add meshes
  42860. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42861. */
  42862. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42863. /**
  42864. * Fired when the left button on this controller is modified
  42865. */
  42866. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42867. /**
  42868. * Fired when the right button on this controller is modified
  42869. */
  42870. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42871. /**
  42872. * Fired when the menu button on this controller is modified
  42873. */
  42874. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42875. /**
  42876. * Called once for each button that changed state since the last frame
  42877. * Vive mapping:
  42878. * 0: touchpad
  42879. * 1: trigger
  42880. * 2: left AND right buttons
  42881. * 3: menu button
  42882. * @param buttonIdx Which button index changed
  42883. * @param state New state of the button
  42884. * @param changes Which properties on the state changed since last frame
  42885. */
  42886. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42887. }
  42888. }
  42889. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  42890. import { Observable } from "babylonjs/Misc/observable";
  42891. import { Scene } from "babylonjs/scene";
  42892. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42893. import { Ray } from "babylonjs/Culling/ray";
  42894. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42895. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42896. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42897. /**
  42898. * Defines the WindowsMotionController object that the state of the windows motion controller
  42899. */
  42900. export class WindowsMotionController extends WebVRController {
  42901. /**
  42902. * The base url used to load the left and right controller models
  42903. */
  42904. static MODEL_BASE_URL: string;
  42905. /**
  42906. * The name of the left controller model file
  42907. */
  42908. static MODEL_LEFT_FILENAME: string;
  42909. /**
  42910. * The name of the right controller model file
  42911. */
  42912. static MODEL_RIGHT_FILENAME: string;
  42913. /**
  42914. * The controller name prefix for this controller type
  42915. */
  42916. static readonly GAMEPAD_ID_PREFIX: string;
  42917. /**
  42918. * The controller id pattern for this controller type
  42919. */
  42920. private static readonly GAMEPAD_ID_PATTERN;
  42921. private _loadedMeshInfo;
  42922. private readonly _mapping;
  42923. /**
  42924. * Fired when the trackpad on this controller is clicked
  42925. */
  42926. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42927. /**
  42928. * Fired when the trackpad on this controller is modified
  42929. */
  42930. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42931. /**
  42932. * The current x and y values of this controller's trackpad
  42933. */
  42934. trackpad: StickValues;
  42935. /**
  42936. * Creates a new WindowsMotionController from a gamepad
  42937. * @param vrGamepad the gamepad that the controller should be created from
  42938. */
  42939. constructor(vrGamepad: any);
  42940. /**
  42941. * Fired when the trigger on this controller is modified
  42942. */
  42943. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42944. /**
  42945. * Fired when the menu button on this controller is modified
  42946. */
  42947. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42948. /**
  42949. * Fired when the grip button on this controller is modified
  42950. */
  42951. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42952. /**
  42953. * Fired when the thumbstick button on this controller is modified
  42954. */
  42955. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42956. /**
  42957. * Fired when the touchpad button on this controller is modified
  42958. */
  42959. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42960. /**
  42961. * Fired when the touchpad values on this controller are modified
  42962. */
  42963. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42964. private _updateTrackpad;
  42965. /**
  42966. * Called once per frame by the engine.
  42967. */
  42968. update(): void;
  42969. /**
  42970. * Called once for each button that changed state since the last frame
  42971. * @param buttonIdx Which button index changed
  42972. * @param state New state of the button
  42973. * @param changes Which properties on the state changed since last frame
  42974. */
  42975. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42976. /**
  42977. * Moves the buttons on the controller mesh based on their current state
  42978. * @param buttonName the name of the button to move
  42979. * @param buttonValue the value of the button which determines the buttons new position
  42980. */
  42981. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42982. /**
  42983. * Moves the axis on the controller mesh based on its current state
  42984. * @param axis the index of the axis
  42985. * @param axisValue the value of the axis which determines the meshes new position
  42986. * @hidden
  42987. */
  42988. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42989. /**
  42990. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42991. * @param scene scene in which to add meshes
  42992. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42993. */
  42994. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42995. /**
  42996. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42997. * can be transformed by button presses and axes values, based on this._mapping.
  42998. *
  42999. * @param scene scene in which the meshes exist
  43000. * @param meshes list of meshes that make up the controller model to process
  43001. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43002. */
  43003. private processModel;
  43004. private createMeshInfo;
  43005. /**
  43006. * Gets the ray of the controller in the direction the controller is pointing
  43007. * @param length the length the resulting ray should be
  43008. * @returns a ray in the direction the controller is pointing
  43009. */
  43010. getForwardRay(length?: number): Ray;
  43011. /**
  43012. * Disposes of the controller
  43013. */
  43014. dispose(): void;
  43015. }
  43016. }
  43017. declare module "babylonjs/Gamepads/Controllers/index" {
  43018. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  43019. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  43020. export * from "babylonjs/Gamepads/Controllers/genericController";
  43021. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  43022. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43023. export * from "babylonjs/Gamepads/Controllers/viveController";
  43024. export * from "babylonjs/Gamepads/Controllers/webVRController";
  43025. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  43026. }
  43027. declare module "babylonjs/Gamepads/index" {
  43028. export * from "babylonjs/Gamepads/Controllers/index";
  43029. export * from "babylonjs/Gamepads/gamepad";
  43030. export * from "babylonjs/Gamepads/gamepadManager";
  43031. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  43032. export * from "babylonjs/Gamepads/xboxGamepad";
  43033. }
  43034. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  43035. import { Observable } from "babylonjs/Misc/observable";
  43036. import { Nullable } from "babylonjs/types";
  43037. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43038. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43039. import { Mesh } from "babylonjs/Meshes/mesh";
  43040. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43041. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43042. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43043. /**
  43044. * Single axis scale gizmo
  43045. */
  43046. export class AxisScaleGizmo extends Gizmo {
  43047. private _coloredMaterial;
  43048. /**
  43049. * Drag behavior responsible for the gizmos dragging interactions
  43050. */
  43051. dragBehavior: PointerDragBehavior;
  43052. private _pointerObserver;
  43053. /**
  43054. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43055. */
  43056. snapDistance: number;
  43057. /**
  43058. * Event that fires each time the gizmo snaps to a new location.
  43059. * * snapDistance is the the change in distance
  43060. */
  43061. onSnapObservable: Observable<{
  43062. snapDistance: number;
  43063. }>;
  43064. /**
  43065. * If the scaling operation should be done on all axis (default: false)
  43066. */
  43067. uniformScaling: boolean;
  43068. /**
  43069. * Creates an AxisScaleGizmo
  43070. * @param gizmoLayer The utility layer the gizmo will be added to
  43071. * @param dragAxis The axis which the gizmo will be able to scale on
  43072. * @param color The color of the gizmo
  43073. */
  43074. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43075. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43076. /**
  43077. * Disposes of the gizmo
  43078. */
  43079. dispose(): void;
  43080. /**
  43081. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43082. * @param mesh The mesh to replace the default mesh of the gizmo
  43083. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43084. */
  43085. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43086. }
  43087. }
  43088. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  43089. import { Observable } from "babylonjs/Misc/observable";
  43090. import { Nullable } from "babylonjs/types";
  43091. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43092. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43093. import { Mesh } from "babylonjs/Meshes/mesh";
  43094. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43095. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43096. import "babylonjs/Meshes/Builders/boxBuilder";
  43097. /**
  43098. * Bounding box gizmo
  43099. */
  43100. export class BoundingBoxGizmo extends Gizmo {
  43101. private _lineBoundingBox;
  43102. private _rotateSpheresParent;
  43103. private _scaleBoxesParent;
  43104. private _boundingDimensions;
  43105. private _renderObserver;
  43106. private _pointerObserver;
  43107. private _scaleDragSpeed;
  43108. private _tmpQuaternion;
  43109. private _tmpVector;
  43110. private _tmpRotationMatrix;
  43111. /**
  43112. * 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)
  43113. */
  43114. ignoreChildren: boolean;
  43115. /**
  43116. * 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)
  43117. */
  43118. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43119. /**
  43120. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43121. */
  43122. rotationSphereSize: number;
  43123. /**
  43124. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43125. */
  43126. scaleBoxSize: number;
  43127. /**
  43128. * 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)
  43129. */
  43130. fixedDragMeshScreenSize: boolean;
  43131. /**
  43132. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43133. */
  43134. fixedDragMeshScreenSizeDistanceFactor: number;
  43135. /**
  43136. * Fired when a rotation sphere or scale box is dragged
  43137. */
  43138. onDragStartObservable: Observable<{}>;
  43139. /**
  43140. * Fired when a scale box is dragged
  43141. */
  43142. onScaleBoxDragObservable: Observable<{}>;
  43143. /**
  43144. * Fired when a scale box drag is ended
  43145. */
  43146. onScaleBoxDragEndObservable: Observable<{}>;
  43147. /**
  43148. * Fired when a rotation sphere is dragged
  43149. */
  43150. onRotationSphereDragObservable: Observable<{}>;
  43151. /**
  43152. * Fired when a rotation sphere drag is ended
  43153. */
  43154. onRotationSphereDragEndObservable: Observable<{}>;
  43155. /**
  43156. * 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)
  43157. */
  43158. scalePivot: Nullable<Vector3>;
  43159. private _anchorMesh;
  43160. private _existingMeshScale;
  43161. private _dragMesh;
  43162. private pointerDragBehavior;
  43163. private coloredMaterial;
  43164. private hoverColoredMaterial;
  43165. /**
  43166. * Sets the color of the bounding box gizmo
  43167. * @param color the color to set
  43168. */
  43169. setColor(color: Color3): void;
  43170. /**
  43171. * Creates an BoundingBoxGizmo
  43172. * @param gizmoLayer The utility layer the gizmo will be added to
  43173. * @param color The color of the gizmo
  43174. */
  43175. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43176. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43177. private _selectNode;
  43178. /**
  43179. * Updates the bounding box information for the Gizmo
  43180. */
  43181. updateBoundingBox(): void;
  43182. private _updateRotationSpheres;
  43183. private _updateScaleBoxes;
  43184. /**
  43185. * Enables rotation on the specified axis and disables rotation on the others
  43186. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43187. */
  43188. setEnabledRotationAxis(axis: string): void;
  43189. /**
  43190. * Enables/disables scaling
  43191. * @param enable if scaling should be enabled
  43192. */
  43193. setEnabledScaling(enable: boolean): void;
  43194. private _updateDummy;
  43195. /**
  43196. * Enables a pointer drag behavior on the bounding box of the gizmo
  43197. */
  43198. enableDragBehavior(): void;
  43199. /**
  43200. * Disposes of the gizmo
  43201. */
  43202. dispose(): void;
  43203. /**
  43204. * 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)
  43205. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43206. * @returns the bounding box mesh with the passed in mesh as a child
  43207. */
  43208. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43209. /**
  43210. * CustomMeshes are not supported by this gizmo
  43211. * @param mesh The mesh to replace the default mesh of the gizmo
  43212. */
  43213. setCustomMesh(mesh: Mesh): void;
  43214. }
  43215. }
  43216. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  43217. import { Observable } from "babylonjs/Misc/observable";
  43218. import { Nullable } from "babylonjs/types";
  43219. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43220. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43221. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43222. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43223. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43224. import "babylonjs/Meshes/Builders/linesBuilder";
  43225. /**
  43226. * Single plane rotation gizmo
  43227. */
  43228. export class PlaneRotationGizmo extends Gizmo {
  43229. /**
  43230. * Drag behavior responsible for the gizmos dragging interactions
  43231. */
  43232. dragBehavior: PointerDragBehavior;
  43233. private _pointerObserver;
  43234. /**
  43235. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43236. */
  43237. snapDistance: number;
  43238. /**
  43239. * Event that fires each time the gizmo snaps to a new location.
  43240. * * snapDistance is the the change in distance
  43241. */
  43242. onSnapObservable: Observable<{
  43243. snapDistance: number;
  43244. }>;
  43245. /**
  43246. * Creates a PlaneRotationGizmo
  43247. * @param gizmoLayer The utility layer the gizmo will be added to
  43248. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43249. * @param color The color of the gizmo
  43250. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43251. */
  43252. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43253. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43254. /**
  43255. * Disposes of the gizmo
  43256. */
  43257. dispose(): void;
  43258. }
  43259. }
  43260. declare module "babylonjs/Gizmos/rotationGizmo" {
  43261. import { Observable } from "babylonjs/Misc/observable";
  43262. import { Nullable } from "babylonjs/types";
  43263. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43264. import { Mesh } from "babylonjs/Meshes/mesh";
  43265. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43266. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  43267. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43268. /**
  43269. * Gizmo that enables rotating a mesh along 3 axis
  43270. */
  43271. export class RotationGizmo extends Gizmo {
  43272. /**
  43273. * Internal gizmo used for interactions on the x axis
  43274. */
  43275. xGizmo: PlaneRotationGizmo;
  43276. /**
  43277. * Internal gizmo used for interactions on the y axis
  43278. */
  43279. yGizmo: PlaneRotationGizmo;
  43280. /**
  43281. * Internal gizmo used for interactions on the z axis
  43282. */
  43283. zGizmo: PlaneRotationGizmo;
  43284. /** Fires an event when any of it's sub gizmos are dragged */
  43285. onDragStartObservable: Observable<{}>;
  43286. /** Fires an event when any of it's sub gizmos are released from dragging */
  43287. onDragEndObservable: Observable<{}>;
  43288. attachedMesh: Nullable<AbstractMesh>;
  43289. /**
  43290. * Creates a RotationGizmo
  43291. * @param gizmoLayer The utility layer the gizmo will be added to
  43292. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43293. */
  43294. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43295. updateGizmoRotationToMatchAttachedMesh: boolean;
  43296. /**
  43297. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43298. */
  43299. snapDistance: number;
  43300. /**
  43301. * Ratio for the scale of the gizmo (Default: 1)
  43302. */
  43303. scaleRatio: number;
  43304. /**
  43305. * Disposes of the gizmo
  43306. */
  43307. dispose(): void;
  43308. /**
  43309. * CustomMeshes are not supported by this gizmo
  43310. * @param mesh The mesh to replace the default mesh of the gizmo
  43311. */
  43312. setCustomMesh(mesh: Mesh): void;
  43313. }
  43314. }
  43315. declare module "babylonjs/Gizmos/positionGizmo" {
  43316. import { Observable } from "babylonjs/Misc/observable";
  43317. import { Nullable } from "babylonjs/types";
  43318. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43319. import { Mesh } from "babylonjs/Meshes/mesh";
  43320. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43321. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  43322. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43323. /**
  43324. * Gizmo that enables dragging a mesh along 3 axis
  43325. */
  43326. export class PositionGizmo extends Gizmo {
  43327. /**
  43328. * Internal gizmo used for interactions on the x axis
  43329. */
  43330. xGizmo: AxisDragGizmo;
  43331. /**
  43332. * Internal gizmo used for interactions on the y axis
  43333. */
  43334. yGizmo: AxisDragGizmo;
  43335. /**
  43336. * Internal gizmo used for interactions on the z axis
  43337. */
  43338. zGizmo: AxisDragGizmo;
  43339. /** Fires an event when any of it's sub gizmos are dragged */
  43340. onDragStartObservable: Observable<{}>;
  43341. /** Fires an event when any of it's sub gizmos are released from dragging */
  43342. onDragEndObservable: Observable<{}>;
  43343. attachedMesh: Nullable<AbstractMesh>;
  43344. /**
  43345. * Creates a PositionGizmo
  43346. * @param gizmoLayer The utility layer the gizmo will be added to
  43347. */
  43348. constructor(gizmoLayer?: UtilityLayerRenderer);
  43349. updateGizmoRotationToMatchAttachedMesh: boolean;
  43350. /**
  43351. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43352. */
  43353. snapDistance: number;
  43354. /**
  43355. * Ratio for the scale of the gizmo (Default: 1)
  43356. */
  43357. scaleRatio: number;
  43358. /**
  43359. * Disposes of the gizmo
  43360. */
  43361. dispose(): void;
  43362. /**
  43363. * CustomMeshes are not supported by this gizmo
  43364. * @param mesh The mesh to replace the default mesh of the gizmo
  43365. */
  43366. setCustomMesh(mesh: Mesh): void;
  43367. }
  43368. }
  43369. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  43370. import { Scene } from "babylonjs/scene";
  43371. import { Color4, Vector4 } from "babylonjs/Maths/math";
  43372. import { Mesh } from "babylonjs/Meshes/mesh";
  43373. /**
  43374. * Class containing static functions to help procedurally build meshes
  43375. */
  43376. export class PolyhedronBuilder {
  43377. /**
  43378. * Creates a polyhedron mesh
  43379. * * 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
  43380. * * The parameter `size` (positive float, default 1) sets the polygon size
  43381. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43382. * * 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`
  43383. * * 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
  43384. * * 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)`)
  43385. * * 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
  43386. * * 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
  43387. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43388. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43389. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43390. * @param name defines the name of the mesh
  43391. * @param options defines the options used to create the mesh
  43392. * @param scene defines the hosting scene
  43393. * @returns the polyhedron mesh
  43394. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  43395. */
  43396. static CreatePolyhedron(name: string, options: {
  43397. type?: number;
  43398. size?: number;
  43399. sizeX?: number;
  43400. sizeY?: number;
  43401. sizeZ?: number;
  43402. custom?: any;
  43403. faceUV?: Vector4[];
  43404. faceColors?: Color4[];
  43405. flat?: boolean;
  43406. updatable?: boolean;
  43407. sideOrientation?: number;
  43408. frontUVs?: Vector4;
  43409. backUVs?: Vector4;
  43410. }, scene: Scene): Mesh;
  43411. }
  43412. }
  43413. declare module "babylonjs/Gizmos/scaleGizmo" {
  43414. import { Observable } from "babylonjs/Misc/observable";
  43415. import { Nullable } from "babylonjs/types";
  43416. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43417. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43418. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  43419. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43420. /**
  43421. * Gizmo that enables scaling a mesh along 3 axis
  43422. */
  43423. export class ScaleGizmo extends Gizmo {
  43424. /**
  43425. * Internal gizmo used for interactions on the x axis
  43426. */
  43427. xGizmo: AxisScaleGizmo;
  43428. /**
  43429. * Internal gizmo used for interactions on the y axis
  43430. */
  43431. yGizmo: AxisScaleGizmo;
  43432. /**
  43433. * Internal gizmo used for interactions on the z axis
  43434. */
  43435. zGizmo: AxisScaleGizmo;
  43436. /**
  43437. * Internal gizmo used to scale all axis equally
  43438. */
  43439. uniformScaleGizmo: AxisScaleGizmo;
  43440. /** Fires an event when any of it's sub gizmos are dragged */
  43441. onDragStartObservable: Observable<{}>;
  43442. /** Fires an event when any of it's sub gizmos are released from dragging */
  43443. onDragEndObservable: Observable<{}>;
  43444. attachedMesh: Nullable<AbstractMesh>;
  43445. /**
  43446. * Creates a ScaleGizmo
  43447. * @param gizmoLayer The utility layer the gizmo will be added to
  43448. */
  43449. constructor(gizmoLayer?: UtilityLayerRenderer);
  43450. updateGizmoRotationToMatchAttachedMesh: boolean;
  43451. /**
  43452. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43453. */
  43454. snapDistance: number;
  43455. /**
  43456. * Ratio for the scale of the gizmo (Default: 1)
  43457. */
  43458. scaleRatio: number;
  43459. /**
  43460. * Disposes of the gizmo
  43461. */
  43462. dispose(): void;
  43463. }
  43464. }
  43465. declare module "babylonjs/Gizmos/gizmoManager" {
  43466. import { Observable } from "babylonjs/Misc/observable";
  43467. import { Nullable } from "babylonjs/types";
  43468. import { Scene, IDisposable } from "babylonjs/scene";
  43469. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43470. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  43471. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  43472. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  43473. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  43474. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  43475. /**
  43476. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43477. */
  43478. export class GizmoManager implements IDisposable {
  43479. private scene;
  43480. /**
  43481. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43482. */
  43483. gizmos: {
  43484. positionGizmo: Nullable<PositionGizmo>;
  43485. rotationGizmo: Nullable<RotationGizmo>;
  43486. scaleGizmo: Nullable<ScaleGizmo>;
  43487. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43488. };
  43489. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43490. clearGizmoOnEmptyPointerEvent: boolean;
  43491. /** Fires an event when the manager is attached to a mesh */
  43492. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43493. private _gizmosEnabled;
  43494. private _pointerObserver;
  43495. private _attachedMesh;
  43496. private _boundingBoxColor;
  43497. private _defaultUtilityLayer;
  43498. private _defaultKeepDepthUtilityLayer;
  43499. /**
  43500. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43501. */
  43502. boundingBoxDragBehavior: SixDofDragBehavior;
  43503. /**
  43504. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43505. */
  43506. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43507. /**
  43508. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43509. */
  43510. usePointerToAttachGizmos: boolean;
  43511. /**
  43512. * Instatiates a gizmo manager
  43513. * @param scene the scene to overlay the gizmos on top of
  43514. */
  43515. constructor(scene: Scene);
  43516. /**
  43517. * Attaches a set of gizmos to the specified mesh
  43518. * @param mesh The mesh the gizmo's should be attached to
  43519. */
  43520. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43521. /**
  43522. * If the position gizmo is enabled
  43523. */
  43524. positionGizmoEnabled: boolean;
  43525. /**
  43526. * If the rotation gizmo is enabled
  43527. */
  43528. rotationGizmoEnabled: boolean;
  43529. /**
  43530. * If the scale gizmo is enabled
  43531. */
  43532. scaleGizmoEnabled: boolean;
  43533. /**
  43534. * If the boundingBox gizmo is enabled
  43535. */
  43536. boundingBoxGizmoEnabled: boolean;
  43537. /**
  43538. * Disposes of the gizmo manager
  43539. */
  43540. dispose(): void;
  43541. }
  43542. }
  43543. declare module "babylonjs/Gizmos/lightGizmo" {
  43544. import { Nullable } from "babylonjs/types";
  43545. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43546. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43547. import { Light } from "babylonjs/Lights/light";
  43548. /**
  43549. * Gizmo that enables viewing a light
  43550. */
  43551. export class LightGizmo extends Gizmo {
  43552. private _box;
  43553. /**
  43554. * Creates a LightGizmo
  43555. * @param gizmoLayer The utility layer the gizmo will be added to
  43556. */
  43557. constructor(gizmoLayer?: UtilityLayerRenderer);
  43558. private _light;
  43559. /**
  43560. * The light that the gizmo is attached to
  43561. */
  43562. light: Nullable<Light>;
  43563. /**
  43564. * @hidden
  43565. * Updates the gizmo to match the attached mesh's position/rotation
  43566. */
  43567. protected _update(): void;
  43568. }
  43569. }
  43570. declare module "babylonjs/Gizmos/index" {
  43571. export * from "babylonjs/Gizmos/axisDragGizmo";
  43572. export * from "babylonjs/Gizmos/axisScaleGizmo";
  43573. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  43574. export * from "babylonjs/Gizmos/gizmo";
  43575. export * from "babylonjs/Gizmos/gizmoManager";
  43576. export * from "babylonjs/Gizmos/planeRotationGizmo";
  43577. export * from "babylonjs/Gizmos/positionGizmo";
  43578. export * from "babylonjs/Gizmos/rotationGizmo";
  43579. export * from "babylonjs/Gizmos/scaleGizmo";
  43580. export * from "babylonjs/Gizmos/lightGizmo";
  43581. }
  43582. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  43583. /** @hidden */
  43584. export var backgroundFragmentDeclaration: {
  43585. name: string;
  43586. shader: string;
  43587. };
  43588. }
  43589. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  43590. /** @hidden */
  43591. export var backgroundUboDeclaration: {
  43592. name: string;
  43593. shader: string;
  43594. };
  43595. }
  43596. declare module "babylonjs/Shaders/background.fragment" {
  43597. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  43598. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43599. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  43600. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43601. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43602. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43603. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43604. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  43605. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  43606. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43607. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  43608. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  43609. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  43610. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  43611. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  43612. /** @hidden */
  43613. export var backgroundPixelShader: {
  43614. name: string;
  43615. shader: string;
  43616. };
  43617. }
  43618. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  43619. /** @hidden */
  43620. export var backgroundVertexDeclaration: {
  43621. name: string;
  43622. shader: string;
  43623. };
  43624. }
  43625. declare module "babylonjs/Shaders/background.vertex" {
  43626. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  43627. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43628. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43629. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  43630. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  43631. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  43632. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  43633. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43634. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43635. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  43636. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  43637. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  43638. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  43639. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  43640. /** @hidden */
  43641. export var backgroundVertexShader: {
  43642. name: string;
  43643. shader: string;
  43644. };
  43645. }
  43646. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  43647. import { Nullable, int, float } from "babylonjs/types";
  43648. import { Scene } from "babylonjs/scene";
  43649. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  43650. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43651. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43652. import { Mesh } from "babylonjs/Meshes/mesh";
  43653. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  43654. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43655. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43656. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43657. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  43658. import "babylonjs/Shaders/background.fragment";
  43659. import "babylonjs/Shaders/background.vertex";
  43660. /**
  43661. * Background material used to create an efficient environement around your scene.
  43662. */
  43663. export class BackgroundMaterial extends PushMaterial {
  43664. /**
  43665. * Standard reflectance value at parallel view angle.
  43666. */
  43667. static StandardReflectance0: number;
  43668. /**
  43669. * Standard reflectance value at grazing angle.
  43670. */
  43671. static StandardReflectance90: number;
  43672. protected _primaryColor: Color3;
  43673. /**
  43674. * Key light Color (multiply against the environement texture)
  43675. */
  43676. primaryColor: Color3;
  43677. protected __perceptualColor: Nullable<Color3>;
  43678. /**
  43679. * Experimental Internal Use Only.
  43680. *
  43681. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43682. * This acts as a helper to set the primary color to a more "human friendly" value.
  43683. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43684. * output color as close as possible from the chosen value.
  43685. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43686. * part of lighting setup.)
  43687. */
  43688. _perceptualColor: Nullable<Color3>;
  43689. protected _primaryColorShadowLevel: float;
  43690. /**
  43691. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43692. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43693. */
  43694. primaryColorShadowLevel: float;
  43695. protected _primaryColorHighlightLevel: float;
  43696. /**
  43697. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43698. * The primary color is used at the level chosen to define what the white area would look.
  43699. */
  43700. primaryColorHighlightLevel: float;
  43701. protected _reflectionTexture: Nullable<BaseTexture>;
  43702. /**
  43703. * Reflection Texture used in the material.
  43704. * Should be author in a specific way for the best result (refer to the documentation).
  43705. */
  43706. reflectionTexture: Nullable<BaseTexture>;
  43707. protected _reflectionBlur: float;
  43708. /**
  43709. * Reflection Texture level of blur.
  43710. *
  43711. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43712. * texture twice.
  43713. */
  43714. reflectionBlur: float;
  43715. protected _diffuseTexture: Nullable<BaseTexture>;
  43716. /**
  43717. * Diffuse Texture used in the material.
  43718. * Should be author in a specific way for the best result (refer to the documentation).
  43719. */
  43720. diffuseTexture: Nullable<BaseTexture>;
  43721. protected _shadowLights: Nullable<IShadowLight[]>;
  43722. /**
  43723. * Specify the list of lights casting shadow on the material.
  43724. * All scene shadow lights will be included if null.
  43725. */
  43726. shadowLights: Nullable<IShadowLight[]>;
  43727. protected _shadowLevel: float;
  43728. /**
  43729. * Helps adjusting the shadow to a softer level if required.
  43730. * 0 means black shadows and 1 means no shadows.
  43731. */
  43732. shadowLevel: float;
  43733. protected _sceneCenter: Vector3;
  43734. /**
  43735. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43736. * It is usually zero but might be interesting to modify according to your setup.
  43737. */
  43738. sceneCenter: Vector3;
  43739. protected _opacityFresnel: boolean;
  43740. /**
  43741. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43742. * This helps ensuring a nice transition when the camera goes under the ground.
  43743. */
  43744. opacityFresnel: boolean;
  43745. protected _reflectionFresnel: boolean;
  43746. /**
  43747. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43748. * This helps adding a mirror texture on the ground.
  43749. */
  43750. reflectionFresnel: boolean;
  43751. protected _reflectionFalloffDistance: number;
  43752. /**
  43753. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43754. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43755. */
  43756. reflectionFalloffDistance: number;
  43757. protected _reflectionAmount: number;
  43758. /**
  43759. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43760. */
  43761. reflectionAmount: number;
  43762. protected _reflectionReflectance0: number;
  43763. /**
  43764. * This specifies the weight of the reflection at grazing angle.
  43765. */
  43766. reflectionReflectance0: number;
  43767. protected _reflectionReflectance90: number;
  43768. /**
  43769. * This specifies the weight of the reflection at a perpendicular point of view.
  43770. */
  43771. reflectionReflectance90: number;
  43772. /**
  43773. * Sets the reflection reflectance fresnel values according to the default standard
  43774. * empirically know to work well :-)
  43775. */
  43776. reflectionStandardFresnelWeight: number;
  43777. protected _useRGBColor: boolean;
  43778. /**
  43779. * Helps to directly use the maps channels instead of their level.
  43780. */
  43781. useRGBColor: boolean;
  43782. protected _enableNoise: boolean;
  43783. /**
  43784. * This helps reducing the banding effect that could occur on the background.
  43785. */
  43786. enableNoise: boolean;
  43787. /**
  43788. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43789. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43790. * Recommended to be keep at 1.0 except for special cases.
  43791. */
  43792. fovMultiplier: number;
  43793. private _fovMultiplier;
  43794. /**
  43795. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43796. */
  43797. useEquirectangularFOV: boolean;
  43798. private _maxSimultaneousLights;
  43799. /**
  43800. * Number of Simultaneous lights allowed on the material.
  43801. */
  43802. maxSimultaneousLights: int;
  43803. /**
  43804. * Default configuration related to image processing available in the Background Material.
  43805. */
  43806. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43807. /**
  43808. * Keep track of the image processing observer to allow dispose and replace.
  43809. */
  43810. private _imageProcessingObserver;
  43811. /**
  43812. * Attaches a new image processing configuration to the PBR Material.
  43813. * @param configuration (if null the scene configuration will be use)
  43814. */
  43815. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43816. /**
  43817. * Gets the image processing configuration used either in this material.
  43818. */
  43819. /**
  43820. * Sets the Default image processing configuration used either in the this material.
  43821. *
  43822. * If sets to null, the scene one is in use.
  43823. */
  43824. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43825. /**
  43826. * Gets wether the color curves effect is enabled.
  43827. */
  43828. /**
  43829. * Sets wether the color curves effect is enabled.
  43830. */
  43831. cameraColorCurvesEnabled: boolean;
  43832. /**
  43833. * Gets wether the color grading effect is enabled.
  43834. */
  43835. /**
  43836. * Gets wether the color grading effect is enabled.
  43837. */
  43838. cameraColorGradingEnabled: boolean;
  43839. /**
  43840. * Gets wether tonemapping is enabled or not.
  43841. */
  43842. /**
  43843. * Sets wether tonemapping is enabled or not
  43844. */
  43845. cameraToneMappingEnabled: boolean;
  43846. /**
  43847. * The camera exposure used on this material.
  43848. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43849. * This corresponds to a photographic exposure.
  43850. */
  43851. /**
  43852. * The camera exposure used on this material.
  43853. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43854. * This corresponds to a photographic exposure.
  43855. */
  43856. cameraExposure: float;
  43857. /**
  43858. * Gets The camera contrast used on this material.
  43859. */
  43860. /**
  43861. * Sets The camera contrast used on this material.
  43862. */
  43863. cameraContrast: float;
  43864. /**
  43865. * Gets the Color Grading 2D Lookup Texture.
  43866. */
  43867. /**
  43868. * Sets the Color Grading 2D Lookup Texture.
  43869. */
  43870. cameraColorGradingTexture: Nullable<BaseTexture>;
  43871. /**
  43872. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43873. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43874. * 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;
  43875. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43876. */
  43877. /**
  43878. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43879. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43880. * 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;
  43881. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43882. */
  43883. cameraColorCurves: Nullable<ColorCurves>;
  43884. /**
  43885. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43886. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43887. */
  43888. switchToBGR: boolean;
  43889. private _renderTargets;
  43890. private _reflectionControls;
  43891. private _white;
  43892. private _primaryShadowColor;
  43893. private _primaryHighlightColor;
  43894. /**
  43895. * Instantiates a Background Material in the given scene
  43896. * @param name The friendly name of the material
  43897. * @param scene The scene to add the material to
  43898. */
  43899. constructor(name: string, scene: Scene);
  43900. /**
  43901. * Gets a boolean indicating that current material needs to register RTT
  43902. */
  43903. readonly hasRenderTargetTextures: boolean;
  43904. /**
  43905. * The entire material has been created in order to prevent overdraw.
  43906. * @returns false
  43907. */
  43908. needAlphaTesting(): boolean;
  43909. /**
  43910. * The entire material has been created in order to prevent overdraw.
  43911. * @returns true if blending is enable
  43912. */
  43913. needAlphaBlending(): boolean;
  43914. /**
  43915. * Checks wether the material is ready to be rendered for a given mesh.
  43916. * @param mesh The mesh to render
  43917. * @param subMesh The submesh to check against
  43918. * @param useInstances Specify wether or not the material is used with instances
  43919. * @returns true if all the dependencies are ready (Textures, Effects...)
  43920. */
  43921. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43922. /**
  43923. * Compute the primary color according to the chosen perceptual color.
  43924. */
  43925. private _computePrimaryColorFromPerceptualColor;
  43926. /**
  43927. * Compute the highlights and shadow colors according to their chosen levels.
  43928. */
  43929. private _computePrimaryColors;
  43930. /**
  43931. * Build the uniform buffer used in the material.
  43932. */
  43933. buildUniformLayout(): void;
  43934. /**
  43935. * Unbind the material.
  43936. */
  43937. unbind(): void;
  43938. /**
  43939. * Bind only the world matrix to the material.
  43940. * @param world The world matrix to bind.
  43941. */
  43942. bindOnlyWorldMatrix(world: Matrix): void;
  43943. /**
  43944. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43945. * @param world The world matrix to bind.
  43946. * @param subMesh The submesh to bind for.
  43947. */
  43948. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43949. /**
  43950. * Dispose the material.
  43951. * @param forceDisposeEffect Force disposal of the associated effect.
  43952. * @param forceDisposeTextures Force disposal of the associated textures.
  43953. */
  43954. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43955. /**
  43956. * Clones the material.
  43957. * @param name The cloned name.
  43958. * @returns The cloned material.
  43959. */
  43960. clone(name: string): BackgroundMaterial;
  43961. /**
  43962. * Serializes the current material to its JSON representation.
  43963. * @returns The JSON representation.
  43964. */
  43965. serialize(): any;
  43966. /**
  43967. * Gets the class name of the material
  43968. * @returns "BackgroundMaterial"
  43969. */
  43970. getClassName(): string;
  43971. /**
  43972. * Parse a JSON input to create back a background material.
  43973. * @param source The JSON data to parse
  43974. * @param scene The scene to create the parsed material in
  43975. * @param rootUrl The root url of the assets the material depends upon
  43976. * @returns the instantiated BackgroundMaterial.
  43977. */
  43978. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43979. }
  43980. }
  43981. declare module "babylonjs/Helpers/environmentHelper" {
  43982. import { Observable } from "babylonjs/Misc/observable";
  43983. import { Nullable } from "babylonjs/types";
  43984. import { Scene } from "babylonjs/scene";
  43985. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43987. import { Mesh } from "babylonjs/Meshes/mesh";
  43988. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43989. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  43990. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  43991. import "babylonjs/Meshes/Builders/planeBuilder";
  43992. import "babylonjs/Meshes/Builders/boxBuilder";
  43993. /**
  43994. * Represents the different options available during the creation of
  43995. * a Environment helper.
  43996. *
  43997. * This can control the default ground, skybox and image processing setup of your scene.
  43998. */
  43999. export interface IEnvironmentHelperOptions {
  44000. /**
  44001. * Specifies wether or not to create a ground.
  44002. * True by default.
  44003. */
  44004. createGround: boolean;
  44005. /**
  44006. * Specifies the ground size.
  44007. * 15 by default.
  44008. */
  44009. groundSize: number;
  44010. /**
  44011. * The texture used on the ground for the main color.
  44012. * Comes from the BabylonJS CDN by default.
  44013. *
  44014. * Remarks: Can be either a texture or a url.
  44015. */
  44016. groundTexture: string | BaseTexture;
  44017. /**
  44018. * The color mixed in the ground texture by default.
  44019. * BabylonJS clearColor by default.
  44020. */
  44021. groundColor: Color3;
  44022. /**
  44023. * Specifies the ground opacity.
  44024. * 1 by default.
  44025. */
  44026. groundOpacity: number;
  44027. /**
  44028. * Enables the ground to receive shadows.
  44029. * True by default.
  44030. */
  44031. enableGroundShadow: boolean;
  44032. /**
  44033. * Helps preventing the shadow to be fully black on the ground.
  44034. * 0.5 by default.
  44035. */
  44036. groundShadowLevel: number;
  44037. /**
  44038. * Creates a mirror texture attach to the ground.
  44039. * false by default.
  44040. */
  44041. enableGroundMirror: boolean;
  44042. /**
  44043. * Specifies the ground mirror size ratio.
  44044. * 0.3 by default as the default kernel is 64.
  44045. */
  44046. groundMirrorSizeRatio: number;
  44047. /**
  44048. * Specifies the ground mirror blur kernel size.
  44049. * 64 by default.
  44050. */
  44051. groundMirrorBlurKernel: number;
  44052. /**
  44053. * Specifies the ground mirror visibility amount.
  44054. * 1 by default
  44055. */
  44056. groundMirrorAmount: number;
  44057. /**
  44058. * Specifies the ground mirror reflectance weight.
  44059. * This uses the standard weight of the background material to setup the fresnel effect
  44060. * of the mirror.
  44061. * 1 by default.
  44062. */
  44063. groundMirrorFresnelWeight: number;
  44064. /**
  44065. * Specifies the ground mirror Falloff distance.
  44066. * This can helps reducing the size of the reflection.
  44067. * 0 by Default.
  44068. */
  44069. groundMirrorFallOffDistance: number;
  44070. /**
  44071. * Specifies the ground mirror texture type.
  44072. * Unsigned Int by Default.
  44073. */
  44074. groundMirrorTextureType: number;
  44075. /**
  44076. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  44077. * the shown objects.
  44078. */
  44079. groundYBias: number;
  44080. /**
  44081. * Specifies wether or not to create a skybox.
  44082. * True by default.
  44083. */
  44084. createSkybox: boolean;
  44085. /**
  44086. * Specifies the skybox size.
  44087. * 20 by default.
  44088. */
  44089. skyboxSize: number;
  44090. /**
  44091. * The texture used on the skybox for the main color.
  44092. * Comes from the BabylonJS CDN by default.
  44093. *
  44094. * Remarks: Can be either a texture or a url.
  44095. */
  44096. skyboxTexture: string | BaseTexture;
  44097. /**
  44098. * The color mixed in the skybox texture by default.
  44099. * BabylonJS clearColor by default.
  44100. */
  44101. skyboxColor: Color3;
  44102. /**
  44103. * The background rotation around the Y axis of the scene.
  44104. * This helps aligning the key lights of your scene with the background.
  44105. * 0 by default.
  44106. */
  44107. backgroundYRotation: number;
  44108. /**
  44109. * Compute automatically the size of the elements to best fit with the scene.
  44110. */
  44111. sizeAuto: boolean;
  44112. /**
  44113. * Default position of the rootMesh if autoSize is not true.
  44114. */
  44115. rootPosition: Vector3;
  44116. /**
  44117. * Sets up the image processing in the scene.
  44118. * true by default.
  44119. */
  44120. setupImageProcessing: boolean;
  44121. /**
  44122. * The texture used as your environment texture in the scene.
  44123. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  44124. *
  44125. * Remarks: Can be either a texture or a url.
  44126. */
  44127. environmentTexture: string | BaseTexture;
  44128. /**
  44129. * The value of the exposure to apply to the scene.
  44130. * 0.6 by default if setupImageProcessing is true.
  44131. */
  44132. cameraExposure: number;
  44133. /**
  44134. * The value of the contrast to apply to the scene.
  44135. * 1.6 by default if setupImageProcessing is true.
  44136. */
  44137. cameraContrast: number;
  44138. /**
  44139. * Specifies wether or not tonemapping should be enabled in the scene.
  44140. * true by default if setupImageProcessing is true.
  44141. */
  44142. toneMappingEnabled: boolean;
  44143. }
  44144. /**
  44145. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  44146. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  44147. * It also helps with the default setup of your imageProcessing configuration.
  44148. */
  44149. export class EnvironmentHelper {
  44150. /**
  44151. * Default ground texture URL.
  44152. */
  44153. private static _groundTextureCDNUrl;
  44154. /**
  44155. * Default skybox texture URL.
  44156. */
  44157. private static _skyboxTextureCDNUrl;
  44158. /**
  44159. * Default environment texture URL.
  44160. */
  44161. private static _environmentTextureCDNUrl;
  44162. /**
  44163. * Creates the default options for the helper.
  44164. */
  44165. private static _getDefaultOptions;
  44166. private _rootMesh;
  44167. /**
  44168. * Gets the root mesh created by the helper.
  44169. */
  44170. readonly rootMesh: Mesh;
  44171. private _skybox;
  44172. /**
  44173. * Gets the skybox created by the helper.
  44174. */
  44175. readonly skybox: Nullable<Mesh>;
  44176. private _skyboxTexture;
  44177. /**
  44178. * Gets the skybox texture created by the helper.
  44179. */
  44180. readonly skyboxTexture: Nullable<BaseTexture>;
  44181. private _skyboxMaterial;
  44182. /**
  44183. * Gets the skybox material created by the helper.
  44184. */
  44185. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  44186. private _ground;
  44187. /**
  44188. * Gets the ground mesh created by the helper.
  44189. */
  44190. readonly ground: Nullable<Mesh>;
  44191. private _groundTexture;
  44192. /**
  44193. * Gets the ground texture created by the helper.
  44194. */
  44195. readonly groundTexture: Nullable<BaseTexture>;
  44196. private _groundMirror;
  44197. /**
  44198. * Gets the ground mirror created by the helper.
  44199. */
  44200. readonly groundMirror: Nullable<MirrorTexture>;
  44201. /**
  44202. * Gets the ground mirror render list to helps pushing the meshes
  44203. * you wish in the ground reflection.
  44204. */
  44205. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  44206. private _groundMaterial;
  44207. /**
  44208. * Gets the ground material created by the helper.
  44209. */
  44210. readonly groundMaterial: Nullable<BackgroundMaterial>;
  44211. /**
  44212. * Stores the creation options.
  44213. */
  44214. private readonly _scene;
  44215. private _options;
  44216. /**
  44217. * This observable will be notified with any error during the creation of the environment,
  44218. * mainly texture creation errors.
  44219. */
  44220. onErrorObservable: Observable<{
  44221. message?: string;
  44222. exception?: any;
  44223. }>;
  44224. /**
  44225. * constructor
  44226. * @param options Defines the options we want to customize the helper
  44227. * @param scene The scene to add the material to
  44228. */
  44229. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  44230. /**
  44231. * Updates the background according to the new options
  44232. * @param options
  44233. */
  44234. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  44235. /**
  44236. * Sets the primary color of all the available elements.
  44237. * @param color the main color to affect to the ground and the background
  44238. */
  44239. setMainColor(color: Color3): void;
  44240. /**
  44241. * Setup the image processing according to the specified options.
  44242. */
  44243. private _setupImageProcessing;
  44244. /**
  44245. * Setup the environment texture according to the specified options.
  44246. */
  44247. private _setupEnvironmentTexture;
  44248. /**
  44249. * Setup the background according to the specified options.
  44250. */
  44251. private _setupBackground;
  44252. /**
  44253. * Get the scene sizes according to the setup.
  44254. */
  44255. private _getSceneSize;
  44256. /**
  44257. * Setup the ground according to the specified options.
  44258. */
  44259. private _setupGround;
  44260. /**
  44261. * Setup the ground material according to the specified options.
  44262. */
  44263. private _setupGroundMaterial;
  44264. /**
  44265. * Setup the ground diffuse texture according to the specified options.
  44266. */
  44267. private _setupGroundDiffuseTexture;
  44268. /**
  44269. * Setup the ground mirror texture according to the specified options.
  44270. */
  44271. private _setupGroundMirrorTexture;
  44272. /**
  44273. * Setup the ground to receive the mirror texture.
  44274. */
  44275. private _setupMirrorInGroundMaterial;
  44276. /**
  44277. * Setup the skybox according to the specified options.
  44278. */
  44279. private _setupSkybox;
  44280. /**
  44281. * Setup the skybox material according to the specified options.
  44282. */
  44283. private _setupSkyboxMaterial;
  44284. /**
  44285. * Setup the skybox reflection texture according to the specified options.
  44286. */
  44287. private _setupSkyboxReflectionTexture;
  44288. private _errorHandler;
  44289. /**
  44290. * Dispose all the elements created by the Helper.
  44291. */
  44292. dispose(): void;
  44293. }
  44294. }
  44295. declare module "babylonjs/Helpers/photoDome" {
  44296. import { Observable } from "babylonjs/Misc/observable";
  44297. import { Nullable } from "babylonjs/types";
  44298. import { Scene } from "babylonjs/scene";
  44299. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44300. import { Mesh } from "babylonjs/Meshes/mesh";
  44301. import { Texture } from "babylonjs/Materials/Textures/texture";
  44302. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44303. import "babylonjs/Meshes/Builders/sphereBuilder";
  44304. /**
  44305. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  44306. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  44307. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  44308. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44309. */
  44310. export class PhotoDome extends TransformNode {
  44311. private _useDirectMapping;
  44312. /**
  44313. * The texture being displayed on the sphere
  44314. */
  44315. protected _photoTexture: Texture;
  44316. /**
  44317. * Gets or sets the texture being displayed on the sphere
  44318. */
  44319. photoTexture: Texture;
  44320. /**
  44321. * Observable raised when an error occured while loading the 360 image
  44322. */
  44323. onLoadErrorObservable: Observable<string>;
  44324. /**
  44325. * The skybox material
  44326. */
  44327. protected _material: BackgroundMaterial;
  44328. /**
  44329. * The surface used for the skybox
  44330. */
  44331. protected _mesh: Mesh;
  44332. /**
  44333. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44334. * Also see the options.resolution property.
  44335. */
  44336. fovMultiplier: number;
  44337. /**
  44338. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  44339. * @param name Element's name, child elements will append suffixes for their own names.
  44340. * @param urlsOfPhoto defines the url of the photo to display
  44341. * @param options defines an object containing optional or exposed sub element properties
  44342. * @param onError defines a callback called when an error occured while loading the texture
  44343. */
  44344. constructor(name: string, urlOfPhoto: string, options: {
  44345. resolution?: number;
  44346. size?: number;
  44347. useDirectMapping?: boolean;
  44348. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  44349. /**
  44350. * Releases resources associated with this node.
  44351. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44352. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44353. */
  44354. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44355. }
  44356. }
  44357. declare module "babylonjs/Misc/textureTools" {
  44358. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44359. import { Texture } from "babylonjs/Materials/Textures/texture";
  44360. import { Scene } from "babylonjs/scene";
  44361. /**
  44362. * Class used to host texture specific utilities
  44363. */
  44364. export class TextureTools {
  44365. /**
  44366. * Uses the GPU to create a copy texture rescaled at a given size
  44367. * @param texture Texture to copy from
  44368. * @param width defines the desired width
  44369. * @param height defines the desired height
  44370. * @param useBilinearMode defines if bilinear mode has to be used
  44371. * @return the generated texture
  44372. */
  44373. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  44374. /**
  44375. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  44376. * @param scene defines the hosting scene
  44377. * @returns the environment BRDF texture
  44378. */
  44379. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44380. private static _environmentBRDFBase64Texture;
  44381. }
  44382. }
  44383. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  44384. import { Nullable } from "babylonjs/types";
  44385. import { IAnimatable } from "babylonjs/Misc/tools";
  44386. import { Color3 } from "babylonjs/Maths/math";
  44387. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44388. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44389. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44390. import { Engine } from "babylonjs/Engines/engine";
  44391. import { Scene } from "babylonjs/scene";
  44392. /**
  44393. * @hidden
  44394. */
  44395. export interface IMaterialClearCoatDefines {
  44396. CLEARCOAT: boolean;
  44397. CLEARCOAT_DEFAULTIOR: boolean;
  44398. CLEARCOAT_TEXTURE: boolean;
  44399. CLEARCOAT_TEXTUREDIRECTUV: number;
  44400. CLEARCOAT_BUMP: boolean;
  44401. CLEARCOAT_BUMPDIRECTUV: number;
  44402. CLEARCOAT_TINT: boolean;
  44403. CLEARCOAT_TINT_TEXTURE: boolean;
  44404. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44405. /** @hidden */
  44406. _areTexturesDirty: boolean;
  44407. }
  44408. /**
  44409. * Define the code related to the clear coat parameters of the pbr material.
  44410. */
  44411. export class PBRClearCoatConfiguration {
  44412. /**
  44413. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44414. * The default fits with a polyurethane material.
  44415. */
  44416. private static readonly _DefaultIndiceOfRefraction;
  44417. private _isEnabled;
  44418. /**
  44419. * Defines if the clear coat is enabled in the material.
  44420. */
  44421. isEnabled: boolean;
  44422. /**
  44423. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  44424. */
  44425. intensity: number;
  44426. /**
  44427. * Defines the clear coat layer roughness.
  44428. */
  44429. roughness: number;
  44430. private _indiceOfRefraction;
  44431. /**
  44432. * Defines the indice of refraction of the clear coat.
  44433. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44434. * The default fits with a polyurethane material.
  44435. * Changing the default value is more performance intensive.
  44436. */
  44437. indiceOfRefraction: number;
  44438. private _texture;
  44439. /**
  44440. * Stores the clear coat values in a texture.
  44441. */
  44442. texture: Nullable<BaseTexture>;
  44443. private _bumpTexture;
  44444. /**
  44445. * Define the clear coat specific bump texture.
  44446. */
  44447. bumpTexture: Nullable<BaseTexture>;
  44448. private _isTintEnabled;
  44449. /**
  44450. * Defines if the clear coat tint is enabled in the material.
  44451. */
  44452. isTintEnabled: boolean;
  44453. /**
  44454. * Defines if the clear coat tint is enabled in the material.
  44455. * This is only use if tint is enabled
  44456. */
  44457. tintColor: Color3;
  44458. /**
  44459. * Defines if the distance at which the tint color should be found in the
  44460. * clear coat media.
  44461. * This is only use if tint is enabled
  44462. */
  44463. tintColorAtDistance: number;
  44464. /**
  44465. * Defines the clear coat layer thickness.
  44466. * This is only use if tint is enabled
  44467. */
  44468. tintThickness: number;
  44469. private _tintTexture;
  44470. /**
  44471. * Stores the clear tint values in a texture.
  44472. * rgb is tint
  44473. * a is a thickness factor
  44474. */
  44475. tintTexture: Nullable<BaseTexture>;
  44476. /** @hidden */
  44477. private _internalMarkAllSubMeshesAsTexturesDirty;
  44478. /** @hidden */
  44479. _markAllSubMeshesAsTexturesDirty(): void;
  44480. /**
  44481. * Instantiate a new istance of clear coat configuration.
  44482. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44483. */
  44484. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44485. /**
  44486. * Specifies that the submesh is ready to be used.
  44487. * @param defines the list of "defines" to update.
  44488. * @param scene defines the scene the material belongs to.
  44489. * @param engine defines the engine the material belongs to.
  44490. * @param disableBumpMap defines wether the material disables bump or not.
  44491. * @returns - boolean indicating that the submesh is ready or not.
  44492. */
  44493. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44494. /**
  44495. * Checks to see if a texture is used in the material.
  44496. * @param defines the list of "defines" to update.
  44497. * @param scene defines the scene to the material belongs to.
  44498. */
  44499. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44500. /**
  44501. * Binds the material data.
  44502. * @param uniformBuffer defines the Uniform buffer to fill in.
  44503. * @param scene defines the scene the material belongs to.
  44504. * @param engine defines the engine the material belongs to.
  44505. * @param disableBumpMap defines wether the material disables bump or not.
  44506. * @param isFrozen defines wether the material is frozen or not.
  44507. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44508. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44509. */
  44510. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44511. /**
  44512. * Checks to see if a texture is used in the material.
  44513. * @param texture - Base texture to use.
  44514. * @returns - Boolean specifying if a texture is used in the material.
  44515. */
  44516. hasTexture(texture: BaseTexture): boolean;
  44517. /**
  44518. * Returns an array of the actively used textures.
  44519. * @param activeTextures Array of BaseTextures
  44520. */
  44521. getActiveTextures(activeTextures: BaseTexture[]): void;
  44522. /**
  44523. * Returns the animatable textures.
  44524. * @param animatables Array of animatable textures.
  44525. */
  44526. getAnimatables(animatables: IAnimatable[]): void;
  44527. /**
  44528. * Disposes the resources of the material.
  44529. * @param forceDisposeTextures - Forces the disposal of all textures.
  44530. */
  44531. dispose(forceDisposeTextures?: boolean): void;
  44532. /**
  44533. * Get the current class name of the texture useful for serialization or dynamic coding.
  44534. * @returns "PBRClearCoatConfiguration"
  44535. */
  44536. getClassName(): string;
  44537. /**
  44538. * Add fallbacks to the effect fallbacks list.
  44539. * @param defines defines the Base texture to use.
  44540. * @param fallbacks defines the current fallback list.
  44541. * @param currentRank defines the current fallback rank.
  44542. * @returns the new fallback rank.
  44543. */
  44544. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44545. /**
  44546. * Add the required uniforms to the current list.
  44547. * @param uniforms defines the current uniform list.
  44548. */
  44549. static AddUniforms(uniforms: string[]): void;
  44550. /**
  44551. * Add the required samplers to the current list.
  44552. * @param samplers defines the current sampler list.
  44553. */
  44554. static AddSamplers(samplers: string[]): void;
  44555. /**
  44556. * Add the required uniforms to the current buffer.
  44557. * @param uniformBuffer defines the current uniform buffer.
  44558. */
  44559. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44560. /**
  44561. * Makes a duplicate of the current configuration into another one.
  44562. * @param clearCoatConfiguration define the config where to copy the info
  44563. */
  44564. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44565. /**
  44566. * Serializes this clear coat configuration.
  44567. * @returns - An object with the serialized config.
  44568. */
  44569. serialize(): any;
  44570. /**
  44571. * Parses a Clear Coat Configuration from a serialized object.
  44572. * @param source - Serialized object.
  44573. */
  44574. parse(source: any): void;
  44575. }
  44576. }
  44577. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  44578. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44579. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44580. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44581. import { Vector2 } from "babylonjs/Maths/math";
  44582. import { Scene } from "babylonjs/scene";
  44583. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44584. import { IAnimatable } from "babylonjs/Misc/tools";
  44585. import { Nullable } from "babylonjs/types";
  44586. /**
  44587. * @hidden
  44588. */
  44589. export interface IMaterialAnisotropicDefines {
  44590. ANISOTROPIC: boolean;
  44591. ANISOTROPIC_TEXTURE: boolean;
  44592. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44593. MAINUV1: boolean;
  44594. _areTexturesDirty: boolean;
  44595. _needUVs: boolean;
  44596. }
  44597. /**
  44598. * Define the code related to the anisotropic parameters of the pbr material.
  44599. */
  44600. export class PBRAnisotropicConfiguration {
  44601. private _isEnabled;
  44602. /**
  44603. * Defines if the anisotropy is enabled in the material.
  44604. */
  44605. isEnabled: boolean;
  44606. /**
  44607. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44608. */
  44609. intensity: number;
  44610. /**
  44611. * Defines if the effect is along the tangents, bitangents or in between.
  44612. * By default, the effect is "strectching" the highlights along the tangents.
  44613. */
  44614. direction: Vector2;
  44615. private _texture;
  44616. /**
  44617. * Stores the anisotropy values in a texture.
  44618. * rg is direction (like normal from -1 to 1)
  44619. * b is a intensity
  44620. */
  44621. texture: Nullable<BaseTexture>;
  44622. /** @hidden */
  44623. private _internalMarkAllSubMeshesAsTexturesDirty;
  44624. /** @hidden */
  44625. _markAllSubMeshesAsTexturesDirty(): void;
  44626. /**
  44627. * Instantiate a new istance of anisotropy configuration.
  44628. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44629. */
  44630. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44631. /**
  44632. * Specifies that the submesh is ready to be used.
  44633. * @param defines the list of "defines" to update.
  44634. * @param scene defines the scene the material belongs to.
  44635. * @returns - boolean indicating that the submesh is ready or not.
  44636. */
  44637. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  44638. /**
  44639. * Checks to see if a texture is used in the material.
  44640. * @param defines the list of "defines" to update.
  44641. * @param mesh the mesh we are preparing the defines for.
  44642. * @param scene defines the scene the material belongs to.
  44643. */
  44644. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  44645. /**
  44646. * Binds the material data.
  44647. * @param uniformBuffer defines the Uniform buffer to fill in.
  44648. * @param scene defines the scene the material belongs to.
  44649. * @param isFrozen defines wether the material is frozen or not.
  44650. */
  44651. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44652. /**
  44653. * Checks to see if a texture is used in the material.
  44654. * @param texture - Base texture to use.
  44655. * @returns - Boolean specifying if a texture is used in the material.
  44656. */
  44657. hasTexture(texture: BaseTexture): boolean;
  44658. /**
  44659. * Returns an array of the actively used textures.
  44660. * @param activeTextures Array of BaseTextures
  44661. */
  44662. getActiveTextures(activeTextures: BaseTexture[]): void;
  44663. /**
  44664. * Returns the animatable textures.
  44665. * @param animatables Array of animatable textures.
  44666. */
  44667. getAnimatables(animatables: IAnimatable[]): void;
  44668. /**
  44669. * Disposes the resources of the material.
  44670. * @param forceDisposeTextures - Forces the disposal of all textures.
  44671. */
  44672. dispose(forceDisposeTextures?: boolean): void;
  44673. /**
  44674. * Get the current class name of the texture useful for serialization or dynamic coding.
  44675. * @returns "PBRAnisotropicConfiguration"
  44676. */
  44677. getClassName(): string;
  44678. /**
  44679. * Add fallbacks to the effect fallbacks list.
  44680. * @param defines defines the Base texture to use.
  44681. * @param fallbacks defines the current fallback list.
  44682. * @param currentRank defines the current fallback rank.
  44683. * @returns the new fallback rank.
  44684. */
  44685. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44686. /**
  44687. * Add the required uniforms to the current list.
  44688. * @param uniforms defines the current uniform list.
  44689. */
  44690. static AddUniforms(uniforms: string[]): void;
  44691. /**
  44692. * Add the required uniforms to the current buffer.
  44693. * @param uniformBuffer defines the current uniform buffer.
  44694. */
  44695. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44696. /**
  44697. * Add the required samplers to the current list.
  44698. * @param samplers defines the current sampler list.
  44699. */
  44700. static AddSamplers(samplers: string[]): void;
  44701. /**
  44702. * Makes a duplicate of the current configuration into another one.
  44703. * @param anisotropicConfiguration define the config where to copy the info
  44704. */
  44705. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  44706. /**
  44707. * Serializes this anisotropy configuration.
  44708. * @returns - An object with the serialized config.
  44709. */
  44710. serialize(): any;
  44711. /**
  44712. * Parses a anisotropy Configuration from a serialized object.
  44713. * @param source - Serialized object.
  44714. */
  44715. parse(source: any): void;
  44716. }
  44717. }
  44718. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  44719. /**
  44720. * @hidden
  44721. */
  44722. export interface IMaterialBRDFDefines {
  44723. BRDF_V_HEIGHT_CORRELATED: boolean;
  44724. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44725. /** @hidden */
  44726. _areMiscDirty: boolean;
  44727. }
  44728. /**
  44729. * Define the code related to the BRDF parameters of the pbr material.
  44730. */
  44731. export class PBRBRDFConfiguration {
  44732. private _useEnergyConservation;
  44733. /**
  44734. * Defines if the material uses energy conservation.
  44735. */
  44736. useEnergyConservation: boolean;
  44737. private _useSmithVisibilityHeightCorrelated;
  44738. /**
  44739. * LEGACY Mode set to false
  44740. * Defines if the material uses height smith correlated visibility term.
  44741. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  44742. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  44743. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  44744. * Not relying on height correlated will also disable energy conservation.
  44745. */
  44746. useSmithVisibilityHeightCorrelated: boolean;
  44747. /** @hidden */
  44748. private _internalMarkAllSubMeshesAsMiscDirty;
  44749. /** @hidden */
  44750. _markAllSubMeshesAsMiscDirty(): void;
  44751. /**
  44752. * Instantiate a new istance of clear coat configuration.
  44753. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  44754. */
  44755. constructor(markAllSubMeshesAsMiscDirty: () => void);
  44756. /**
  44757. * Checks to see if a texture is used in the material.
  44758. * @param defines the list of "defines" to update.
  44759. */
  44760. prepareDefines(defines: IMaterialBRDFDefines): void;
  44761. /**
  44762. * Get the current class name of the texture useful for serialization or dynamic coding.
  44763. * @returns "PBRClearCoatConfiguration"
  44764. */
  44765. getClassName(): string;
  44766. /**
  44767. * Makes a duplicate of the current configuration into another one.
  44768. * @param brdfConfiguration define the config where to copy the info
  44769. */
  44770. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  44771. /**
  44772. * Serializes this BRDF configuration.
  44773. * @returns - An object with the serialized config.
  44774. */
  44775. serialize(): any;
  44776. /**
  44777. * Parses a BRDF Configuration from a serialized object.
  44778. * @param source - Serialized object.
  44779. */
  44780. parse(source: any): void;
  44781. }
  44782. }
  44783. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  44784. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44785. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44786. import { Color3 } from "babylonjs/Maths/math";
  44787. import { Scene } from "babylonjs/scene";
  44788. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44789. import { IAnimatable } from "babylonjs/Misc/tools";
  44790. import { Nullable } from "babylonjs/types";
  44791. /**
  44792. * @hidden
  44793. */
  44794. export interface IMaterialSheenDefines {
  44795. SHEEN: boolean;
  44796. SHEEN_TEXTURE: boolean;
  44797. SHEEN_TEXTUREDIRECTUV: number;
  44798. SHEEN_LINKWITHALBEDO: boolean;
  44799. /** @hidden */
  44800. _areTexturesDirty: boolean;
  44801. }
  44802. /**
  44803. * Define the code related to the Sheen parameters of the pbr material.
  44804. */
  44805. export class PBRSheenConfiguration {
  44806. private _isEnabled;
  44807. /**
  44808. * Defines if the material uses sheen.
  44809. */
  44810. isEnabled: boolean;
  44811. private _linkSheenWithAlbedo;
  44812. /**
  44813. * Defines if the sheen is linked to the sheen color.
  44814. */
  44815. linkSheenWithAlbedo: boolean;
  44816. /**
  44817. * Defines the sheen intensity.
  44818. */
  44819. intensity: number;
  44820. /**
  44821. * Defines the sheen color.
  44822. */
  44823. color: Color3;
  44824. private _texture;
  44825. /**
  44826. * Stores the sheen tint values in a texture.
  44827. * rgb is tint
  44828. * a is a intensity
  44829. */
  44830. texture: Nullable<BaseTexture>;
  44831. /** @hidden */
  44832. private _internalMarkAllSubMeshesAsTexturesDirty;
  44833. /** @hidden */
  44834. _markAllSubMeshesAsTexturesDirty(): void;
  44835. /**
  44836. * Instantiate a new istance of clear coat configuration.
  44837. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44838. */
  44839. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44840. /**
  44841. * Specifies that the submesh is ready to be used.
  44842. * @param defines the list of "defines" to update.
  44843. * @param scene defines the scene the material belongs to.
  44844. * @returns - boolean indicating that the submesh is ready or not.
  44845. */
  44846. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  44847. /**
  44848. * Checks to see if a texture is used in the material.
  44849. * @param defines the list of "defines" to update.
  44850. * @param scene defines the scene the material belongs to.
  44851. */
  44852. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  44853. /**
  44854. * Binds the material data.
  44855. * @param uniformBuffer defines the Uniform buffer to fill in.
  44856. * @param scene defines the scene the material belongs to.
  44857. * @param isFrozen defines wether the material is frozen or not.
  44858. */
  44859. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44860. /**
  44861. * Checks to see if a texture is used in the material.
  44862. * @param texture - Base texture to use.
  44863. * @returns - Boolean specifying if a texture is used in the material.
  44864. */
  44865. hasTexture(texture: BaseTexture): boolean;
  44866. /**
  44867. * Returns an array of the actively used textures.
  44868. * @param activeTextures Array of BaseTextures
  44869. */
  44870. getActiveTextures(activeTextures: BaseTexture[]): void;
  44871. /**
  44872. * Returns the animatable textures.
  44873. * @param animatables Array of animatable textures.
  44874. */
  44875. getAnimatables(animatables: IAnimatable[]): void;
  44876. /**
  44877. * Disposes the resources of the material.
  44878. * @param forceDisposeTextures - Forces the disposal of all textures.
  44879. */
  44880. dispose(forceDisposeTextures?: boolean): void;
  44881. /**
  44882. * Get the current class name of the texture useful for serialization or dynamic coding.
  44883. * @returns "PBRSheenConfiguration"
  44884. */
  44885. getClassName(): string;
  44886. /**
  44887. * Add fallbacks to the effect fallbacks list.
  44888. * @param defines defines the Base texture to use.
  44889. * @param fallbacks defines the current fallback list.
  44890. * @param currentRank defines the current fallback rank.
  44891. * @returns the new fallback rank.
  44892. */
  44893. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44894. /**
  44895. * Add the required uniforms to the current list.
  44896. * @param uniforms defines the current uniform list.
  44897. */
  44898. static AddUniforms(uniforms: string[]): void;
  44899. /**
  44900. * Add the required uniforms to the current buffer.
  44901. * @param uniformBuffer defines the current uniform buffer.
  44902. */
  44903. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44904. /**
  44905. * Add the required samplers to the current list.
  44906. * @param samplers defines the current sampler list.
  44907. */
  44908. static AddSamplers(samplers: string[]): void;
  44909. /**
  44910. * Makes a duplicate of the current configuration into another one.
  44911. * @param sheenConfiguration define the config where to copy the info
  44912. */
  44913. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  44914. /**
  44915. * Serializes this BRDF configuration.
  44916. * @returns - An object with the serialized config.
  44917. */
  44918. serialize(): any;
  44919. /**
  44920. * Parses a Sheen Configuration from a serialized object.
  44921. * @param source - Serialized object.
  44922. */
  44923. parse(source: any): void;
  44924. }
  44925. }
  44926. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  44927. /** @hidden */
  44928. export var pbrFragmentDeclaration: {
  44929. name: string;
  44930. shader: string;
  44931. };
  44932. }
  44933. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  44934. /** @hidden */
  44935. export var pbrUboDeclaration: {
  44936. name: string;
  44937. shader: string;
  44938. };
  44939. }
  44940. declare module "babylonjs/Shaders/ShadersInclude/pbrFunctions" {
  44941. /** @hidden */
  44942. export var pbrFunctions: {
  44943. name: string;
  44944. shader: string;
  44945. };
  44946. }
  44947. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  44948. /** @hidden */
  44949. export var harmonicsFunctions: {
  44950. name: string;
  44951. shader: string;
  44952. };
  44953. }
  44954. declare module "babylonjs/Shaders/ShadersInclude/pbrPreLightingFunctions" {
  44955. /** @hidden */
  44956. export var pbrPreLightingFunctions: {
  44957. name: string;
  44958. shader: string;
  44959. };
  44960. }
  44961. declare module "babylonjs/Shaders/ShadersInclude/pbrFalloffLightingFunctions" {
  44962. /** @hidden */
  44963. export var pbrFalloffLightingFunctions: {
  44964. name: string;
  44965. shader: string;
  44966. };
  44967. }
  44968. declare module "babylonjs/Shaders/ShadersInclude/pbrLightingFunctions" {
  44969. /** @hidden */
  44970. export var pbrLightingFunctions: {
  44971. name: string;
  44972. shader: string;
  44973. };
  44974. }
  44975. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  44976. /** @hidden */
  44977. export var pbrDebug: {
  44978. name: string;
  44979. shader: string;
  44980. };
  44981. }
  44982. declare module "babylonjs/Shaders/pbr.fragment" {
  44983. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  44984. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  44985. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44986. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44987. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  44988. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44989. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44990. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44991. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  44992. import "babylonjs/Shaders/ShadersInclude/pbrFunctions";
  44993. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  44994. import "babylonjs/Shaders/ShadersInclude/pbrPreLightingFunctions";
  44995. import "babylonjs/Shaders/ShadersInclude/pbrFalloffLightingFunctions";
  44996. import "babylonjs/Shaders/ShadersInclude/pbrLightingFunctions";
  44997. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  44998. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  44999. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  45000. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  45001. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  45002. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  45003. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  45004. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  45005. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  45006. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  45007. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  45008. /** @hidden */
  45009. export var pbrPixelShader: {
  45010. name: string;
  45011. shader: string;
  45012. };
  45013. }
  45014. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  45015. /** @hidden */
  45016. export var pbrVertexDeclaration: {
  45017. name: string;
  45018. shader: string;
  45019. };
  45020. }
  45021. declare module "babylonjs/Shaders/pbr.vertex" {
  45022. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  45023. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  45024. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45025. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45026. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45027. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  45028. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  45029. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  45030. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  45031. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45032. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45033. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  45034. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  45035. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  45036. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  45037. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45038. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45039. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  45040. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  45041. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  45042. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  45043. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  45044. /** @hidden */
  45045. export var pbrVertexShader: {
  45046. name: string;
  45047. shader: string;
  45048. };
  45049. }
  45050. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  45051. import { IAnimatable } from "babylonjs/Misc/tools";
  45052. import { Nullable } from "babylonjs/types";
  45053. import { Scene } from "babylonjs/scene";
  45054. import { Matrix, Color3 } from "babylonjs/Maths/math";
  45055. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45056. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45057. import { Mesh } from "babylonjs/Meshes/mesh";
  45058. import { PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  45059. import { PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  45060. import { PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  45061. import { PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  45062. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45063. import { Material } from "babylonjs/Materials/material";
  45064. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  45065. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45066. import "babylonjs/Shaders/pbr.fragment";
  45067. import "babylonjs/Shaders/pbr.vertex";
  45068. /**
  45069. * The Physically based material base class of BJS.
  45070. *
  45071. * This offers the main features of a standard PBR material.
  45072. * For more information, please refer to the documentation :
  45073. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45074. */
  45075. export abstract class PBRBaseMaterial extends PushMaterial {
  45076. /**
  45077. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45078. */
  45079. static readonly PBRMATERIAL_OPAQUE: number;
  45080. /**
  45081. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45082. */
  45083. static readonly PBRMATERIAL_ALPHATEST: number;
  45084. /**
  45085. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45086. */
  45087. static readonly PBRMATERIAL_ALPHABLEND: number;
  45088. /**
  45089. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45090. * They are also discarded below the alpha cutoff threshold to improve performances.
  45091. */
  45092. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45093. /**
  45094. * Defines the default value of how much AO map is occluding the analytical lights
  45095. * (point spot...).
  45096. */
  45097. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45098. /**
  45099. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45100. */
  45101. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45102. /**
  45103. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45104. * to enhance interoperability with other engines.
  45105. */
  45106. static readonly LIGHTFALLOFF_GLTF: number;
  45107. /**
  45108. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45109. * to enhance interoperability with other materials.
  45110. */
  45111. static readonly LIGHTFALLOFF_STANDARD: number;
  45112. /**
  45113. * Intensity of the direct lights e.g. the four lights available in your scene.
  45114. * This impacts both the direct diffuse and specular highlights.
  45115. */
  45116. protected _directIntensity: number;
  45117. /**
  45118. * Intensity of the emissive part of the material.
  45119. * This helps controlling the emissive effect without modifying the emissive color.
  45120. */
  45121. protected _emissiveIntensity: number;
  45122. /**
  45123. * Intensity of the environment e.g. how much the environment will light the object
  45124. * either through harmonics for rough material or through the refelction for shiny ones.
  45125. */
  45126. protected _environmentIntensity: number;
  45127. /**
  45128. * This is a special control allowing the reduction of the specular highlights coming from the
  45129. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45130. */
  45131. protected _specularIntensity: number;
  45132. /**
  45133. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45134. */
  45135. private _lightingInfos;
  45136. /**
  45137. * Debug Control allowing disabling the bump map on this material.
  45138. */
  45139. protected _disableBumpMap: boolean;
  45140. /**
  45141. * AKA Diffuse Texture in standard nomenclature.
  45142. */
  45143. protected _albedoTexture: BaseTexture;
  45144. /**
  45145. * AKA Occlusion Texture in other nomenclature.
  45146. */
  45147. protected _ambientTexture: BaseTexture;
  45148. /**
  45149. * AKA Occlusion Texture Intensity in other nomenclature.
  45150. */
  45151. protected _ambientTextureStrength: number;
  45152. /**
  45153. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45154. * 1 means it completely occludes it
  45155. * 0 mean it has no impact
  45156. */
  45157. protected _ambientTextureImpactOnAnalyticalLights: number;
  45158. /**
  45159. * Stores the alpha values in a texture.
  45160. */
  45161. protected _opacityTexture: BaseTexture;
  45162. /**
  45163. * Stores the reflection values in a texture.
  45164. */
  45165. protected _reflectionTexture: BaseTexture;
  45166. /**
  45167. * Stores the refraction values in a texture.
  45168. */
  45169. protected _refractionTexture: BaseTexture;
  45170. /**
  45171. * Stores the emissive values in a texture.
  45172. */
  45173. protected _emissiveTexture: BaseTexture;
  45174. /**
  45175. * AKA Specular texture in other nomenclature.
  45176. */
  45177. protected _reflectivityTexture: BaseTexture;
  45178. /**
  45179. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45180. */
  45181. protected _metallicTexture: BaseTexture;
  45182. /**
  45183. * Specifies the metallic scalar of the metallic/roughness workflow.
  45184. * Can also be used to scale the metalness values of the metallic texture.
  45185. */
  45186. protected _metallic: Nullable<number>;
  45187. /**
  45188. * Specifies the roughness scalar of the metallic/roughness workflow.
  45189. * Can also be used to scale the roughness values of the metallic texture.
  45190. */
  45191. protected _roughness: Nullable<number>;
  45192. /**
  45193. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45194. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45195. */
  45196. protected _microSurfaceTexture: BaseTexture;
  45197. /**
  45198. * Stores surface normal data used to displace a mesh in a texture.
  45199. */
  45200. protected _bumpTexture: BaseTexture;
  45201. /**
  45202. * Stores the pre-calculated light information of a mesh in a texture.
  45203. */
  45204. protected _lightmapTexture: BaseTexture;
  45205. /**
  45206. * The color of a material in ambient lighting.
  45207. */
  45208. protected _ambientColor: Color3;
  45209. /**
  45210. * AKA Diffuse Color in other nomenclature.
  45211. */
  45212. protected _albedoColor: Color3;
  45213. /**
  45214. * AKA Specular Color in other nomenclature.
  45215. */
  45216. protected _reflectivityColor: Color3;
  45217. /**
  45218. * The color applied when light is reflected from a material.
  45219. */
  45220. protected _reflectionColor: Color3;
  45221. /**
  45222. * The color applied when light is emitted from a material.
  45223. */
  45224. protected _emissiveColor: Color3;
  45225. /**
  45226. * AKA Glossiness in other nomenclature.
  45227. */
  45228. protected _microSurface: number;
  45229. /**
  45230. * source material index of refraction (IOR)' / 'destination material IOR.
  45231. */
  45232. protected _indexOfRefraction: number;
  45233. /**
  45234. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45235. */
  45236. protected _invertRefractionY: boolean;
  45237. /**
  45238. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45239. * Materials half opaque for instance using refraction could benefit from this control.
  45240. */
  45241. protected _linkRefractionWithTransparency: boolean;
  45242. /**
  45243. * Specifies that the material will use the light map as a show map.
  45244. */
  45245. protected _useLightmapAsShadowmap: boolean;
  45246. /**
  45247. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45248. * makes the reflect vector face the model (under horizon).
  45249. */
  45250. protected _useHorizonOcclusion: boolean;
  45251. /**
  45252. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45253. * too much the area relying on ambient texture to define their ambient occlusion.
  45254. */
  45255. protected _useRadianceOcclusion: boolean;
  45256. /**
  45257. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45258. */
  45259. protected _useAlphaFromAlbedoTexture: boolean;
  45260. /**
  45261. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45262. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45263. */
  45264. protected _useSpecularOverAlpha: boolean;
  45265. /**
  45266. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45267. */
  45268. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45269. /**
  45270. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45271. */
  45272. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45273. /**
  45274. * Specifies if the metallic texture contains the roughness information in its green channel.
  45275. */
  45276. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45277. /**
  45278. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45279. */
  45280. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45281. /**
  45282. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45283. */
  45284. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45285. /**
  45286. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45287. */
  45288. protected _useAmbientInGrayScale: boolean;
  45289. /**
  45290. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45291. * The material will try to infer what glossiness each pixel should be.
  45292. */
  45293. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45294. /**
  45295. * Defines the falloff type used in this material.
  45296. * It by default is Physical.
  45297. */
  45298. protected _lightFalloff: number;
  45299. /**
  45300. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45301. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45302. */
  45303. protected _useRadianceOverAlpha: boolean;
  45304. /**
  45305. * Allows using an object space normal map (instead of tangent space).
  45306. */
  45307. protected _useObjectSpaceNormalMap: boolean;
  45308. /**
  45309. * Allows using the bump map in parallax mode.
  45310. */
  45311. protected _useParallax: boolean;
  45312. /**
  45313. * Allows using the bump map in parallax occlusion mode.
  45314. */
  45315. protected _useParallaxOcclusion: boolean;
  45316. /**
  45317. * Controls the scale bias of the parallax mode.
  45318. */
  45319. protected _parallaxScaleBias: number;
  45320. /**
  45321. * If sets to true, disables all the lights affecting the material.
  45322. */
  45323. protected _disableLighting: boolean;
  45324. /**
  45325. * Number of Simultaneous lights allowed on the material.
  45326. */
  45327. protected _maxSimultaneousLights: number;
  45328. /**
  45329. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45330. */
  45331. protected _invertNormalMapX: boolean;
  45332. /**
  45333. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45334. */
  45335. protected _invertNormalMapY: boolean;
  45336. /**
  45337. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45338. */
  45339. protected _twoSidedLighting: boolean;
  45340. /**
  45341. * Defines the alpha limits in alpha test mode.
  45342. */
  45343. protected _alphaCutOff: number;
  45344. /**
  45345. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45346. */
  45347. protected _forceAlphaTest: boolean;
  45348. /**
  45349. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45350. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45351. */
  45352. protected _useAlphaFresnel: boolean;
  45353. /**
  45354. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45355. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45356. */
  45357. protected _useLinearAlphaFresnel: boolean;
  45358. /**
  45359. * The transparency mode of the material.
  45360. */
  45361. protected _transparencyMode: Nullable<number>;
  45362. /**
  45363. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45364. * from cos thetav and roughness:
  45365. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45366. */
  45367. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45368. /**
  45369. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45370. */
  45371. protected _forceIrradianceInFragment: boolean;
  45372. /**
  45373. * Force normal to face away from face.
  45374. */
  45375. protected _forceNormalForward: boolean;
  45376. /**
  45377. * Enables specular anti aliasing in the PBR shader.
  45378. * It will both interacts on the Geometry for analytical and IBL lighting.
  45379. * It also prefilter the roughness map based on the bump values.
  45380. */
  45381. protected _enableSpecularAntiAliasing: boolean;
  45382. /**
  45383. * Default configuration related to image processing available in the PBR Material.
  45384. */
  45385. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45386. /**
  45387. * Keep track of the image processing observer to allow dispose and replace.
  45388. */
  45389. private _imageProcessingObserver;
  45390. /**
  45391. * Attaches a new image processing configuration to the PBR Material.
  45392. * @param configuration
  45393. */
  45394. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45395. /**
  45396. * Stores the available render targets.
  45397. */
  45398. private _renderTargets;
  45399. /**
  45400. * Sets the global ambient color for the material used in lighting calculations.
  45401. */
  45402. private _globalAmbientColor;
  45403. /**
  45404. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45405. */
  45406. private _useLogarithmicDepth;
  45407. /**
  45408. * If set to true, no lighting calculations will be applied.
  45409. */
  45410. private _unlit;
  45411. private _debugMode;
  45412. /**
  45413. * @hidden
  45414. * This is reserved for the inspector.
  45415. * Defines the material debug mode.
  45416. * It helps seeing only some components of the material while troubleshooting.
  45417. */
  45418. debugMode: number;
  45419. /**
  45420. * @hidden
  45421. * This is reserved for the inspector.
  45422. * Specify from where on screen the debug mode should start.
  45423. * The value goes from -1 (full screen) to 1 (not visible)
  45424. * It helps with side by side comparison against the final render
  45425. * This defaults to -1
  45426. */
  45427. private debugLimit;
  45428. /**
  45429. * @hidden
  45430. * This is reserved for the inspector.
  45431. * As the default viewing range might not be enough (if the ambient is really small for instance)
  45432. * You can use the factor to better multiply the final value.
  45433. */
  45434. private debugFactor;
  45435. /**
  45436. * Defines the clear coat layer parameters for the material.
  45437. */
  45438. readonly clearCoat: PBRClearCoatConfiguration;
  45439. /**
  45440. * Defines the anisotropic parameters for the material.
  45441. */
  45442. readonly anisotropy: PBRAnisotropicConfiguration;
  45443. /**
  45444. * Defines the BRDF parameters for the material.
  45445. */
  45446. readonly brdf: PBRBRDFConfiguration;
  45447. /**
  45448. * Defines the Sheen parameters for the material.
  45449. */
  45450. readonly sheen: PBRSheenConfiguration;
  45451. /**
  45452. * Instantiates a new PBRMaterial instance.
  45453. *
  45454. * @param name The material name
  45455. * @param scene The scene the material will be use in.
  45456. */
  45457. constructor(name: string, scene: Scene);
  45458. /**
  45459. * Gets a boolean indicating that current material needs to register RTT
  45460. */
  45461. readonly hasRenderTargetTextures: boolean;
  45462. /**
  45463. * Gets the name of the material class.
  45464. */
  45465. getClassName(): string;
  45466. /**
  45467. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45468. */
  45469. /**
  45470. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45471. */
  45472. useLogarithmicDepth: boolean;
  45473. /**
  45474. * Gets the current transparency mode.
  45475. */
  45476. /**
  45477. * Sets the transparency mode of the material.
  45478. *
  45479. * | Value | Type | Description |
  45480. * | ----- | ----------------------------------- | ----------- |
  45481. * | 0 | OPAQUE | |
  45482. * | 1 | ALPHATEST | |
  45483. * | 2 | ALPHABLEND | |
  45484. * | 3 | ALPHATESTANDBLEND | |
  45485. *
  45486. */
  45487. transparencyMode: Nullable<number>;
  45488. /**
  45489. * Returns true if alpha blending should be disabled.
  45490. */
  45491. private readonly _disableAlphaBlending;
  45492. /**
  45493. * Specifies whether or not this material should be rendered in alpha blend mode.
  45494. */
  45495. needAlphaBlending(): boolean;
  45496. /**
  45497. * Specifies if the mesh will require alpha blending.
  45498. * @param mesh - BJS mesh.
  45499. */
  45500. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45501. /**
  45502. * Specifies whether or not this material should be rendered in alpha test mode.
  45503. */
  45504. needAlphaTesting(): boolean;
  45505. /**
  45506. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45507. */
  45508. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45509. /**
  45510. * Gets the texture used for the alpha test.
  45511. */
  45512. getAlphaTestTexture(): BaseTexture;
  45513. /**
  45514. * Specifies that the submesh is ready to be used.
  45515. * @param mesh - BJS mesh.
  45516. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45517. * @param useInstances - Specifies that instances should be used.
  45518. * @returns - boolean indicating that the submesh is ready or not.
  45519. */
  45520. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45521. /**
  45522. * Specifies if the material uses metallic roughness workflow.
  45523. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45524. */
  45525. isMetallicWorkflow(): boolean;
  45526. private _prepareEffect;
  45527. private _prepareDefines;
  45528. /**
  45529. * Force shader compilation
  45530. */
  45531. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45532. clipPlane: boolean;
  45533. }>): void;
  45534. /**
  45535. * Initializes the uniform buffer layout for the shader.
  45536. */
  45537. buildUniformLayout(): void;
  45538. /**
  45539. * Unbinds the textures.
  45540. */
  45541. unbind(): void;
  45542. /**
  45543. * Binds the submesh data.
  45544. * @param world - The world matrix.
  45545. * @param mesh - The BJS mesh.
  45546. * @param subMesh - A submesh of the BJS mesh.
  45547. */
  45548. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45549. /**
  45550. * Returns the animatable textures.
  45551. * @returns - Array of animatable textures.
  45552. */
  45553. getAnimatables(): IAnimatable[];
  45554. /**
  45555. * Returns the texture used for reflections.
  45556. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45557. */
  45558. private _getReflectionTexture;
  45559. /**
  45560. * Returns the texture used for refraction or null if none is used.
  45561. * @returns - Refection texture if present. If no refraction texture and refraction
  45562. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45563. */
  45564. private _getRefractionTexture;
  45565. /**
  45566. * Returns an array of the actively used textures.
  45567. * @returns - Array of BaseTextures
  45568. */
  45569. getActiveTextures(): BaseTexture[];
  45570. /**
  45571. * Checks to see if a texture is used in the material.
  45572. * @param texture - Base texture to use.
  45573. * @returns - Boolean specifying if a texture is used in the material.
  45574. */
  45575. hasTexture(texture: BaseTexture): boolean;
  45576. /**
  45577. * Disposes the resources of the material.
  45578. * @param forceDisposeEffect - Forces the disposal of effects.
  45579. * @param forceDisposeTextures - Forces the disposal of all textures.
  45580. */
  45581. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45582. }
  45583. }
  45584. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  45585. import { Nullable } from "babylonjs/types";
  45586. import { Scene } from "babylonjs/scene";
  45587. import { Color3 } from "babylonjs/Maths/math";
  45588. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45589. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45590. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45591. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  45592. /**
  45593. * The Physically based material of BJS.
  45594. *
  45595. * This offers the main features of a standard PBR material.
  45596. * For more information, please refer to the documentation :
  45597. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45598. */
  45599. export class PBRMaterial extends PBRBaseMaterial {
  45600. /**
  45601. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45602. */
  45603. static readonly PBRMATERIAL_OPAQUE: number;
  45604. /**
  45605. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45606. */
  45607. static readonly PBRMATERIAL_ALPHATEST: number;
  45608. /**
  45609. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45610. */
  45611. static readonly PBRMATERIAL_ALPHABLEND: number;
  45612. /**
  45613. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45614. * They are also discarded below the alpha cutoff threshold to improve performances.
  45615. */
  45616. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45617. /**
  45618. * Defines the default value of how much AO map is occluding the analytical lights
  45619. * (point spot...).
  45620. */
  45621. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45622. /**
  45623. * Intensity of the direct lights e.g. the four lights available in your scene.
  45624. * This impacts both the direct diffuse and specular highlights.
  45625. */
  45626. directIntensity: number;
  45627. /**
  45628. * Intensity of the emissive part of the material.
  45629. * This helps controlling the emissive effect without modifying the emissive color.
  45630. */
  45631. emissiveIntensity: number;
  45632. /**
  45633. * Intensity of the environment e.g. how much the environment will light the object
  45634. * either through harmonics for rough material or through the refelction for shiny ones.
  45635. */
  45636. environmentIntensity: number;
  45637. /**
  45638. * This is a special control allowing the reduction of the specular highlights coming from the
  45639. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45640. */
  45641. specularIntensity: number;
  45642. /**
  45643. * Debug Control allowing disabling the bump map on this material.
  45644. */
  45645. disableBumpMap: boolean;
  45646. /**
  45647. * AKA Diffuse Texture in standard nomenclature.
  45648. */
  45649. albedoTexture: BaseTexture;
  45650. /**
  45651. * AKA Occlusion Texture in other nomenclature.
  45652. */
  45653. ambientTexture: BaseTexture;
  45654. /**
  45655. * AKA Occlusion Texture Intensity in other nomenclature.
  45656. */
  45657. ambientTextureStrength: number;
  45658. /**
  45659. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45660. * 1 means it completely occludes it
  45661. * 0 mean it has no impact
  45662. */
  45663. ambientTextureImpactOnAnalyticalLights: number;
  45664. /**
  45665. * Stores the alpha values in a texture.
  45666. */
  45667. opacityTexture: BaseTexture;
  45668. /**
  45669. * Stores the reflection values in a texture.
  45670. */
  45671. reflectionTexture: Nullable<BaseTexture>;
  45672. /**
  45673. * Stores the emissive values in a texture.
  45674. */
  45675. emissiveTexture: BaseTexture;
  45676. /**
  45677. * AKA Specular texture in other nomenclature.
  45678. */
  45679. reflectivityTexture: BaseTexture;
  45680. /**
  45681. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45682. */
  45683. metallicTexture: BaseTexture;
  45684. /**
  45685. * Specifies the metallic scalar of the metallic/roughness workflow.
  45686. * Can also be used to scale the metalness values of the metallic texture.
  45687. */
  45688. metallic: Nullable<number>;
  45689. /**
  45690. * Specifies the roughness scalar of the metallic/roughness workflow.
  45691. * Can also be used to scale the roughness values of the metallic texture.
  45692. */
  45693. roughness: Nullable<number>;
  45694. /**
  45695. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45696. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45697. */
  45698. microSurfaceTexture: BaseTexture;
  45699. /**
  45700. * Stores surface normal data used to displace a mesh in a texture.
  45701. */
  45702. bumpTexture: BaseTexture;
  45703. /**
  45704. * Stores the pre-calculated light information of a mesh in a texture.
  45705. */
  45706. lightmapTexture: BaseTexture;
  45707. /**
  45708. * Stores the refracted light information in a texture.
  45709. */
  45710. refractionTexture: BaseTexture;
  45711. /**
  45712. * The color of a material in ambient lighting.
  45713. */
  45714. ambientColor: Color3;
  45715. /**
  45716. * AKA Diffuse Color in other nomenclature.
  45717. */
  45718. albedoColor: Color3;
  45719. /**
  45720. * AKA Specular Color in other nomenclature.
  45721. */
  45722. reflectivityColor: Color3;
  45723. /**
  45724. * The color reflected from the material.
  45725. */
  45726. reflectionColor: Color3;
  45727. /**
  45728. * The color emitted from the material.
  45729. */
  45730. emissiveColor: Color3;
  45731. /**
  45732. * AKA Glossiness in other nomenclature.
  45733. */
  45734. microSurface: number;
  45735. /**
  45736. * source material index of refraction (IOR)' / 'destination material IOR.
  45737. */
  45738. indexOfRefraction: number;
  45739. /**
  45740. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45741. */
  45742. invertRefractionY: boolean;
  45743. /**
  45744. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45745. * Materials half opaque for instance using refraction could benefit from this control.
  45746. */
  45747. linkRefractionWithTransparency: boolean;
  45748. /**
  45749. * If true, the light map contains occlusion information instead of lighting info.
  45750. */
  45751. useLightmapAsShadowmap: boolean;
  45752. /**
  45753. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45754. */
  45755. useAlphaFromAlbedoTexture: boolean;
  45756. /**
  45757. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45758. */
  45759. forceAlphaTest: boolean;
  45760. /**
  45761. * Defines the alpha limits in alpha test mode.
  45762. */
  45763. alphaCutOff: number;
  45764. /**
  45765. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45766. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45767. */
  45768. useSpecularOverAlpha: boolean;
  45769. /**
  45770. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45771. */
  45772. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45773. /**
  45774. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45775. */
  45776. useRoughnessFromMetallicTextureAlpha: boolean;
  45777. /**
  45778. * Specifies if the metallic texture contains the roughness information in its green channel.
  45779. */
  45780. useRoughnessFromMetallicTextureGreen: boolean;
  45781. /**
  45782. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45783. */
  45784. useMetallnessFromMetallicTextureBlue: boolean;
  45785. /**
  45786. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45787. */
  45788. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45789. /**
  45790. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45791. */
  45792. useAmbientInGrayScale: boolean;
  45793. /**
  45794. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45795. * The material will try to infer what glossiness each pixel should be.
  45796. */
  45797. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45798. /**
  45799. * BJS is using an harcoded light falloff based on a manually sets up range.
  45800. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45801. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45802. */
  45803. /**
  45804. * BJS is using an harcoded light falloff based on a manually sets up range.
  45805. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45806. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45807. */
  45808. usePhysicalLightFalloff: boolean;
  45809. /**
  45810. * In order to support the falloff compatibility with gltf, a special mode has been added
  45811. * to reproduce the gltf light falloff.
  45812. */
  45813. /**
  45814. * In order to support the falloff compatibility with gltf, a special mode has been added
  45815. * to reproduce the gltf light falloff.
  45816. */
  45817. useGLTFLightFalloff: boolean;
  45818. /**
  45819. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45820. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45821. */
  45822. useRadianceOverAlpha: boolean;
  45823. /**
  45824. * Allows using an object space normal map (instead of tangent space).
  45825. */
  45826. useObjectSpaceNormalMap: boolean;
  45827. /**
  45828. * Allows using the bump map in parallax mode.
  45829. */
  45830. useParallax: boolean;
  45831. /**
  45832. * Allows using the bump map in parallax occlusion mode.
  45833. */
  45834. useParallaxOcclusion: boolean;
  45835. /**
  45836. * Controls the scale bias of the parallax mode.
  45837. */
  45838. parallaxScaleBias: number;
  45839. /**
  45840. * If sets to true, disables all the lights affecting the material.
  45841. */
  45842. disableLighting: boolean;
  45843. /**
  45844. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45845. */
  45846. forceIrradianceInFragment: boolean;
  45847. /**
  45848. * Number of Simultaneous lights allowed on the material.
  45849. */
  45850. maxSimultaneousLights: number;
  45851. /**
  45852. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45853. */
  45854. invertNormalMapX: boolean;
  45855. /**
  45856. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45857. */
  45858. invertNormalMapY: boolean;
  45859. /**
  45860. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45861. */
  45862. twoSidedLighting: boolean;
  45863. /**
  45864. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45865. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45866. */
  45867. useAlphaFresnel: boolean;
  45868. /**
  45869. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45870. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45871. */
  45872. useLinearAlphaFresnel: boolean;
  45873. /**
  45874. * Let user defines the brdf lookup texture used for IBL.
  45875. * A default 8bit version is embedded but you could point at :
  45876. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  45877. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45878. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45879. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45880. */
  45881. environmentBRDFTexture: Nullable<BaseTexture>;
  45882. /**
  45883. * Force normal to face away from face.
  45884. */
  45885. forceNormalForward: boolean;
  45886. /**
  45887. * Enables specular anti aliasing in the PBR shader.
  45888. * It will both interacts on the Geometry for analytical and IBL lighting.
  45889. * It also prefilter the roughness map based on the bump values.
  45890. */
  45891. enableSpecularAntiAliasing: boolean;
  45892. /**
  45893. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45894. * makes the reflect vector face the model (under horizon).
  45895. */
  45896. useHorizonOcclusion: boolean;
  45897. /**
  45898. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45899. * too much the area relying on ambient texture to define their ambient occlusion.
  45900. */
  45901. useRadianceOcclusion: boolean;
  45902. /**
  45903. * If set to true, no lighting calculations will be applied.
  45904. */
  45905. unlit: boolean;
  45906. /**
  45907. * Gets the image processing configuration used either in this material.
  45908. */
  45909. /**
  45910. * Sets the Default image processing configuration used either in the this material.
  45911. *
  45912. * If sets to null, the scene one is in use.
  45913. */
  45914. imageProcessingConfiguration: ImageProcessingConfiguration;
  45915. /**
  45916. * Gets wether the color curves effect is enabled.
  45917. */
  45918. /**
  45919. * Sets wether the color curves effect is enabled.
  45920. */
  45921. cameraColorCurvesEnabled: boolean;
  45922. /**
  45923. * Gets wether the color grading effect is enabled.
  45924. */
  45925. /**
  45926. * Gets wether the color grading effect is enabled.
  45927. */
  45928. cameraColorGradingEnabled: boolean;
  45929. /**
  45930. * Gets wether tonemapping is enabled or not.
  45931. */
  45932. /**
  45933. * Sets wether tonemapping is enabled or not
  45934. */
  45935. cameraToneMappingEnabled: boolean;
  45936. /**
  45937. * The camera exposure used on this material.
  45938. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45939. * This corresponds to a photographic exposure.
  45940. */
  45941. /**
  45942. * The camera exposure used on this material.
  45943. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45944. * This corresponds to a photographic exposure.
  45945. */
  45946. cameraExposure: number;
  45947. /**
  45948. * Gets The camera contrast used on this material.
  45949. */
  45950. /**
  45951. * Sets The camera contrast used on this material.
  45952. */
  45953. cameraContrast: number;
  45954. /**
  45955. * Gets the Color Grading 2D Lookup Texture.
  45956. */
  45957. /**
  45958. * Sets the Color Grading 2D Lookup Texture.
  45959. */
  45960. cameraColorGradingTexture: Nullable<BaseTexture>;
  45961. /**
  45962. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45963. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45964. * 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;
  45965. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45966. */
  45967. /**
  45968. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45969. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45970. * 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;
  45971. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45972. */
  45973. cameraColorCurves: Nullable<ColorCurves>;
  45974. /**
  45975. * Instantiates a new PBRMaterial instance.
  45976. *
  45977. * @param name The material name
  45978. * @param scene The scene the material will be use in.
  45979. */
  45980. constructor(name: string, scene: Scene);
  45981. /**
  45982. * Returns the name of this material class.
  45983. */
  45984. getClassName(): string;
  45985. /**
  45986. * Makes a duplicate of the current material.
  45987. * @param name - name to use for the new material.
  45988. */
  45989. clone(name: string): PBRMaterial;
  45990. /**
  45991. * Serializes this PBR Material.
  45992. * @returns - An object with the serialized material.
  45993. */
  45994. serialize(): any;
  45995. /**
  45996. * Parses a PBR Material from a serialized object.
  45997. * @param source - Serialized object.
  45998. * @param scene - BJS scene instance.
  45999. * @param rootUrl - url for the scene object
  46000. * @returns - PBRMaterial
  46001. */
  46002. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  46003. }
  46004. }
  46005. declare module "babylonjs/Misc/dds" {
  46006. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46007. import { Engine } from "babylonjs/Engines/engine";
  46008. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46009. import { Nullable } from "babylonjs/types";
  46010. import { Scene } from "babylonjs/scene";
  46011. /**
  46012. * Direct draw surface info
  46013. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  46014. */
  46015. export interface DDSInfo {
  46016. /**
  46017. * Width of the texture
  46018. */
  46019. width: number;
  46020. /**
  46021. * Width of the texture
  46022. */
  46023. height: number;
  46024. /**
  46025. * Number of Mipmaps for the texture
  46026. * @see https://en.wikipedia.org/wiki/Mipmap
  46027. */
  46028. mipmapCount: number;
  46029. /**
  46030. * If the textures format is a known fourCC format
  46031. * @see https://www.fourcc.org/
  46032. */
  46033. isFourCC: boolean;
  46034. /**
  46035. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  46036. */
  46037. isRGB: boolean;
  46038. /**
  46039. * If the texture is a lumincance format
  46040. */
  46041. isLuminance: boolean;
  46042. /**
  46043. * If this is a cube texture
  46044. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  46045. */
  46046. isCube: boolean;
  46047. /**
  46048. * If the texture is a compressed format eg. FOURCC_DXT1
  46049. */
  46050. isCompressed: boolean;
  46051. /**
  46052. * The dxgiFormat of the texture
  46053. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  46054. */
  46055. dxgiFormat: number;
  46056. /**
  46057. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  46058. */
  46059. textureType: number;
  46060. /**
  46061. * Sphericle polynomial created for the dds texture
  46062. */
  46063. sphericalPolynomial?: SphericalPolynomial;
  46064. }
  46065. /**
  46066. * Class used to provide DDS decompression tools
  46067. */
  46068. export class DDSTools {
  46069. /**
  46070. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  46071. */
  46072. static StoreLODInAlphaChannel: boolean;
  46073. /**
  46074. * Gets DDS information from an array buffer
  46075. * @param arrayBuffer defines the array buffer to read data from
  46076. * @returns the DDS information
  46077. */
  46078. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  46079. private static _FloatView;
  46080. private static _Int32View;
  46081. private static _ToHalfFloat;
  46082. private static _FromHalfFloat;
  46083. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  46084. private static _GetHalfFloatRGBAArrayBuffer;
  46085. private static _GetFloatRGBAArrayBuffer;
  46086. private static _GetFloatAsUIntRGBAArrayBuffer;
  46087. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  46088. private static _GetRGBAArrayBuffer;
  46089. private static _ExtractLongWordOrder;
  46090. private static _GetRGBArrayBuffer;
  46091. private static _GetLuminanceArrayBuffer;
  46092. /**
  46093. * Uploads DDS Levels to a Babylon Texture
  46094. * @hidden
  46095. */
  46096. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  46097. }
  46098. module "babylonjs/Engines/engine" {
  46099. interface Engine {
  46100. /**
  46101. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  46102. * @param rootUrl defines the url where the file to load is located
  46103. * @param scene defines the current scene
  46104. * @param lodScale defines scale to apply to the mip map selection
  46105. * @param lodOffset defines offset to apply to the mip map selection
  46106. * @param onLoad defines an optional callback raised when the texture is loaded
  46107. * @param onError defines an optional callback raised if there is an issue to load the texture
  46108. * @param format defines the format of the data
  46109. * @param forcedExtension defines the extension to use to pick the right loader
  46110. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  46111. * @returns the cube texture as an InternalTexture
  46112. */
  46113. 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;
  46114. }
  46115. }
  46116. }
  46117. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  46118. import { Nullable } from "babylonjs/types";
  46119. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46120. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46121. /**
  46122. * Implementation of the DDS Texture Loader.
  46123. * @hidden
  46124. */
  46125. export class _DDSTextureLoader implements IInternalTextureLoader {
  46126. /**
  46127. * Defines wether the loader supports cascade loading the different faces.
  46128. */
  46129. readonly supportCascades: boolean;
  46130. /**
  46131. * This returns if the loader support the current file information.
  46132. * @param extension defines the file extension of the file being loaded
  46133. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46134. * @param fallback defines the fallback internal texture if any
  46135. * @param isBase64 defines whether the texture is encoded as a base64
  46136. * @param isBuffer defines whether the texture data are stored as a buffer
  46137. * @returns true if the loader can load the specified file
  46138. */
  46139. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46140. /**
  46141. * Transform the url before loading if required.
  46142. * @param rootUrl the url of the texture
  46143. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46144. * @returns the transformed texture
  46145. */
  46146. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46147. /**
  46148. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46149. * @param rootUrl the url of the texture
  46150. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46151. * @returns the fallback texture
  46152. */
  46153. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46154. /**
  46155. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46156. * @param data contains the texture data
  46157. * @param texture defines the BabylonJS internal texture
  46158. * @param createPolynomials will be true if polynomials have been requested
  46159. * @param onLoad defines the callback to trigger once the texture is ready
  46160. * @param onError defines the callback to trigger in case of error
  46161. */
  46162. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46163. /**
  46164. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46165. * @param data contains the texture data
  46166. * @param texture defines the BabylonJS internal texture
  46167. * @param callback defines the method to call once ready to upload
  46168. */
  46169. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46170. }
  46171. }
  46172. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46173. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46174. /** @hidden */
  46175. export var rgbdEncodePixelShader: {
  46176. name: string;
  46177. shader: string;
  46178. };
  46179. }
  46180. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46181. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46182. /** @hidden */
  46183. export var rgbdDecodePixelShader: {
  46184. name: string;
  46185. shader: string;
  46186. };
  46187. }
  46188. declare module "babylonjs/Misc/environmentTextureTools" {
  46189. import { Nullable } from "babylonjs/types";
  46190. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46191. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46192. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46193. import "babylonjs/Shaders/rgbdEncode.fragment";
  46194. import "babylonjs/Shaders/rgbdDecode.fragment";
  46195. /**
  46196. * Raw texture data and descriptor sufficient for WebGL texture upload
  46197. */
  46198. export interface EnvironmentTextureInfo {
  46199. /**
  46200. * Version of the environment map
  46201. */
  46202. version: number;
  46203. /**
  46204. * Width of image
  46205. */
  46206. width: number;
  46207. /**
  46208. * Irradiance information stored in the file.
  46209. */
  46210. irradiance: any;
  46211. /**
  46212. * Specular information stored in the file.
  46213. */
  46214. specular: any;
  46215. }
  46216. /**
  46217. * Sets of helpers addressing the serialization and deserialization of environment texture
  46218. * stored in a BabylonJS env file.
  46219. * Those files are usually stored as .env files.
  46220. */
  46221. export class EnvironmentTextureTools {
  46222. /**
  46223. * Magic number identifying the env file.
  46224. */
  46225. private static _MagicBytes;
  46226. /**
  46227. * Gets the environment info from an env file.
  46228. * @param data The array buffer containing the .env bytes.
  46229. * @returns the environment file info (the json header) if successfully parsed.
  46230. */
  46231. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46232. /**
  46233. * Creates an environment texture from a loaded cube texture.
  46234. * @param texture defines the cube texture to convert in env file
  46235. * @return a promise containing the environment data if succesfull.
  46236. */
  46237. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46238. /**
  46239. * Creates a JSON representation of the spherical data.
  46240. * @param texture defines the texture containing the polynomials
  46241. * @return the JSON representation of the spherical info
  46242. */
  46243. private static _CreateEnvTextureIrradiance;
  46244. /**
  46245. * Uploads the texture info contained in the env file to the GPU.
  46246. * @param texture defines the internal texture to upload to
  46247. * @param arrayBuffer defines the buffer cotaining the data to load
  46248. * @param info defines the texture info retrieved through the GetEnvInfo method
  46249. * @returns a promise
  46250. */
  46251. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46252. /**
  46253. * Uploads the levels of image data to the GPU.
  46254. * @param texture defines the internal texture to upload to
  46255. * @param imageData defines the array buffer views of image data [mipmap][face]
  46256. * @returns a promise
  46257. */
  46258. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46259. /**
  46260. * Uploads spherical polynomials information to the texture.
  46261. * @param texture defines the texture we are trying to upload the information to
  46262. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46263. */
  46264. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46265. /** @hidden */
  46266. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46267. }
  46268. }
  46269. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  46270. import { Nullable } from "babylonjs/types";
  46271. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46272. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46273. /**
  46274. * Implementation of the ENV Texture Loader.
  46275. * @hidden
  46276. */
  46277. export class _ENVTextureLoader implements IInternalTextureLoader {
  46278. /**
  46279. * Defines wether the loader supports cascade loading the different faces.
  46280. */
  46281. readonly supportCascades: boolean;
  46282. /**
  46283. * This returns if the loader support the current file information.
  46284. * @param extension defines the file extension of the file being loaded
  46285. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46286. * @param fallback defines the fallback internal texture if any
  46287. * @param isBase64 defines whether the texture is encoded as a base64
  46288. * @param isBuffer defines whether the texture data are stored as a buffer
  46289. * @returns true if the loader can load the specified file
  46290. */
  46291. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46292. /**
  46293. * Transform the url before loading if required.
  46294. * @param rootUrl the url of the texture
  46295. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46296. * @returns the transformed texture
  46297. */
  46298. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46299. /**
  46300. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46301. * @param rootUrl the url of the texture
  46302. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46303. * @returns the fallback texture
  46304. */
  46305. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46306. /**
  46307. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46308. * @param data contains the texture data
  46309. * @param texture defines the BabylonJS internal texture
  46310. * @param createPolynomials will be true if polynomials have been requested
  46311. * @param onLoad defines the callback to trigger once the texture is ready
  46312. * @param onError defines the callback to trigger in case of error
  46313. */
  46314. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46315. /**
  46316. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46317. * @param data contains the texture data
  46318. * @param texture defines the BabylonJS internal texture
  46319. * @param callback defines the method to call once ready to upload
  46320. */
  46321. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46322. }
  46323. }
  46324. declare module "babylonjs/Misc/khronosTextureContainer" {
  46325. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46326. /**
  46327. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46328. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46329. */
  46330. export class KhronosTextureContainer {
  46331. /** contents of the KTX container file */
  46332. arrayBuffer: any;
  46333. private static HEADER_LEN;
  46334. private static COMPRESSED_2D;
  46335. private static COMPRESSED_3D;
  46336. private static TEX_2D;
  46337. private static TEX_3D;
  46338. /**
  46339. * Gets the openGL type
  46340. */
  46341. glType: number;
  46342. /**
  46343. * Gets the openGL type size
  46344. */
  46345. glTypeSize: number;
  46346. /**
  46347. * Gets the openGL format
  46348. */
  46349. glFormat: number;
  46350. /**
  46351. * Gets the openGL internal format
  46352. */
  46353. glInternalFormat: number;
  46354. /**
  46355. * Gets the base internal format
  46356. */
  46357. glBaseInternalFormat: number;
  46358. /**
  46359. * Gets image width in pixel
  46360. */
  46361. pixelWidth: number;
  46362. /**
  46363. * Gets image height in pixel
  46364. */
  46365. pixelHeight: number;
  46366. /**
  46367. * Gets image depth in pixels
  46368. */
  46369. pixelDepth: number;
  46370. /**
  46371. * Gets the number of array elements
  46372. */
  46373. numberOfArrayElements: number;
  46374. /**
  46375. * Gets the number of faces
  46376. */
  46377. numberOfFaces: number;
  46378. /**
  46379. * Gets the number of mipmap levels
  46380. */
  46381. numberOfMipmapLevels: number;
  46382. /**
  46383. * Gets the bytes of key value data
  46384. */
  46385. bytesOfKeyValueData: number;
  46386. /**
  46387. * Gets the load type
  46388. */
  46389. loadType: number;
  46390. /**
  46391. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46392. */
  46393. isInvalid: boolean;
  46394. /**
  46395. * Creates a new KhronosTextureContainer
  46396. * @param arrayBuffer contents of the KTX container file
  46397. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46398. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46399. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46400. */
  46401. constructor(
  46402. /** contents of the KTX container file */
  46403. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46404. /**
  46405. * Uploads KTX content to a Babylon Texture.
  46406. * It is assumed that the texture has already been created & is currently bound
  46407. * @hidden
  46408. */
  46409. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46410. private _upload2DCompressedLevels;
  46411. }
  46412. }
  46413. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  46414. import { Nullable } from "babylonjs/types";
  46415. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46416. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46417. /**
  46418. * Implementation of the KTX Texture Loader.
  46419. * @hidden
  46420. */
  46421. export class _KTXTextureLoader implements IInternalTextureLoader {
  46422. /**
  46423. * Defines wether the loader supports cascade loading the different faces.
  46424. */
  46425. readonly supportCascades: boolean;
  46426. /**
  46427. * This returns if the loader support the current file information.
  46428. * @param extension defines the file extension of the file being loaded
  46429. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46430. * @param fallback defines the fallback internal texture if any
  46431. * @param isBase64 defines whether the texture is encoded as a base64
  46432. * @param isBuffer defines whether the texture data are stored as a buffer
  46433. * @returns true if the loader can load the specified file
  46434. */
  46435. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46436. /**
  46437. * Transform the url before loading if required.
  46438. * @param rootUrl the url of the texture
  46439. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46440. * @returns the transformed texture
  46441. */
  46442. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46443. /**
  46444. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46445. * @param rootUrl the url of the texture
  46446. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46447. * @returns the fallback texture
  46448. */
  46449. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46450. /**
  46451. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46452. * @param data contains the texture data
  46453. * @param texture defines the BabylonJS internal texture
  46454. * @param createPolynomials will be true if polynomials have been requested
  46455. * @param onLoad defines the callback to trigger once the texture is ready
  46456. * @param onError defines the callback to trigger in case of error
  46457. */
  46458. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46459. /**
  46460. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46461. * @param data contains the texture data
  46462. * @param texture defines the BabylonJS internal texture
  46463. * @param callback defines the method to call once ready to upload
  46464. */
  46465. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  46466. }
  46467. }
  46468. declare module "babylonjs/Helpers/sceneHelpers" {
  46469. import { Nullable } from "babylonjs/types";
  46470. import { Mesh } from "babylonjs/Meshes/mesh";
  46471. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46472. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  46473. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  46474. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  46475. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  46476. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  46477. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  46478. import "babylonjs/Meshes/Builders/boxBuilder";
  46479. /** @hidden */
  46480. export var _forceSceneHelpersToBundle: boolean;
  46481. module "babylonjs/scene" {
  46482. interface Scene {
  46483. /**
  46484. * Creates a default light for the scene.
  46485. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  46486. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  46487. */
  46488. createDefaultLight(replace?: boolean): void;
  46489. /**
  46490. * Creates a default camera for the scene.
  46491. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  46492. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46493. * @param replace has default false, when true replaces the active camera in the scene
  46494. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  46495. */
  46496. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46497. /**
  46498. * Creates a default camera and a default light.
  46499. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  46500. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46501. * @param replace has the default false, when true replaces the active camera/light in the scene
  46502. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  46503. */
  46504. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46505. /**
  46506. * Creates a new sky box
  46507. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  46508. * @param environmentTexture defines the texture to use as environment texture
  46509. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  46510. * @param scale defines the overall scale of the skybox
  46511. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  46512. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  46513. * @returns a new mesh holding the sky box
  46514. */
  46515. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  46516. /**
  46517. * Creates a new environment
  46518. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  46519. * @param options defines the options you can use to configure the environment
  46520. * @returns the new EnvironmentHelper
  46521. */
  46522. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  46523. /**
  46524. * Creates a new VREXperienceHelper
  46525. * @see http://doc.babylonjs.com/how_to/webvr_helper
  46526. * @param webVROptions defines the options used to create the new VREXperienceHelper
  46527. * @returns a new VREXperienceHelper
  46528. */
  46529. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  46530. /**
  46531. * Creates a new XREXperienceHelper
  46532. * @see http://doc.babylonjs.com/how_to/webxr
  46533. * @returns a promise for a new XREXperienceHelper
  46534. */
  46535. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  46536. }
  46537. }
  46538. }
  46539. declare module "babylonjs/Helpers/videoDome" {
  46540. import { Scene } from "babylonjs/scene";
  46541. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46542. import { Mesh } from "babylonjs/Meshes/mesh";
  46543. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  46544. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46545. import "babylonjs/Meshes/Builders/sphereBuilder";
  46546. /**
  46547. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  46548. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  46549. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  46550. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46551. */
  46552. export class VideoDome extends TransformNode {
  46553. /**
  46554. * Define the video source as a Monoscopic panoramic 360 video.
  46555. */
  46556. static readonly MODE_MONOSCOPIC: number;
  46557. /**
  46558. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46559. */
  46560. static readonly MODE_TOPBOTTOM: number;
  46561. /**
  46562. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46563. */
  46564. static readonly MODE_SIDEBYSIDE: number;
  46565. private _useDirectMapping;
  46566. /**
  46567. * The video texture being displayed on the sphere
  46568. */
  46569. protected _videoTexture: VideoTexture;
  46570. /**
  46571. * Gets the video texture being displayed on the sphere
  46572. */
  46573. readonly videoTexture: VideoTexture;
  46574. /**
  46575. * The skybox material
  46576. */
  46577. protected _material: BackgroundMaterial;
  46578. /**
  46579. * The surface used for the skybox
  46580. */
  46581. protected _mesh: Mesh;
  46582. /**
  46583. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46584. * Also see the options.resolution property.
  46585. */
  46586. fovMultiplier: number;
  46587. private _videoMode;
  46588. /**
  46589. * Gets or set the current video mode for the video. It can be:
  46590. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  46591. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46592. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46593. */
  46594. videoMode: number;
  46595. /**
  46596. * Oberserver used in Stereoscopic VR Mode.
  46597. */
  46598. private _onBeforeCameraRenderObserver;
  46599. /**
  46600. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  46601. * @param name Element's name, child elements will append suffixes for their own names.
  46602. * @param urlsOrVideo defines the url(s) or the video element to use
  46603. * @param options An object containing optional or exposed sub element properties
  46604. */
  46605. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  46606. resolution?: number;
  46607. clickToPlay?: boolean;
  46608. autoPlay?: boolean;
  46609. loop?: boolean;
  46610. size?: number;
  46611. poster?: string;
  46612. useDirectMapping?: boolean;
  46613. }, scene: Scene);
  46614. private _changeVideoMode;
  46615. /**
  46616. * Releases resources associated with this node.
  46617. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46618. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46619. */
  46620. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46621. }
  46622. }
  46623. declare module "babylonjs/Helpers/index" {
  46624. export * from "babylonjs/Helpers/environmentHelper";
  46625. export * from "babylonjs/Helpers/photoDome";
  46626. export * from "babylonjs/Helpers/sceneHelpers";
  46627. export * from "babylonjs/Helpers/videoDome";
  46628. }
  46629. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  46630. import { PerfCounter } from "babylonjs/Misc/tools";
  46631. import { IDisposable } from "babylonjs/scene";
  46632. import { Engine } from "babylonjs/Engines/engine";
  46633. /**
  46634. * This class can be used to get instrumentation data from a Babylon engine
  46635. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46636. */
  46637. export class EngineInstrumentation implements IDisposable {
  46638. /**
  46639. * Define the instrumented engine.
  46640. */
  46641. engine: Engine;
  46642. private _captureGPUFrameTime;
  46643. private _gpuFrameTimeToken;
  46644. private _gpuFrameTime;
  46645. private _captureShaderCompilationTime;
  46646. private _shaderCompilationTime;
  46647. private _onBeginFrameObserver;
  46648. private _onEndFrameObserver;
  46649. private _onBeforeShaderCompilationObserver;
  46650. private _onAfterShaderCompilationObserver;
  46651. /**
  46652. * Gets the perf counter used for GPU frame time
  46653. */
  46654. readonly gpuFrameTimeCounter: PerfCounter;
  46655. /**
  46656. * Gets the GPU frame time capture status
  46657. */
  46658. /**
  46659. * Enable or disable the GPU frame time capture
  46660. */
  46661. captureGPUFrameTime: boolean;
  46662. /**
  46663. * Gets the perf counter used for shader compilation time
  46664. */
  46665. readonly shaderCompilationTimeCounter: PerfCounter;
  46666. /**
  46667. * Gets the shader compilation time capture status
  46668. */
  46669. /**
  46670. * Enable or disable the shader compilation time capture
  46671. */
  46672. captureShaderCompilationTime: boolean;
  46673. /**
  46674. * Instantiates a new engine instrumentation.
  46675. * This class can be used to get instrumentation data from a Babylon engine
  46676. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46677. * @param engine Defines the engine to instrument
  46678. */
  46679. constructor(
  46680. /**
  46681. * Define the instrumented engine.
  46682. */
  46683. engine: Engine);
  46684. /**
  46685. * Dispose and release associated resources.
  46686. */
  46687. dispose(): void;
  46688. }
  46689. }
  46690. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  46691. import { PerfCounter } from "babylonjs/Misc/tools";
  46692. import { Scene, IDisposable } from "babylonjs/scene";
  46693. /**
  46694. * This class can be used to get instrumentation data from a Babylon engine
  46695. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46696. */
  46697. export class SceneInstrumentation implements IDisposable {
  46698. /**
  46699. * Defines the scene to instrument
  46700. */
  46701. scene: Scene;
  46702. private _captureActiveMeshesEvaluationTime;
  46703. private _activeMeshesEvaluationTime;
  46704. private _captureRenderTargetsRenderTime;
  46705. private _renderTargetsRenderTime;
  46706. private _captureFrameTime;
  46707. private _frameTime;
  46708. private _captureRenderTime;
  46709. private _renderTime;
  46710. private _captureInterFrameTime;
  46711. private _interFrameTime;
  46712. private _captureParticlesRenderTime;
  46713. private _particlesRenderTime;
  46714. private _captureSpritesRenderTime;
  46715. private _spritesRenderTime;
  46716. private _capturePhysicsTime;
  46717. private _physicsTime;
  46718. private _captureAnimationsTime;
  46719. private _animationsTime;
  46720. private _captureCameraRenderTime;
  46721. private _cameraRenderTime;
  46722. private _onBeforeActiveMeshesEvaluationObserver;
  46723. private _onAfterActiveMeshesEvaluationObserver;
  46724. private _onBeforeRenderTargetsRenderObserver;
  46725. private _onAfterRenderTargetsRenderObserver;
  46726. private _onAfterRenderObserver;
  46727. private _onBeforeDrawPhaseObserver;
  46728. private _onAfterDrawPhaseObserver;
  46729. private _onBeforeAnimationsObserver;
  46730. private _onBeforeParticlesRenderingObserver;
  46731. private _onAfterParticlesRenderingObserver;
  46732. private _onBeforeSpritesRenderingObserver;
  46733. private _onAfterSpritesRenderingObserver;
  46734. private _onBeforePhysicsObserver;
  46735. private _onAfterPhysicsObserver;
  46736. private _onAfterAnimationsObserver;
  46737. private _onBeforeCameraRenderObserver;
  46738. private _onAfterCameraRenderObserver;
  46739. /**
  46740. * Gets the perf counter used for active meshes evaluation time
  46741. */
  46742. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  46743. /**
  46744. * Gets the active meshes evaluation time capture status
  46745. */
  46746. /**
  46747. * Enable or disable the active meshes evaluation time capture
  46748. */
  46749. captureActiveMeshesEvaluationTime: boolean;
  46750. /**
  46751. * Gets the perf counter used for render targets render time
  46752. */
  46753. readonly renderTargetsRenderTimeCounter: PerfCounter;
  46754. /**
  46755. * Gets the render targets render time capture status
  46756. */
  46757. /**
  46758. * Enable or disable the render targets render time capture
  46759. */
  46760. captureRenderTargetsRenderTime: boolean;
  46761. /**
  46762. * Gets the perf counter used for particles render time
  46763. */
  46764. readonly particlesRenderTimeCounter: PerfCounter;
  46765. /**
  46766. * Gets the particles render time capture status
  46767. */
  46768. /**
  46769. * Enable or disable the particles render time capture
  46770. */
  46771. captureParticlesRenderTime: boolean;
  46772. /**
  46773. * Gets the perf counter used for sprites render time
  46774. */
  46775. readonly spritesRenderTimeCounter: PerfCounter;
  46776. /**
  46777. * Gets the sprites render time capture status
  46778. */
  46779. /**
  46780. * Enable or disable the sprites render time capture
  46781. */
  46782. captureSpritesRenderTime: boolean;
  46783. /**
  46784. * Gets the perf counter used for physics time
  46785. */
  46786. readonly physicsTimeCounter: PerfCounter;
  46787. /**
  46788. * Gets the physics time capture status
  46789. */
  46790. /**
  46791. * Enable or disable the physics time capture
  46792. */
  46793. capturePhysicsTime: boolean;
  46794. /**
  46795. * Gets the perf counter used for animations time
  46796. */
  46797. readonly animationsTimeCounter: PerfCounter;
  46798. /**
  46799. * Gets the animations time capture status
  46800. */
  46801. /**
  46802. * Enable or disable the animations time capture
  46803. */
  46804. captureAnimationsTime: boolean;
  46805. /**
  46806. * Gets the perf counter used for frame time capture
  46807. */
  46808. readonly frameTimeCounter: PerfCounter;
  46809. /**
  46810. * Gets the frame time capture status
  46811. */
  46812. /**
  46813. * Enable or disable the frame time capture
  46814. */
  46815. captureFrameTime: boolean;
  46816. /**
  46817. * Gets the perf counter used for inter-frames time capture
  46818. */
  46819. readonly interFrameTimeCounter: PerfCounter;
  46820. /**
  46821. * Gets the inter-frames time capture status
  46822. */
  46823. /**
  46824. * Enable or disable the inter-frames time capture
  46825. */
  46826. captureInterFrameTime: boolean;
  46827. /**
  46828. * Gets the perf counter used for render time capture
  46829. */
  46830. readonly renderTimeCounter: PerfCounter;
  46831. /**
  46832. * Gets the render time capture status
  46833. */
  46834. /**
  46835. * Enable or disable the render time capture
  46836. */
  46837. captureRenderTime: boolean;
  46838. /**
  46839. * Gets the perf counter used for camera render time capture
  46840. */
  46841. readonly cameraRenderTimeCounter: PerfCounter;
  46842. /**
  46843. * Gets the camera render time capture status
  46844. */
  46845. /**
  46846. * Enable or disable the camera render time capture
  46847. */
  46848. captureCameraRenderTime: boolean;
  46849. /**
  46850. * Gets the perf counter used for draw calls
  46851. */
  46852. readonly drawCallsCounter: PerfCounter;
  46853. /**
  46854. * Gets the perf counter used for texture collisions
  46855. */
  46856. readonly textureCollisionsCounter: PerfCounter;
  46857. /**
  46858. * Instantiates a new scene instrumentation.
  46859. * This class can be used to get instrumentation data from a Babylon engine
  46860. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46861. * @param scene Defines the scene to instrument
  46862. */
  46863. constructor(
  46864. /**
  46865. * Defines the scene to instrument
  46866. */
  46867. scene: Scene);
  46868. /**
  46869. * Dispose and release associated resources.
  46870. */
  46871. dispose(): void;
  46872. }
  46873. }
  46874. declare module "babylonjs/Instrumentation/index" {
  46875. export * from "babylonjs/Instrumentation/engineInstrumentation";
  46876. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  46877. export * from "babylonjs/Instrumentation/timeToken";
  46878. }
  46879. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  46880. /** @hidden */
  46881. export var glowMapGenerationPixelShader: {
  46882. name: string;
  46883. shader: string;
  46884. };
  46885. }
  46886. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  46887. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46888. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  46889. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  46890. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46891. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  46892. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46893. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46894. /** @hidden */
  46895. export var glowMapGenerationVertexShader: {
  46896. name: string;
  46897. shader: string;
  46898. };
  46899. }
  46900. declare module "babylonjs/Layers/effectLayer" {
  46901. import { Observable } from "babylonjs/Misc/observable";
  46902. import { Nullable } from "babylonjs/types";
  46903. import { Camera } from "babylonjs/Cameras/camera";
  46904. import { Scene } from "babylonjs/scene";
  46905. import { Color4, ISize } from "babylonjs/Maths/math";
  46906. import { Engine } from "babylonjs/Engines/engine";
  46907. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46908. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46909. import { Mesh } from "babylonjs/Meshes/mesh";
  46910. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  46911. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46912. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46913. import { Effect } from "babylonjs/Materials/effect";
  46914. import { Material } from "babylonjs/Materials/material";
  46915. import "babylonjs/Shaders/glowMapGeneration.fragment";
  46916. import "babylonjs/Shaders/glowMapGeneration.vertex";
  46917. /**
  46918. * Effect layer options. This helps customizing the behaviour
  46919. * of the effect layer.
  46920. */
  46921. export interface IEffectLayerOptions {
  46922. /**
  46923. * Multiplication factor apply to the canvas size to compute the render target size
  46924. * used to generated the objects (the smaller the faster).
  46925. */
  46926. mainTextureRatio: number;
  46927. /**
  46928. * Enforces a fixed size texture to ensure effect stability across devices.
  46929. */
  46930. mainTextureFixedSize?: number;
  46931. /**
  46932. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  46933. */
  46934. alphaBlendingMode: number;
  46935. /**
  46936. * The camera attached to the layer.
  46937. */
  46938. camera: Nullable<Camera>;
  46939. /**
  46940. * The rendering group to draw the layer in.
  46941. */
  46942. renderingGroupId: number;
  46943. }
  46944. /**
  46945. * The effect layer Helps adding post process effect blended with the main pass.
  46946. *
  46947. * This can be for instance use to generate glow or higlight effects on the scene.
  46948. *
  46949. * The effect layer class can not be used directly and is intented to inherited from to be
  46950. * customized per effects.
  46951. */
  46952. export abstract class EffectLayer {
  46953. private _vertexBuffers;
  46954. private _indexBuffer;
  46955. private _cachedDefines;
  46956. private _effectLayerMapGenerationEffect;
  46957. private _effectLayerOptions;
  46958. private _mergeEffect;
  46959. protected _scene: Scene;
  46960. protected _engine: Engine;
  46961. protected _maxSize: number;
  46962. protected _mainTextureDesiredSize: ISize;
  46963. protected _mainTexture: RenderTargetTexture;
  46964. protected _shouldRender: boolean;
  46965. protected _postProcesses: PostProcess[];
  46966. protected _textures: BaseTexture[];
  46967. protected _emissiveTextureAndColor: {
  46968. texture: Nullable<BaseTexture>;
  46969. color: Color4;
  46970. };
  46971. /**
  46972. * The name of the layer
  46973. */
  46974. name: string;
  46975. /**
  46976. * The clear color of the texture used to generate the glow map.
  46977. */
  46978. neutralColor: Color4;
  46979. /**
  46980. * Specifies wether the highlight layer is enabled or not.
  46981. */
  46982. isEnabled: boolean;
  46983. /**
  46984. * Gets the camera attached to the layer.
  46985. */
  46986. readonly camera: Nullable<Camera>;
  46987. /**
  46988. * Gets the rendering group id the layer should render in.
  46989. */
  46990. readonly renderingGroupId: number;
  46991. /**
  46992. * An event triggered when the effect layer has been disposed.
  46993. */
  46994. onDisposeObservable: Observable<EffectLayer>;
  46995. /**
  46996. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  46997. */
  46998. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  46999. /**
  47000. * An event triggered when the generated texture is being merged in the scene.
  47001. */
  47002. onBeforeComposeObservable: Observable<EffectLayer>;
  47003. /**
  47004. * An event triggered when the generated texture has been merged in the scene.
  47005. */
  47006. onAfterComposeObservable: Observable<EffectLayer>;
  47007. /**
  47008. * An event triggered when the efffect layer changes its size.
  47009. */
  47010. onSizeChangedObservable: Observable<EffectLayer>;
  47011. /** @hidden */
  47012. static _SceneComponentInitialization: (scene: Scene) => void;
  47013. /**
  47014. * Instantiates a new effect Layer and references it in the scene.
  47015. * @param name The name of the layer
  47016. * @param scene The scene to use the layer in
  47017. */
  47018. constructor(
  47019. /** The Friendly of the effect in the scene */
  47020. name: string, scene: Scene);
  47021. /**
  47022. * Get the effect name of the layer.
  47023. * @return The effect name
  47024. */
  47025. abstract getEffectName(): string;
  47026. /**
  47027. * Checks for the readiness of the element composing the layer.
  47028. * @param subMesh the mesh to check for
  47029. * @param useInstances specify wether or not to use instances to render the mesh
  47030. * @return true if ready otherwise, false
  47031. */
  47032. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47033. /**
  47034. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47035. * @returns true if the effect requires stencil during the main canvas render pass.
  47036. */
  47037. abstract needStencil(): boolean;
  47038. /**
  47039. * Create the merge effect. This is the shader use to blit the information back
  47040. * to the main canvas at the end of the scene rendering.
  47041. * @returns The effect containing the shader used to merge the effect on the main canvas
  47042. */
  47043. protected abstract _createMergeEffect(): Effect;
  47044. /**
  47045. * Creates the render target textures and post processes used in the effect layer.
  47046. */
  47047. protected abstract _createTextureAndPostProcesses(): void;
  47048. /**
  47049. * Implementation specific of rendering the generating effect on the main canvas.
  47050. * @param effect The effect used to render through
  47051. */
  47052. protected abstract _internalRender(effect: Effect): void;
  47053. /**
  47054. * Sets the required values for both the emissive texture and and the main color.
  47055. */
  47056. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47057. /**
  47058. * Free any resources and references associated to a mesh.
  47059. * Internal use
  47060. * @param mesh The mesh to free.
  47061. */
  47062. abstract _disposeMesh(mesh: Mesh): void;
  47063. /**
  47064. * Serializes this layer (Glow or Highlight for example)
  47065. * @returns a serialized layer object
  47066. */
  47067. abstract serialize?(): any;
  47068. /**
  47069. * Initializes the effect layer with the required options.
  47070. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  47071. */
  47072. protected _init(options: Partial<IEffectLayerOptions>): void;
  47073. /**
  47074. * Generates the index buffer of the full screen quad blending to the main canvas.
  47075. */
  47076. private _generateIndexBuffer;
  47077. /**
  47078. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  47079. */
  47080. private _genrateVertexBuffer;
  47081. /**
  47082. * Sets the main texture desired size which is the closest power of two
  47083. * of the engine canvas size.
  47084. */
  47085. private _setMainTextureSize;
  47086. /**
  47087. * Creates the main texture for the effect layer.
  47088. */
  47089. protected _createMainTexture(): void;
  47090. /**
  47091. * Adds specific effects defines.
  47092. * @param defines The defines to add specifics to.
  47093. */
  47094. protected _addCustomEffectDefines(defines: string[]): void;
  47095. /**
  47096. * Checks for the readiness of the element composing the layer.
  47097. * @param subMesh the mesh to check for
  47098. * @param useInstances specify wether or not to use instances to render the mesh
  47099. * @param emissiveTexture the associated emissive texture used to generate the glow
  47100. * @return true if ready otherwise, false
  47101. */
  47102. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  47103. /**
  47104. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  47105. */
  47106. render(): void;
  47107. /**
  47108. * Determine if a given mesh will be used in the current effect.
  47109. * @param mesh mesh to test
  47110. * @returns true if the mesh will be used
  47111. */
  47112. hasMesh(mesh: AbstractMesh): boolean;
  47113. /**
  47114. * Returns true if the layer contains information to display, otherwise false.
  47115. * @returns true if the glow layer should be rendered
  47116. */
  47117. shouldRender(): boolean;
  47118. /**
  47119. * Returns true if the mesh should render, otherwise false.
  47120. * @param mesh The mesh to render
  47121. * @returns true if it should render otherwise false
  47122. */
  47123. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  47124. /**
  47125. * Returns true if the mesh can be rendered, otherwise false.
  47126. * @param mesh The mesh to render
  47127. * @param material The material used on the mesh
  47128. * @returns true if it can be rendered otherwise false
  47129. */
  47130. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47131. /**
  47132. * Returns true if the mesh should render, otherwise false.
  47133. * @param mesh The mesh to render
  47134. * @returns true if it should render otherwise false
  47135. */
  47136. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  47137. /**
  47138. * Renders the submesh passed in parameter to the generation map.
  47139. */
  47140. protected _renderSubMesh(subMesh: SubMesh): void;
  47141. /**
  47142. * Rebuild the required buffers.
  47143. * @hidden Internal use only.
  47144. */
  47145. _rebuild(): void;
  47146. /**
  47147. * Dispose only the render target textures and post process.
  47148. */
  47149. private _disposeTextureAndPostProcesses;
  47150. /**
  47151. * Dispose the highlight layer and free resources.
  47152. */
  47153. dispose(): void;
  47154. /**
  47155. * Gets the class name of the effect layer
  47156. * @returns the string with the class name of the effect layer
  47157. */
  47158. getClassName(): string;
  47159. /**
  47160. * Creates an effect layer from parsed effect layer data
  47161. * @param parsedEffectLayer defines effect layer data
  47162. * @param scene defines the current scene
  47163. * @param rootUrl defines the root URL containing the effect layer information
  47164. * @returns a parsed effect Layer
  47165. */
  47166. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  47167. }
  47168. }
  47169. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  47170. import { Scene } from "babylonjs/scene";
  47171. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47172. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47173. import { AbstractScene } from "babylonjs/abstractScene";
  47174. module "babylonjs/abstractScene" {
  47175. interface AbstractScene {
  47176. /**
  47177. * The list of effect layers (highlights/glow) added to the scene
  47178. * @see http://doc.babylonjs.com/how_to/highlight_layer
  47179. * @see http://doc.babylonjs.com/how_to/glow_layer
  47180. */
  47181. effectLayers: Array<EffectLayer>;
  47182. /**
  47183. * Removes the given effect layer from this scene.
  47184. * @param toRemove defines the effect layer to remove
  47185. * @returns the index of the removed effect layer
  47186. */
  47187. removeEffectLayer(toRemove: EffectLayer): number;
  47188. /**
  47189. * Adds the given effect layer to this scene
  47190. * @param newEffectLayer defines the effect layer to add
  47191. */
  47192. addEffectLayer(newEffectLayer: EffectLayer): void;
  47193. }
  47194. }
  47195. /**
  47196. * Defines the layer scene component responsible to manage any effect layers
  47197. * in a given scene.
  47198. */
  47199. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  47200. /**
  47201. * The component name helpfull to identify the component in the list of scene components.
  47202. */
  47203. readonly name: string;
  47204. /**
  47205. * The scene the component belongs to.
  47206. */
  47207. scene: Scene;
  47208. private _engine;
  47209. private _renderEffects;
  47210. private _needStencil;
  47211. private _previousStencilState;
  47212. /**
  47213. * Creates a new instance of the component for the given scene
  47214. * @param scene Defines the scene to register the component in
  47215. */
  47216. constructor(scene: Scene);
  47217. /**
  47218. * Registers the component in a given scene
  47219. */
  47220. register(): void;
  47221. /**
  47222. * Rebuilds the elements related to this component in case of
  47223. * context lost for instance.
  47224. */
  47225. rebuild(): void;
  47226. /**
  47227. * Serializes the component data to the specified json object
  47228. * @param serializationObject The object to serialize to
  47229. */
  47230. serialize(serializationObject: any): void;
  47231. /**
  47232. * Adds all the element from the container to the scene
  47233. * @param container the container holding the elements
  47234. */
  47235. addFromContainer(container: AbstractScene): void;
  47236. /**
  47237. * Removes all the elements in the container from the scene
  47238. * @param container contains the elements to remove
  47239. */
  47240. removeFromContainer(container: AbstractScene): void;
  47241. /**
  47242. * Disposes the component and the associated ressources.
  47243. */
  47244. dispose(): void;
  47245. private _isReadyForMesh;
  47246. private _renderMainTexture;
  47247. private _setStencil;
  47248. private _setStencilBack;
  47249. private _draw;
  47250. private _drawCamera;
  47251. private _drawRenderingGroup;
  47252. }
  47253. }
  47254. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  47255. /** @hidden */
  47256. export var glowMapMergePixelShader: {
  47257. name: string;
  47258. shader: string;
  47259. };
  47260. }
  47261. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  47262. /** @hidden */
  47263. export var glowMapMergeVertexShader: {
  47264. name: string;
  47265. shader: string;
  47266. };
  47267. }
  47268. declare module "babylonjs/Layers/glowLayer" {
  47269. import { Nullable } from "babylonjs/types";
  47270. import { Camera } from "babylonjs/Cameras/camera";
  47271. import { Scene } from "babylonjs/scene";
  47272. import { Color4 } from "babylonjs/Maths/math";
  47273. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47274. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47275. import { Mesh } from "babylonjs/Meshes/mesh";
  47276. import { Texture } from "babylonjs/Materials/Textures/texture";
  47277. import { Effect } from "babylonjs/Materials/effect";
  47278. import { Material } from "babylonjs/Materials/material";
  47279. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47280. import "babylonjs/Shaders/glowMapMerge.fragment";
  47281. import "babylonjs/Shaders/glowMapMerge.vertex";
  47282. import "babylonjs/Layers/effectLayerSceneComponent";
  47283. module "babylonjs/abstractScene" {
  47284. interface AbstractScene {
  47285. /**
  47286. * Return a the first highlight layer of the scene with a given name.
  47287. * @param name The name of the highlight layer to look for.
  47288. * @return The highlight layer if found otherwise null.
  47289. */
  47290. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  47291. }
  47292. }
  47293. /**
  47294. * Glow layer options. This helps customizing the behaviour
  47295. * of the glow layer.
  47296. */
  47297. export interface IGlowLayerOptions {
  47298. /**
  47299. * Multiplication factor apply to the canvas size to compute the render target size
  47300. * used to generated the glowing objects (the smaller the faster).
  47301. */
  47302. mainTextureRatio: number;
  47303. /**
  47304. * Enforces a fixed size texture to ensure resize independant blur.
  47305. */
  47306. mainTextureFixedSize?: number;
  47307. /**
  47308. * How big is the kernel of the blur texture.
  47309. */
  47310. blurKernelSize: number;
  47311. /**
  47312. * The camera attached to the layer.
  47313. */
  47314. camera: Nullable<Camera>;
  47315. /**
  47316. * Enable MSAA by chosing the number of samples.
  47317. */
  47318. mainTextureSamples?: number;
  47319. /**
  47320. * The rendering group to draw the layer in.
  47321. */
  47322. renderingGroupId: number;
  47323. }
  47324. /**
  47325. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  47326. *
  47327. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47328. * glowy meshes to your scene.
  47329. *
  47330. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  47331. */
  47332. export class GlowLayer extends EffectLayer {
  47333. /**
  47334. * Effect Name of the layer.
  47335. */
  47336. static readonly EffectName: string;
  47337. /**
  47338. * The default blur kernel size used for the glow.
  47339. */
  47340. static DefaultBlurKernelSize: number;
  47341. /**
  47342. * The default texture size ratio used for the glow.
  47343. */
  47344. static DefaultTextureRatio: number;
  47345. /**
  47346. * Sets the kernel size of the blur.
  47347. */
  47348. /**
  47349. * Gets the kernel size of the blur.
  47350. */
  47351. blurKernelSize: number;
  47352. /**
  47353. * Sets the glow intensity.
  47354. */
  47355. /**
  47356. * Gets the glow intensity.
  47357. */
  47358. intensity: number;
  47359. private _options;
  47360. private _intensity;
  47361. private _horizontalBlurPostprocess1;
  47362. private _verticalBlurPostprocess1;
  47363. private _horizontalBlurPostprocess2;
  47364. private _verticalBlurPostprocess2;
  47365. private _blurTexture1;
  47366. private _blurTexture2;
  47367. private _postProcesses1;
  47368. private _postProcesses2;
  47369. private _includedOnlyMeshes;
  47370. private _excludedMeshes;
  47371. /**
  47372. * Callback used to let the user override the color selection on a per mesh basis
  47373. */
  47374. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  47375. /**
  47376. * Callback used to let the user override the texture selection on a per mesh basis
  47377. */
  47378. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  47379. /**
  47380. * Instantiates a new glow Layer and references it to the scene.
  47381. * @param name The name of the layer
  47382. * @param scene The scene to use the layer in
  47383. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  47384. */
  47385. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  47386. /**
  47387. * Get the effect name of the layer.
  47388. * @return The effect name
  47389. */
  47390. getEffectName(): string;
  47391. /**
  47392. * Create the merge effect. This is the shader use to blit the information back
  47393. * to the main canvas at the end of the scene rendering.
  47394. */
  47395. protected _createMergeEffect(): Effect;
  47396. /**
  47397. * Creates the render target textures and post processes used in the glow layer.
  47398. */
  47399. protected _createTextureAndPostProcesses(): void;
  47400. /**
  47401. * Checks for the readiness of the element composing the layer.
  47402. * @param subMesh the mesh to check for
  47403. * @param useInstances specify wether or not to use instances to render the mesh
  47404. * @param emissiveTexture the associated emissive texture used to generate the glow
  47405. * @return true if ready otherwise, false
  47406. */
  47407. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47408. /**
  47409. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47410. */
  47411. needStencil(): boolean;
  47412. /**
  47413. * Returns true if the mesh can be rendered, otherwise false.
  47414. * @param mesh The mesh to render
  47415. * @param material The material used on the mesh
  47416. * @returns true if it can be rendered otherwise false
  47417. */
  47418. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47419. /**
  47420. * Implementation specific of rendering the generating effect on the main canvas.
  47421. * @param effect The effect used to render through
  47422. */
  47423. protected _internalRender(effect: Effect): void;
  47424. /**
  47425. * Sets the required values for both the emissive texture and and the main color.
  47426. */
  47427. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47428. /**
  47429. * Returns true if the mesh should render, otherwise false.
  47430. * @param mesh The mesh to render
  47431. * @returns true if it should render otherwise false
  47432. */
  47433. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47434. /**
  47435. * Adds specific effects defines.
  47436. * @param defines The defines to add specifics to.
  47437. */
  47438. protected _addCustomEffectDefines(defines: string[]): void;
  47439. /**
  47440. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  47441. * @param mesh The mesh to exclude from the glow layer
  47442. */
  47443. addExcludedMesh(mesh: Mesh): void;
  47444. /**
  47445. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  47446. * @param mesh The mesh to remove
  47447. */
  47448. removeExcludedMesh(mesh: Mesh): void;
  47449. /**
  47450. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  47451. * @param mesh The mesh to include in the glow layer
  47452. */
  47453. addIncludedOnlyMesh(mesh: Mesh): void;
  47454. /**
  47455. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  47456. * @param mesh The mesh to remove
  47457. */
  47458. removeIncludedOnlyMesh(mesh: Mesh): void;
  47459. /**
  47460. * Determine if a given mesh will be used in the glow layer
  47461. * @param mesh The mesh to test
  47462. * @returns true if the mesh will be highlighted by the current glow layer
  47463. */
  47464. hasMesh(mesh: AbstractMesh): boolean;
  47465. /**
  47466. * Free any resources and references associated to a mesh.
  47467. * Internal use
  47468. * @param mesh The mesh to free.
  47469. * @hidden
  47470. */
  47471. _disposeMesh(mesh: Mesh): void;
  47472. /**
  47473. * Gets the class name of the effect layer
  47474. * @returns the string with the class name of the effect layer
  47475. */
  47476. getClassName(): string;
  47477. /**
  47478. * Serializes this glow layer
  47479. * @returns a serialized glow layer object
  47480. */
  47481. serialize(): any;
  47482. /**
  47483. * Creates a Glow Layer from parsed glow layer data
  47484. * @param parsedGlowLayer defines glow layer data
  47485. * @param scene defines the current scene
  47486. * @param rootUrl defines the root URL containing the glow layer information
  47487. * @returns a parsed Glow Layer
  47488. */
  47489. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  47490. }
  47491. }
  47492. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  47493. /** @hidden */
  47494. export var glowBlurPostProcessPixelShader: {
  47495. name: string;
  47496. shader: string;
  47497. };
  47498. }
  47499. declare module "babylonjs/Layers/highlightLayer" {
  47500. import { Observable } from "babylonjs/Misc/observable";
  47501. import { Nullable } from "babylonjs/types";
  47502. import { Camera } from "babylonjs/Cameras/camera";
  47503. import { Scene } from "babylonjs/scene";
  47504. import { Color3, Color4 } from "babylonjs/Maths/math";
  47505. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47506. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47507. import { Mesh } from "babylonjs/Meshes/mesh";
  47508. import { Effect } from "babylonjs/Materials/effect";
  47509. import { Material } from "babylonjs/Materials/material";
  47510. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47511. import "babylonjs/Shaders/glowMapMerge.fragment";
  47512. import "babylonjs/Shaders/glowMapMerge.vertex";
  47513. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  47514. module "babylonjs/abstractScene" {
  47515. interface AbstractScene {
  47516. /**
  47517. * Return a the first highlight layer of the scene with a given name.
  47518. * @param name The name of the highlight layer to look for.
  47519. * @return The highlight layer if found otherwise null.
  47520. */
  47521. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  47522. }
  47523. }
  47524. /**
  47525. * Highlight layer options. This helps customizing the behaviour
  47526. * of the highlight layer.
  47527. */
  47528. export interface IHighlightLayerOptions {
  47529. /**
  47530. * Multiplication factor apply to the canvas size to compute the render target size
  47531. * used to generated the glowing objects (the smaller the faster).
  47532. */
  47533. mainTextureRatio: number;
  47534. /**
  47535. * Enforces a fixed size texture to ensure resize independant blur.
  47536. */
  47537. mainTextureFixedSize?: number;
  47538. /**
  47539. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  47540. * of the picture to blur (the smaller the faster).
  47541. */
  47542. blurTextureSizeRatio: number;
  47543. /**
  47544. * How big in texel of the blur texture is the vertical blur.
  47545. */
  47546. blurVerticalSize: number;
  47547. /**
  47548. * How big in texel of the blur texture is the horizontal blur.
  47549. */
  47550. blurHorizontalSize: number;
  47551. /**
  47552. * Alpha blending mode used to apply the blur. Default is combine.
  47553. */
  47554. alphaBlendingMode: number;
  47555. /**
  47556. * The camera attached to the layer.
  47557. */
  47558. camera: Nullable<Camera>;
  47559. /**
  47560. * Should we display highlight as a solid stroke?
  47561. */
  47562. isStroke?: boolean;
  47563. /**
  47564. * The rendering group to draw the layer in.
  47565. */
  47566. renderingGroupId: number;
  47567. }
  47568. /**
  47569. * The highlight layer Helps adding a glow effect around a mesh.
  47570. *
  47571. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47572. * glowy meshes to your scene.
  47573. *
  47574. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  47575. */
  47576. export class HighlightLayer extends EffectLayer {
  47577. name: string;
  47578. /**
  47579. * Effect Name of the highlight layer.
  47580. */
  47581. static readonly EffectName: string;
  47582. /**
  47583. * The neutral color used during the preparation of the glow effect.
  47584. * This is black by default as the blend operation is a blend operation.
  47585. */
  47586. static NeutralColor: Color4;
  47587. /**
  47588. * Stencil value used for glowing meshes.
  47589. */
  47590. static GlowingMeshStencilReference: number;
  47591. /**
  47592. * Stencil value used for the other meshes in the scene.
  47593. */
  47594. static NormalMeshStencilReference: number;
  47595. /**
  47596. * Specifies whether or not the inner glow is ACTIVE in the layer.
  47597. */
  47598. innerGlow: boolean;
  47599. /**
  47600. * Specifies whether or not the outer glow is ACTIVE in the layer.
  47601. */
  47602. outerGlow: boolean;
  47603. /**
  47604. * Specifies the horizontal size of the blur.
  47605. */
  47606. /**
  47607. * Gets the horizontal size of the blur.
  47608. */
  47609. blurHorizontalSize: number;
  47610. /**
  47611. * Specifies the vertical size of the blur.
  47612. */
  47613. /**
  47614. * Gets the vertical size of the blur.
  47615. */
  47616. blurVerticalSize: number;
  47617. /**
  47618. * An event triggered when the highlight layer is being blurred.
  47619. */
  47620. onBeforeBlurObservable: Observable<HighlightLayer>;
  47621. /**
  47622. * An event triggered when the highlight layer has been blurred.
  47623. */
  47624. onAfterBlurObservable: Observable<HighlightLayer>;
  47625. private _instanceGlowingMeshStencilReference;
  47626. private _options;
  47627. private _downSamplePostprocess;
  47628. private _horizontalBlurPostprocess;
  47629. private _verticalBlurPostprocess;
  47630. private _blurTexture;
  47631. private _meshes;
  47632. private _excludedMeshes;
  47633. /**
  47634. * Instantiates a new highlight Layer and references it to the scene..
  47635. * @param name The name of the layer
  47636. * @param scene The scene to use the layer in
  47637. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  47638. */
  47639. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  47640. /**
  47641. * Get the effect name of the layer.
  47642. * @return The effect name
  47643. */
  47644. getEffectName(): string;
  47645. /**
  47646. * Create the merge effect. This is the shader use to blit the information back
  47647. * to the main canvas at the end of the scene rendering.
  47648. */
  47649. protected _createMergeEffect(): Effect;
  47650. /**
  47651. * Creates the render target textures and post processes used in the highlight layer.
  47652. */
  47653. protected _createTextureAndPostProcesses(): void;
  47654. /**
  47655. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47656. */
  47657. needStencil(): boolean;
  47658. /**
  47659. * Checks for the readiness of the element composing the layer.
  47660. * @param subMesh the mesh to check for
  47661. * @param useInstances specify wether or not to use instances to render the mesh
  47662. * @param emissiveTexture the associated emissive texture used to generate the glow
  47663. * @return true if ready otherwise, false
  47664. */
  47665. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47666. /**
  47667. * Implementation specific of rendering the generating effect on the main canvas.
  47668. * @param effect The effect used to render through
  47669. */
  47670. protected _internalRender(effect: Effect): void;
  47671. /**
  47672. * Returns true if the layer contains information to display, otherwise false.
  47673. */
  47674. shouldRender(): boolean;
  47675. /**
  47676. * Returns true if the mesh should render, otherwise false.
  47677. * @param mesh The mesh to render
  47678. * @returns true if it should render otherwise false
  47679. */
  47680. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47681. /**
  47682. * Sets the required values for both the emissive texture and and the main color.
  47683. */
  47684. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47685. /**
  47686. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  47687. * @param mesh The mesh to exclude from the highlight layer
  47688. */
  47689. addExcludedMesh(mesh: Mesh): void;
  47690. /**
  47691. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  47692. * @param mesh The mesh to highlight
  47693. */
  47694. removeExcludedMesh(mesh: Mesh): void;
  47695. /**
  47696. * Determine if a given mesh will be highlighted by the current HighlightLayer
  47697. * @param mesh mesh to test
  47698. * @returns true if the mesh will be highlighted by the current HighlightLayer
  47699. */
  47700. hasMesh(mesh: AbstractMesh): boolean;
  47701. /**
  47702. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  47703. * @param mesh The mesh to highlight
  47704. * @param color The color of the highlight
  47705. * @param glowEmissiveOnly Extract the glow from the emissive texture
  47706. */
  47707. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  47708. /**
  47709. * Remove a mesh from the highlight layer in order to make it stop glowing.
  47710. * @param mesh The mesh to highlight
  47711. */
  47712. removeMesh(mesh: Mesh): void;
  47713. /**
  47714. * Force the stencil to the normal expected value for none glowing parts
  47715. */
  47716. private _defaultStencilReference;
  47717. /**
  47718. * Free any resources and references associated to a mesh.
  47719. * Internal use
  47720. * @param mesh The mesh to free.
  47721. * @hidden
  47722. */
  47723. _disposeMesh(mesh: Mesh): void;
  47724. /**
  47725. * Dispose the highlight layer and free resources.
  47726. */
  47727. dispose(): void;
  47728. /**
  47729. * Gets the class name of the effect layer
  47730. * @returns the string with the class name of the effect layer
  47731. */
  47732. getClassName(): string;
  47733. /**
  47734. * Serializes this Highlight layer
  47735. * @returns a serialized Highlight layer object
  47736. */
  47737. serialize(): any;
  47738. /**
  47739. * Creates a Highlight layer from parsed Highlight layer data
  47740. * @param parsedHightlightLayer defines the Highlight layer data
  47741. * @param scene defines the current scene
  47742. * @param rootUrl defines the root URL containing the Highlight layer information
  47743. * @returns a parsed Highlight layer
  47744. */
  47745. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  47746. }
  47747. }
  47748. declare module "babylonjs/Layers/index" {
  47749. export * from "babylonjs/Layers/effectLayer";
  47750. export * from "babylonjs/Layers/effectLayerSceneComponent";
  47751. export * from "babylonjs/Layers/glowLayer";
  47752. export * from "babylonjs/Layers/highlightLayer";
  47753. export * from "babylonjs/Layers/layer";
  47754. export * from "babylonjs/Layers/layerSceneComponent";
  47755. }
  47756. declare module "babylonjs/Shaders/lensFlare.fragment" {
  47757. /** @hidden */
  47758. export var lensFlarePixelShader: {
  47759. name: string;
  47760. shader: string;
  47761. };
  47762. }
  47763. declare module "babylonjs/Shaders/lensFlare.vertex" {
  47764. /** @hidden */
  47765. export var lensFlareVertexShader: {
  47766. name: string;
  47767. shader: string;
  47768. };
  47769. }
  47770. declare module "babylonjs/LensFlares/lensFlareSystem" {
  47771. import { Scene } from "babylonjs/scene";
  47772. import { Vector3, Viewport } from "babylonjs/Maths/math";
  47773. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47774. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  47775. import "babylonjs/Shaders/lensFlare.fragment";
  47776. import "babylonjs/Shaders/lensFlare.vertex";
  47777. /**
  47778. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47779. * It is usually composed of several `lensFlare`.
  47780. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47781. */
  47782. export class LensFlareSystem {
  47783. /**
  47784. * Define the name of the lens flare system
  47785. */
  47786. name: string;
  47787. /**
  47788. * List of lens flares used in this system.
  47789. */
  47790. lensFlares: LensFlare[];
  47791. /**
  47792. * Define a limit from the border the lens flare can be visible.
  47793. */
  47794. borderLimit: number;
  47795. /**
  47796. * Define a viewport border we do not want to see the lens flare in.
  47797. */
  47798. viewportBorder: number;
  47799. /**
  47800. * Define a predicate which could limit the list of meshes able to occlude the effect.
  47801. */
  47802. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  47803. /**
  47804. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  47805. */
  47806. layerMask: number;
  47807. /**
  47808. * Define the id of the lens flare system in the scene.
  47809. * (equal to name by default)
  47810. */
  47811. id: string;
  47812. private _scene;
  47813. private _emitter;
  47814. private _vertexBuffers;
  47815. private _indexBuffer;
  47816. private _effect;
  47817. private _positionX;
  47818. private _positionY;
  47819. private _isEnabled;
  47820. /** @hidden */
  47821. static _SceneComponentInitialization: (scene: Scene) => void;
  47822. /**
  47823. * Instantiates a lens flare system.
  47824. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47825. * It is usually composed of several `lensFlare`.
  47826. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47827. * @param name Define the name of the lens flare system in the scene
  47828. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  47829. * @param scene Define the scene the lens flare system belongs to
  47830. */
  47831. constructor(
  47832. /**
  47833. * Define the name of the lens flare system
  47834. */
  47835. name: string, emitter: any, scene: Scene);
  47836. /**
  47837. * Define if the lens flare system is enabled.
  47838. */
  47839. isEnabled: boolean;
  47840. /**
  47841. * Get the scene the effects belongs to.
  47842. * @returns the scene holding the lens flare system
  47843. */
  47844. getScene(): Scene;
  47845. /**
  47846. * Get the emitter of the lens flare system.
  47847. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47848. * @returns the emitter of the lens flare system
  47849. */
  47850. getEmitter(): any;
  47851. /**
  47852. * Set the emitter of the lens flare system.
  47853. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47854. * @param newEmitter Define the new emitter of the system
  47855. */
  47856. setEmitter(newEmitter: any): void;
  47857. /**
  47858. * Get the lens flare system emitter position.
  47859. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  47860. * @returns the position
  47861. */
  47862. getEmitterPosition(): Vector3;
  47863. /**
  47864. * @hidden
  47865. */
  47866. computeEffectivePosition(globalViewport: Viewport): boolean;
  47867. /** @hidden */
  47868. _isVisible(): boolean;
  47869. /**
  47870. * @hidden
  47871. */
  47872. render(): boolean;
  47873. /**
  47874. * Dispose and release the lens flare with its associated resources.
  47875. */
  47876. dispose(): void;
  47877. /**
  47878. * Parse a lens flare system from a JSON repressentation
  47879. * @param parsedLensFlareSystem Define the JSON to parse
  47880. * @param scene Define the scene the parsed system should be instantiated in
  47881. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  47882. * @returns the parsed system
  47883. */
  47884. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  47885. /**
  47886. * Serialize the current Lens Flare System into a JSON representation.
  47887. * @returns the serialized JSON
  47888. */
  47889. serialize(): any;
  47890. }
  47891. }
  47892. declare module "babylonjs/LensFlares/lensFlare" {
  47893. import { Nullable } from "babylonjs/types";
  47894. import { Color3 } from "babylonjs/Maths/math";
  47895. import { Texture } from "babylonjs/Materials/Textures/texture";
  47896. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  47897. /**
  47898. * This represents one of the lens effect in a `lensFlareSystem`.
  47899. * It controls one of the indiviual texture used in the effect.
  47900. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47901. */
  47902. export class LensFlare {
  47903. /**
  47904. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47905. */
  47906. size: number;
  47907. /**
  47908. * 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.
  47909. */
  47910. position: number;
  47911. /**
  47912. * Define the lens color.
  47913. */
  47914. color: Color3;
  47915. /**
  47916. * Define the lens texture.
  47917. */
  47918. texture: Nullable<Texture>;
  47919. /**
  47920. * Define the alpha mode to render this particular lens.
  47921. */
  47922. alphaMode: number;
  47923. private _system;
  47924. /**
  47925. * Creates a new Lens Flare.
  47926. * This represents one of the lens effect in a `lensFlareSystem`.
  47927. * It controls one of the indiviual texture used in the effect.
  47928. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47929. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  47930. * @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.
  47931. * @param color Define the lens color
  47932. * @param imgUrl Define the lens texture url
  47933. * @param system Define the `lensFlareSystem` this flare is part of
  47934. * @returns The newly created Lens Flare
  47935. */
  47936. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  47937. /**
  47938. * Instantiates a new Lens Flare.
  47939. * This represents one of the lens effect in a `lensFlareSystem`.
  47940. * It controls one of the indiviual texture used in the effect.
  47941. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47942. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  47943. * @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.
  47944. * @param color Define the lens color
  47945. * @param imgUrl Define the lens texture url
  47946. * @param system Define the `lensFlareSystem` this flare is part of
  47947. */
  47948. constructor(
  47949. /**
  47950. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47951. */
  47952. size: number,
  47953. /**
  47954. * 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.
  47955. */
  47956. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  47957. /**
  47958. * Dispose and release the lens flare with its associated resources.
  47959. */
  47960. dispose(): void;
  47961. }
  47962. }
  47963. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  47964. import { Nullable } from "babylonjs/types";
  47965. import { Scene } from "babylonjs/scene";
  47966. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47967. import { AbstractScene } from "babylonjs/abstractScene";
  47968. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  47969. module "babylonjs/abstractScene" {
  47970. interface AbstractScene {
  47971. /**
  47972. * The list of lens flare system added to the scene
  47973. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47974. */
  47975. lensFlareSystems: Array<LensFlareSystem>;
  47976. /**
  47977. * Removes the given lens flare system from this scene.
  47978. * @param toRemove The lens flare system to remove
  47979. * @returns The index of the removed lens flare system
  47980. */
  47981. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  47982. /**
  47983. * Adds the given lens flare system to this scene
  47984. * @param newLensFlareSystem The lens flare system to add
  47985. */
  47986. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  47987. /**
  47988. * Gets a lens flare system using its name
  47989. * @param name defines the name to look for
  47990. * @returns the lens flare system or null if not found
  47991. */
  47992. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  47993. /**
  47994. * Gets a lens flare system using its id
  47995. * @param id defines the id to look for
  47996. * @returns the lens flare system or null if not found
  47997. */
  47998. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  47999. }
  48000. }
  48001. /**
  48002. * Defines the lens flare scene component responsible to manage any lens flares
  48003. * in a given scene.
  48004. */
  48005. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  48006. /**
  48007. * The component name helpfull to identify the component in the list of scene components.
  48008. */
  48009. readonly name: string;
  48010. /**
  48011. * The scene the component belongs to.
  48012. */
  48013. scene: Scene;
  48014. /**
  48015. * Creates a new instance of the component for the given scene
  48016. * @param scene Defines the scene to register the component in
  48017. */
  48018. constructor(scene: Scene);
  48019. /**
  48020. * Registers the component in a given scene
  48021. */
  48022. register(): void;
  48023. /**
  48024. * Rebuilds the elements related to this component in case of
  48025. * context lost for instance.
  48026. */
  48027. rebuild(): void;
  48028. /**
  48029. * Adds all the element from the container to the scene
  48030. * @param container the container holding the elements
  48031. */
  48032. addFromContainer(container: AbstractScene): void;
  48033. /**
  48034. * Removes all the elements in the container from the scene
  48035. * @param container contains the elements to remove
  48036. */
  48037. removeFromContainer(container: AbstractScene): void;
  48038. /**
  48039. * Serializes the component data to the specified json object
  48040. * @param serializationObject The object to serialize to
  48041. */
  48042. serialize(serializationObject: any): void;
  48043. /**
  48044. * Disposes the component and the associated ressources.
  48045. */
  48046. dispose(): void;
  48047. private _draw;
  48048. }
  48049. }
  48050. declare module "babylonjs/LensFlares/index" {
  48051. export * from "babylonjs/LensFlares/lensFlare";
  48052. export * from "babylonjs/LensFlares/lensFlareSystem";
  48053. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  48054. }
  48055. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  48056. import { Scene } from "babylonjs/scene";
  48057. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  48058. import { AbstractScene } from "babylonjs/abstractScene";
  48059. /**
  48060. * Defines the shadow generator component responsible to manage any shadow generators
  48061. * in a given scene.
  48062. */
  48063. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  48064. /**
  48065. * The component name helpfull to identify the component in the list of scene components.
  48066. */
  48067. readonly name: string;
  48068. /**
  48069. * The scene the component belongs to.
  48070. */
  48071. scene: Scene;
  48072. /**
  48073. * Creates a new instance of the component for the given scene
  48074. * @param scene Defines the scene to register the component in
  48075. */
  48076. constructor(scene: Scene);
  48077. /**
  48078. * Registers the component in a given scene
  48079. */
  48080. register(): void;
  48081. /**
  48082. * Rebuilds the elements related to this component in case of
  48083. * context lost for instance.
  48084. */
  48085. rebuild(): void;
  48086. /**
  48087. * Serializes the component data to the specified json object
  48088. * @param serializationObject The object to serialize to
  48089. */
  48090. serialize(serializationObject: any): void;
  48091. /**
  48092. * Adds all the element from the container to the scene
  48093. * @param container the container holding the elements
  48094. */
  48095. addFromContainer(container: AbstractScene): void;
  48096. /**
  48097. * Removes all the elements in the container from the scene
  48098. * @param container contains the elements to remove
  48099. */
  48100. removeFromContainer(container: AbstractScene): void;
  48101. /**
  48102. * Rebuilds the elements related to this component in case of
  48103. * context lost for instance.
  48104. */
  48105. dispose(): void;
  48106. private _gatherRenderTargets;
  48107. }
  48108. }
  48109. declare module "babylonjs/Lights/Shadows/index" {
  48110. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  48111. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  48112. }
  48113. declare module "babylonjs/Lights/directionalLight" {
  48114. import { Camera } from "babylonjs/Cameras/camera";
  48115. import { Scene } from "babylonjs/scene";
  48116. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48117. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48118. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48119. import { Effect } from "babylonjs/Materials/effect";
  48120. /**
  48121. * A directional light is defined by a direction (what a surprise!).
  48122. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48123. * 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.
  48124. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48125. */
  48126. export class DirectionalLight extends ShadowLight {
  48127. private _shadowFrustumSize;
  48128. /**
  48129. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48130. */
  48131. /**
  48132. * Specifies a fix frustum size for the shadow generation.
  48133. */
  48134. shadowFrustumSize: number;
  48135. private _shadowOrthoScale;
  48136. /**
  48137. * Gets the shadow projection scale against the optimal computed one.
  48138. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48139. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48140. */
  48141. /**
  48142. * Sets the shadow projection scale against the optimal computed one.
  48143. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48144. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48145. */
  48146. shadowOrthoScale: number;
  48147. /**
  48148. * Automatically compute the projection matrix to best fit (including all the casters)
  48149. * on each frame.
  48150. */
  48151. autoUpdateExtends: boolean;
  48152. private _orthoLeft;
  48153. private _orthoRight;
  48154. private _orthoTop;
  48155. private _orthoBottom;
  48156. /**
  48157. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48158. * The directional light is emitted from everywhere in the given direction.
  48159. * It can cast shadows.
  48160. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48161. * @param name The friendly name of the light
  48162. * @param direction The direction of the light
  48163. * @param scene The scene the light belongs to
  48164. */
  48165. constructor(name: string, direction: Vector3, scene: Scene);
  48166. /**
  48167. * Returns the string "DirectionalLight".
  48168. * @return The class name
  48169. */
  48170. getClassName(): string;
  48171. /**
  48172. * Returns the integer 1.
  48173. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48174. */
  48175. getTypeID(): number;
  48176. /**
  48177. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48178. * Returns the DirectionalLight Shadow projection matrix.
  48179. */
  48180. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48181. /**
  48182. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48183. * Returns the DirectionalLight Shadow projection matrix.
  48184. */
  48185. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48186. /**
  48187. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48188. * Returns the DirectionalLight Shadow projection matrix.
  48189. */
  48190. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48191. protected _buildUniformLayout(): void;
  48192. /**
  48193. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48194. * @param effect The effect to update
  48195. * @param lightIndex The index of the light in the effect to update
  48196. * @returns The directional light
  48197. */
  48198. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48199. /**
  48200. * Gets the minZ used for shadow according to both the scene and the light.
  48201. *
  48202. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48203. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48204. * @param activeCamera The camera we are returning the min for
  48205. * @returns the depth min z
  48206. */
  48207. getDepthMinZ(activeCamera: Camera): number;
  48208. /**
  48209. * Gets the maxZ used for shadow according to both the scene and the light.
  48210. *
  48211. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48212. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48213. * @param activeCamera The camera we are returning the max for
  48214. * @returns the depth max z
  48215. */
  48216. getDepthMaxZ(activeCamera: Camera): number;
  48217. /**
  48218. * Prepares the list of defines specific to the light type.
  48219. * @param defines the list of defines
  48220. * @param lightIndex defines the index of the light for the effect
  48221. */
  48222. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48223. }
  48224. }
  48225. declare module "babylonjs/Lights/pointLight" {
  48226. import { Scene } from "babylonjs/scene";
  48227. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48228. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48229. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48230. import { Effect } from "babylonjs/Materials/effect";
  48231. /**
  48232. * A point light is a light defined by an unique point in world space.
  48233. * The light is emitted in every direction from this point.
  48234. * A good example of a point light is a standard light bulb.
  48235. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48236. */
  48237. export class PointLight extends ShadowLight {
  48238. private _shadowAngle;
  48239. /**
  48240. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48241. * This specifies what angle the shadow will use to be created.
  48242. *
  48243. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48244. */
  48245. /**
  48246. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48247. * This specifies what angle the shadow will use to be created.
  48248. *
  48249. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48250. */
  48251. shadowAngle: number;
  48252. /**
  48253. * Gets the direction if it has been set.
  48254. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48255. */
  48256. /**
  48257. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48258. */
  48259. direction: Vector3;
  48260. /**
  48261. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  48262. * A PointLight emits the light in every direction.
  48263. * It can cast shadows.
  48264. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  48265. * ```javascript
  48266. * var pointLight = new PointLight("pl", camera.position, scene);
  48267. * ```
  48268. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48269. * @param name The light friendly name
  48270. * @param position The position of the point light in the scene
  48271. * @param scene The scene the lights belongs to
  48272. */
  48273. constructor(name: string, position: Vector3, scene: Scene);
  48274. /**
  48275. * Returns the string "PointLight"
  48276. * @returns the class name
  48277. */
  48278. getClassName(): string;
  48279. /**
  48280. * Returns the integer 0.
  48281. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48282. */
  48283. getTypeID(): number;
  48284. /**
  48285. * Specifies wether or not the shadowmap should be a cube texture.
  48286. * @returns true if the shadowmap needs to be a cube texture.
  48287. */
  48288. needCube(): boolean;
  48289. /**
  48290. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  48291. * @param faceIndex The index of the face we are computed the direction to generate shadow
  48292. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  48293. */
  48294. getShadowDirection(faceIndex?: number): Vector3;
  48295. /**
  48296. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  48297. * - fov = PI / 2
  48298. * - aspect ratio : 1.0
  48299. * - z-near and far equal to the active camera minZ and maxZ.
  48300. * Returns the PointLight.
  48301. */
  48302. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48303. protected _buildUniformLayout(): void;
  48304. /**
  48305. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  48306. * @param effect The effect to update
  48307. * @param lightIndex The index of the light in the effect to update
  48308. * @returns The point light
  48309. */
  48310. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  48311. /**
  48312. * Prepares the list of defines specific to the light type.
  48313. * @param defines the list of defines
  48314. * @param lightIndex defines the index of the light for the effect
  48315. */
  48316. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48317. }
  48318. }
  48319. declare module "babylonjs/Lights/spotLight" {
  48320. import { Nullable } from "babylonjs/types";
  48321. import { Scene } from "babylonjs/scene";
  48322. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48323. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48324. import { Effect } from "babylonjs/Materials/effect";
  48325. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48326. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48327. /**
  48328. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48329. * These values define a cone of light starting from the position, emitting toward the direction.
  48330. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48331. * and the exponent defines the speed of the decay of the light with distance (reach).
  48332. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48333. */
  48334. export class SpotLight extends ShadowLight {
  48335. private _angle;
  48336. private _innerAngle;
  48337. private _cosHalfAngle;
  48338. private _lightAngleScale;
  48339. private _lightAngleOffset;
  48340. /**
  48341. * Gets the cone angle of the spot light in Radians.
  48342. */
  48343. /**
  48344. * Sets the cone angle of the spot light in Radians.
  48345. */
  48346. angle: number;
  48347. /**
  48348. * Only used in gltf falloff mode, this defines the angle where
  48349. * the directional falloff will start before cutting at angle which could be seen
  48350. * as outer angle.
  48351. */
  48352. /**
  48353. * Only used in gltf falloff mode, this defines the angle where
  48354. * the directional falloff will start before cutting at angle which could be seen
  48355. * as outer angle.
  48356. */
  48357. innerAngle: number;
  48358. private _shadowAngleScale;
  48359. /**
  48360. * Allows scaling the angle of the light for shadow generation only.
  48361. */
  48362. /**
  48363. * Allows scaling the angle of the light for shadow generation only.
  48364. */
  48365. shadowAngleScale: number;
  48366. /**
  48367. * The light decay speed with the distance from the emission spot.
  48368. */
  48369. exponent: number;
  48370. private _projectionTextureMatrix;
  48371. /**
  48372. * Allows reading the projecton texture
  48373. */
  48374. readonly projectionTextureMatrix: Matrix;
  48375. protected _projectionTextureLightNear: number;
  48376. /**
  48377. * Gets the near clip of the Spotlight for texture projection.
  48378. */
  48379. /**
  48380. * Sets the near clip of the Spotlight for texture projection.
  48381. */
  48382. projectionTextureLightNear: number;
  48383. protected _projectionTextureLightFar: number;
  48384. /**
  48385. * Gets the far clip of the Spotlight for texture projection.
  48386. */
  48387. /**
  48388. * Sets the far clip of the Spotlight for texture projection.
  48389. */
  48390. projectionTextureLightFar: number;
  48391. protected _projectionTextureUpDirection: Vector3;
  48392. /**
  48393. * Gets the Up vector of the Spotlight for texture projection.
  48394. */
  48395. /**
  48396. * Sets the Up vector of the Spotlight for texture projection.
  48397. */
  48398. projectionTextureUpDirection: Vector3;
  48399. private _projectionTexture;
  48400. /**
  48401. * Gets the projection texture of the light.
  48402. */
  48403. /**
  48404. * Sets the projection texture of the light.
  48405. */
  48406. projectionTexture: Nullable<BaseTexture>;
  48407. private _projectionTextureViewLightDirty;
  48408. private _projectionTextureProjectionLightDirty;
  48409. private _projectionTextureDirty;
  48410. private _projectionTextureViewTargetVector;
  48411. private _projectionTextureViewLightMatrix;
  48412. private _projectionTextureProjectionLightMatrix;
  48413. private _projectionTextureScalingMatrix;
  48414. /**
  48415. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48416. * It can cast shadows.
  48417. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48418. * @param name The light friendly name
  48419. * @param position The position of the spot light in the scene
  48420. * @param direction The direction of the light in the scene
  48421. * @param angle The cone angle of the light in Radians
  48422. * @param exponent The light decay speed with the distance from the emission spot
  48423. * @param scene The scene the lights belongs to
  48424. */
  48425. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48426. /**
  48427. * Returns the string "SpotLight".
  48428. * @returns the class name
  48429. */
  48430. getClassName(): string;
  48431. /**
  48432. * Returns the integer 2.
  48433. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48434. */
  48435. getTypeID(): number;
  48436. /**
  48437. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48438. */
  48439. protected _setDirection(value: Vector3): void;
  48440. /**
  48441. * Overrides the position setter to recompute the projection texture view light Matrix.
  48442. */
  48443. protected _setPosition(value: Vector3): void;
  48444. /**
  48445. * 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.
  48446. * Returns the SpotLight.
  48447. */
  48448. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48449. protected _computeProjectionTextureViewLightMatrix(): void;
  48450. protected _computeProjectionTextureProjectionLightMatrix(): void;
  48451. /**
  48452. * Main function for light texture projection matrix computing.
  48453. */
  48454. protected _computeProjectionTextureMatrix(): void;
  48455. protected _buildUniformLayout(): void;
  48456. private _computeAngleValues;
  48457. /**
  48458. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48459. * @param effect The effect to update
  48460. * @param lightIndex The index of the light in the effect to update
  48461. * @returns The spot light
  48462. */
  48463. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  48464. /**
  48465. * Disposes the light and the associated resources.
  48466. */
  48467. dispose(): void;
  48468. /**
  48469. * Prepares the list of defines specific to the light type.
  48470. * @param defines the list of defines
  48471. * @param lightIndex defines the index of the light for the effect
  48472. */
  48473. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48474. }
  48475. }
  48476. declare module "babylonjs/Lights/index" {
  48477. export * from "babylonjs/Lights/light";
  48478. export * from "babylonjs/Lights/shadowLight";
  48479. export * from "babylonjs/Lights/Shadows/index";
  48480. export * from "babylonjs/Lights/directionalLight";
  48481. export * from "babylonjs/Lights/hemisphericLight";
  48482. export * from "babylonjs/Lights/pointLight";
  48483. export * from "babylonjs/Lights/spotLight";
  48484. }
  48485. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  48486. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  48487. /**
  48488. * Header information of HDR texture files.
  48489. */
  48490. export interface HDRInfo {
  48491. /**
  48492. * The height of the texture in pixels.
  48493. */
  48494. height: number;
  48495. /**
  48496. * The width of the texture in pixels.
  48497. */
  48498. width: number;
  48499. /**
  48500. * The index of the beginning of the data in the binary file.
  48501. */
  48502. dataPosition: number;
  48503. }
  48504. /**
  48505. * This groups tools to convert HDR texture to native colors array.
  48506. */
  48507. export class HDRTools {
  48508. private static Ldexp;
  48509. private static Rgbe2float;
  48510. private static readStringLine;
  48511. /**
  48512. * Reads header information from an RGBE texture stored in a native array.
  48513. * More information on this format are available here:
  48514. * https://en.wikipedia.org/wiki/RGBE_image_format
  48515. *
  48516. * @param uint8array The binary file stored in native array.
  48517. * @return The header information.
  48518. */
  48519. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  48520. /**
  48521. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  48522. * This RGBE texture needs to store the information as a panorama.
  48523. *
  48524. * More information on this format are available here:
  48525. * https://en.wikipedia.org/wiki/RGBE_image_format
  48526. *
  48527. * @param buffer The binary file stored in an array buffer.
  48528. * @param size The expected size of the extracted cubemap.
  48529. * @return The Cube Map information.
  48530. */
  48531. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  48532. /**
  48533. * Returns the pixels data extracted from an RGBE texture.
  48534. * This pixels will be stored left to right up to down in the R G B order in one array.
  48535. *
  48536. * More information on this format are available here:
  48537. * https://en.wikipedia.org/wiki/RGBE_image_format
  48538. *
  48539. * @param uint8array The binary file stored in an array buffer.
  48540. * @param hdrInfo The header information of the file.
  48541. * @return The pixels data in RGB right to left up to down order.
  48542. */
  48543. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  48544. private static RGBE_ReadPixels_RLE;
  48545. }
  48546. }
  48547. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  48548. import { Nullable } from "babylonjs/types";
  48549. import { Scene } from "babylonjs/scene";
  48550. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48551. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48552. /**
  48553. * This represents a texture coming from an HDR input.
  48554. *
  48555. * The only supported format is currently panorama picture stored in RGBE format.
  48556. * Example of such files can be found on HDRLib: http://hdrlib.com/
  48557. */
  48558. export class HDRCubeTexture extends BaseTexture {
  48559. private static _facesMapping;
  48560. private _generateHarmonics;
  48561. private _noMipmap;
  48562. private _textureMatrix;
  48563. private _size;
  48564. private _onLoad;
  48565. private _onError;
  48566. /**
  48567. * The texture URL.
  48568. */
  48569. url: string;
  48570. /**
  48571. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  48572. */
  48573. coordinatesMode: number;
  48574. protected _isBlocking: boolean;
  48575. /**
  48576. * Sets wether or not the texture is blocking during loading.
  48577. */
  48578. /**
  48579. * Gets wether or not the texture is blocking during loading.
  48580. */
  48581. isBlocking: boolean;
  48582. protected _rotationY: number;
  48583. /**
  48584. * Sets texture matrix rotation angle around Y axis in radians.
  48585. */
  48586. /**
  48587. * Gets texture matrix rotation angle around Y axis radians.
  48588. */
  48589. rotationY: number;
  48590. /**
  48591. * Gets or sets the center of the bounding box associated with the cube texture
  48592. * It must define where the camera used to render the texture was set
  48593. */
  48594. boundingBoxPosition: Vector3;
  48595. private _boundingBoxSize;
  48596. /**
  48597. * Gets or sets the size of the bounding box associated with the cube texture
  48598. * When defined, the cubemap will switch to local mode
  48599. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  48600. * @example https://www.babylonjs-playground.com/#RNASML
  48601. */
  48602. boundingBoxSize: Vector3;
  48603. /**
  48604. * Instantiates an HDRTexture from the following parameters.
  48605. *
  48606. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  48607. * @param scene The scene the texture will be used in
  48608. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48609. * @param noMipmap Forces to not generate the mipmap if true
  48610. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  48611. * @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)
  48612. * @param reserved Reserved flag for internal use.
  48613. */
  48614. 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>);
  48615. /**
  48616. * Get the current class name of the texture useful for serialization or dynamic coding.
  48617. * @returns "HDRCubeTexture"
  48618. */
  48619. getClassName(): string;
  48620. /**
  48621. * Occurs when the file is raw .hdr file.
  48622. */
  48623. private loadTexture;
  48624. clone(): HDRCubeTexture;
  48625. delayLoad(): void;
  48626. /**
  48627. * Get the texture reflection matrix used to rotate/transform the reflection.
  48628. * @returns the reflection matrix
  48629. */
  48630. getReflectionTextureMatrix(): Matrix;
  48631. /**
  48632. * Set the texture reflection matrix used to rotate/transform the reflection.
  48633. * @param value Define the reflection matrix to set
  48634. */
  48635. setReflectionTextureMatrix(value: Matrix): void;
  48636. /**
  48637. * Parses a JSON representation of an HDR Texture in order to create the texture
  48638. * @param parsedTexture Define the JSON representation
  48639. * @param scene Define the scene the texture should be created in
  48640. * @param rootUrl Define the root url in case we need to load relative dependencies
  48641. * @returns the newly created texture after parsing
  48642. */
  48643. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  48644. serialize(): any;
  48645. }
  48646. }
  48647. declare module "babylonjs/Physics/physicsEngine" {
  48648. import { Nullable } from "babylonjs/types";
  48649. import { Vector3 } from "babylonjs/Maths/math";
  48650. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  48651. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  48652. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  48653. /**
  48654. * Class used to control physics engine
  48655. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  48656. */
  48657. export class PhysicsEngine implements IPhysicsEngine {
  48658. private _physicsPlugin;
  48659. /**
  48660. * Global value used to control the smallest number supported by the simulation
  48661. */
  48662. static Epsilon: number;
  48663. private _impostors;
  48664. private _joints;
  48665. /**
  48666. * Gets the gravity vector used by the simulation
  48667. */
  48668. gravity: Vector3;
  48669. /**
  48670. * Factory used to create the default physics plugin.
  48671. * @returns The default physics plugin
  48672. */
  48673. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  48674. /**
  48675. * Creates a new Physics Engine
  48676. * @param gravity defines the gravity vector used by the simulation
  48677. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  48678. */
  48679. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  48680. /**
  48681. * Sets the gravity vector used by the simulation
  48682. * @param gravity defines the gravity vector to use
  48683. */
  48684. setGravity(gravity: Vector3): void;
  48685. /**
  48686. * Set the time step of the physics engine.
  48687. * Default is 1/60.
  48688. * To slow it down, enter 1/600 for example.
  48689. * To speed it up, 1/30
  48690. * @param newTimeStep defines the new timestep to apply to this world.
  48691. */
  48692. setTimeStep(newTimeStep?: number): void;
  48693. /**
  48694. * Get the time step of the physics engine.
  48695. * @returns the current time step
  48696. */
  48697. getTimeStep(): number;
  48698. /**
  48699. * Release all resources
  48700. */
  48701. dispose(): void;
  48702. /**
  48703. * Gets the name of the current physics plugin
  48704. * @returns the name of the plugin
  48705. */
  48706. getPhysicsPluginName(): string;
  48707. /**
  48708. * Adding a new impostor for the impostor tracking.
  48709. * This will be done by the impostor itself.
  48710. * @param impostor the impostor to add
  48711. */
  48712. addImpostor(impostor: PhysicsImpostor): void;
  48713. /**
  48714. * Remove an impostor from the engine.
  48715. * This impostor and its mesh will not longer be updated by the physics engine.
  48716. * @param impostor the impostor to remove
  48717. */
  48718. removeImpostor(impostor: PhysicsImpostor): void;
  48719. /**
  48720. * Add a joint to the physics engine
  48721. * @param mainImpostor defines the main impostor to which the joint is added.
  48722. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  48723. * @param joint defines the joint that will connect both impostors.
  48724. */
  48725. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48726. /**
  48727. * Removes a joint from the simulation
  48728. * @param mainImpostor defines the impostor used with the joint
  48729. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  48730. * @param joint defines the joint to remove
  48731. */
  48732. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48733. /**
  48734. * Called by the scene. No need to call it.
  48735. * @param delta defines the timespam between frames
  48736. */
  48737. _step(delta: number): void;
  48738. /**
  48739. * Gets the current plugin used to run the simulation
  48740. * @returns current plugin
  48741. */
  48742. getPhysicsPlugin(): IPhysicsEnginePlugin;
  48743. /**
  48744. * Gets the list of physic impostors
  48745. * @returns an array of PhysicsImpostor
  48746. */
  48747. getImpostors(): Array<PhysicsImpostor>;
  48748. /**
  48749. * Gets the impostor for a physics enabled object
  48750. * @param object defines the object impersonated by the impostor
  48751. * @returns the PhysicsImpostor or null if not found
  48752. */
  48753. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  48754. /**
  48755. * Gets the impostor for a physics body object
  48756. * @param body defines physics body used by the impostor
  48757. * @returns the PhysicsImpostor or null if not found
  48758. */
  48759. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  48760. }
  48761. }
  48762. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  48763. import { Nullable } from "babylonjs/types";
  48764. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  48765. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48766. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  48767. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48768. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  48769. /** @hidden */
  48770. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  48771. private _useDeltaForWorldStep;
  48772. world: any;
  48773. name: string;
  48774. private _physicsMaterials;
  48775. private _fixedTimeStep;
  48776. BJSCANNON: any;
  48777. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  48778. setGravity(gravity: Vector3): void;
  48779. setTimeStep(timeStep: number): void;
  48780. getTimeStep(): number;
  48781. executeStep(delta: number): void;
  48782. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48783. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48784. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48785. private _processChildMeshes;
  48786. removePhysicsBody(impostor: PhysicsImpostor): void;
  48787. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48788. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48789. private _addMaterial;
  48790. private _checkWithEpsilon;
  48791. private _createShape;
  48792. private _createHeightmap;
  48793. private _minus90X;
  48794. private _plus90X;
  48795. private _tmpPosition;
  48796. private _tmpDeltaPosition;
  48797. private _tmpUnityRotation;
  48798. private _updatePhysicsBodyTransformation;
  48799. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48800. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48801. isSupported(): boolean;
  48802. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48803. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48804. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48805. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48806. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48807. getBodyMass(impostor: PhysicsImpostor): number;
  48808. getBodyFriction(impostor: PhysicsImpostor): number;
  48809. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48810. getBodyRestitution(impostor: PhysicsImpostor): number;
  48811. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48812. sleepBody(impostor: PhysicsImpostor): void;
  48813. wakeUpBody(impostor: PhysicsImpostor): void;
  48814. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  48815. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48816. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48817. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48818. getRadius(impostor: PhysicsImpostor): number;
  48819. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48820. dispose(): void;
  48821. private _extendNamespace;
  48822. }
  48823. }
  48824. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  48825. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  48826. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48827. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  48828. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48829. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  48830. import { Nullable } from "babylonjs/types";
  48831. /** @hidden */
  48832. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  48833. world: any;
  48834. name: string;
  48835. BJSOIMO: any;
  48836. constructor(iterations?: number, oimoInjection?: any);
  48837. setGravity(gravity: Vector3): void;
  48838. setTimeStep(timeStep: number): void;
  48839. getTimeStep(): number;
  48840. private _tmpImpostorsArray;
  48841. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48842. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48843. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48844. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48845. private _tmpPositionVector;
  48846. removePhysicsBody(impostor: PhysicsImpostor): void;
  48847. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48848. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48849. isSupported(): boolean;
  48850. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48851. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48852. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48853. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48854. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48855. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48856. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48857. getBodyMass(impostor: PhysicsImpostor): number;
  48858. getBodyFriction(impostor: PhysicsImpostor): number;
  48859. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48860. getBodyRestitution(impostor: PhysicsImpostor): number;
  48861. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48862. sleepBody(impostor: PhysicsImpostor): void;
  48863. wakeUpBody(impostor: PhysicsImpostor): void;
  48864. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48865. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  48866. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  48867. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48868. getRadius(impostor: PhysicsImpostor): number;
  48869. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48870. dispose(): void;
  48871. }
  48872. }
  48873. declare module "babylonjs/Probes/reflectionProbe" {
  48874. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48875. import { Vector3 } from "babylonjs/Maths/math";
  48876. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48877. import { Nullable } from "babylonjs/types";
  48878. import { Scene } from "babylonjs/scene";
  48879. module "babylonjs/abstractScene" {
  48880. interface AbstractScene {
  48881. /**
  48882. * The list of reflection probes added to the scene
  48883. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48884. */
  48885. reflectionProbes: Array<ReflectionProbe>;
  48886. /**
  48887. * Removes the given reflection probe from this scene.
  48888. * @param toRemove The reflection probe to remove
  48889. * @returns The index of the removed reflection probe
  48890. */
  48891. removeReflectionProbe(toRemove: ReflectionProbe): number;
  48892. /**
  48893. * Adds the given reflection probe to this scene.
  48894. * @param newReflectionProbe The reflection probe to add
  48895. */
  48896. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  48897. }
  48898. }
  48899. /**
  48900. * Class used to generate realtime reflection / refraction cube textures
  48901. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48902. */
  48903. export class ReflectionProbe {
  48904. /** defines the name of the probe */
  48905. name: string;
  48906. private _scene;
  48907. private _renderTargetTexture;
  48908. private _projectionMatrix;
  48909. private _viewMatrix;
  48910. private _target;
  48911. private _add;
  48912. private _attachedMesh;
  48913. private _invertYAxis;
  48914. /** Gets or sets probe position (center of the cube map) */
  48915. position: Vector3;
  48916. /**
  48917. * Creates a new reflection probe
  48918. * @param name defines the name of the probe
  48919. * @param size defines the texture resolution (for each face)
  48920. * @param scene defines the hosting scene
  48921. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  48922. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  48923. */
  48924. constructor(
  48925. /** defines the name of the probe */
  48926. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  48927. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  48928. samples: number;
  48929. /** Gets or sets the refresh rate to use (on every frame by default) */
  48930. refreshRate: number;
  48931. /**
  48932. * Gets the hosting scene
  48933. * @returns a Scene
  48934. */
  48935. getScene(): Scene;
  48936. /** Gets the internal CubeTexture used to render to */
  48937. readonly cubeTexture: RenderTargetTexture;
  48938. /** Gets the list of meshes to render */
  48939. readonly renderList: Nullable<AbstractMesh[]>;
  48940. /**
  48941. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  48942. * @param mesh defines the mesh to attach to
  48943. */
  48944. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48945. /**
  48946. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  48947. * @param renderingGroupId The rendering group id corresponding to its index
  48948. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48949. */
  48950. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  48951. /**
  48952. * Clean all associated resources
  48953. */
  48954. dispose(): void;
  48955. /**
  48956. * Converts the reflection probe information to a readable string for debug purpose.
  48957. * @param fullDetails Supports for multiple levels of logging within scene loading
  48958. * @returns the human readable reflection probe info
  48959. */
  48960. toString(fullDetails?: boolean): string;
  48961. /**
  48962. * Get the class name of the relfection probe.
  48963. * @returns "ReflectionProbe"
  48964. */
  48965. getClassName(): string;
  48966. /**
  48967. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  48968. * @returns The JSON representation of the texture
  48969. */
  48970. serialize(): any;
  48971. /**
  48972. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  48973. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  48974. * @param scene Define the scene the parsed reflection probe should be instantiated in
  48975. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48976. * @returns The parsed reflection probe if successful
  48977. */
  48978. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  48979. }
  48980. }
  48981. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  48982. /** @hidden */
  48983. export var _BabylonLoaderRegistered: boolean;
  48984. }
  48985. declare module "babylonjs/Loading/Plugins/index" {
  48986. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  48987. }
  48988. declare module "babylonjs/Loading/index" {
  48989. export * from "babylonjs/Loading/loadingScreen";
  48990. export * from "babylonjs/Loading/Plugins/index";
  48991. export * from "babylonjs/Loading/sceneLoader";
  48992. export * from "babylonjs/Loading/sceneLoaderFlags";
  48993. }
  48994. declare module "babylonjs/Materials/Background/index" {
  48995. export * from "babylonjs/Materials/Background/backgroundMaterial";
  48996. }
  48997. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  48998. import { Scene } from "babylonjs/scene";
  48999. import { Color3 } from "babylonjs/Maths/math";
  49000. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  49001. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49002. /**
  49003. * The Physically based simple base material of BJS.
  49004. *
  49005. * This enables better naming and convention enforcements on top of the pbrMaterial.
  49006. * It is used as the base class for both the specGloss and metalRough conventions.
  49007. */
  49008. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  49009. /**
  49010. * Number of Simultaneous lights allowed on the material.
  49011. */
  49012. maxSimultaneousLights: number;
  49013. /**
  49014. * If sets to true, disables all the lights affecting the material.
  49015. */
  49016. disableLighting: boolean;
  49017. /**
  49018. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  49019. */
  49020. environmentTexture: BaseTexture;
  49021. /**
  49022. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49023. */
  49024. invertNormalMapX: boolean;
  49025. /**
  49026. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49027. */
  49028. invertNormalMapY: boolean;
  49029. /**
  49030. * Normal map used in the model.
  49031. */
  49032. normalTexture: BaseTexture;
  49033. /**
  49034. * Emissivie color used to self-illuminate the model.
  49035. */
  49036. emissiveColor: Color3;
  49037. /**
  49038. * Emissivie texture used to self-illuminate the model.
  49039. */
  49040. emissiveTexture: BaseTexture;
  49041. /**
  49042. * Occlusion Channel Strenght.
  49043. */
  49044. occlusionStrength: number;
  49045. /**
  49046. * Occlusion Texture of the material (adding extra occlusion effects).
  49047. */
  49048. occlusionTexture: BaseTexture;
  49049. /**
  49050. * Defines the alpha limits in alpha test mode.
  49051. */
  49052. alphaCutOff: number;
  49053. /**
  49054. * Gets the current double sided mode.
  49055. */
  49056. /**
  49057. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49058. */
  49059. doubleSided: boolean;
  49060. /**
  49061. * Stores the pre-calculated light information of a mesh in a texture.
  49062. */
  49063. lightmapTexture: BaseTexture;
  49064. /**
  49065. * If true, the light map contains occlusion information instead of lighting info.
  49066. */
  49067. useLightmapAsShadowmap: boolean;
  49068. /**
  49069. * Instantiates a new PBRMaterial instance.
  49070. *
  49071. * @param name The material name
  49072. * @param scene The scene the material will be use in.
  49073. */
  49074. constructor(name: string, scene: Scene);
  49075. getClassName(): string;
  49076. }
  49077. }
  49078. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  49079. import { Scene } from "babylonjs/scene";
  49080. import { Color3 } from "babylonjs/Maths/math";
  49081. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49082. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  49083. /**
  49084. * The PBR material of BJS following the metal roughness convention.
  49085. *
  49086. * This fits to the PBR convention in the GLTF definition:
  49087. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  49088. */
  49089. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  49090. /**
  49091. * The base color has two different interpretations depending on the value of metalness.
  49092. * When the material is a metal, the base color is the specific measured reflectance value
  49093. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  49094. * of the material.
  49095. */
  49096. baseColor: Color3;
  49097. /**
  49098. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  49099. * well as opacity information in the alpha channel.
  49100. */
  49101. baseTexture: BaseTexture;
  49102. /**
  49103. * Specifies the metallic scalar value of the material.
  49104. * Can also be used to scale the metalness values of the metallic texture.
  49105. */
  49106. metallic: number;
  49107. /**
  49108. * Specifies the roughness scalar value of the material.
  49109. * Can also be used to scale the roughness values of the metallic texture.
  49110. */
  49111. roughness: number;
  49112. /**
  49113. * Texture containing both the metallic value in the B channel and the
  49114. * roughness value in the G channel to keep better precision.
  49115. */
  49116. metallicRoughnessTexture: BaseTexture;
  49117. /**
  49118. * Instantiates a new PBRMetalRoughnessMaterial instance.
  49119. *
  49120. * @param name The material name
  49121. * @param scene The scene the material will be use in.
  49122. */
  49123. constructor(name: string, scene: Scene);
  49124. /**
  49125. * Return the currrent class name of the material.
  49126. */
  49127. getClassName(): string;
  49128. /**
  49129. * Makes a duplicate of the current material.
  49130. * @param name - name to use for the new material.
  49131. */
  49132. clone(name: string): PBRMetallicRoughnessMaterial;
  49133. /**
  49134. * Serialize the material to a parsable JSON object.
  49135. */
  49136. serialize(): any;
  49137. /**
  49138. * Parses a JSON object correponding to the serialize function.
  49139. */
  49140. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  49141. }
  49142. }
  49143. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  49144. import { Scene } from "babylonjs/scene";
  49145. import { Color3 } from "babylonjs/Maths/math";
  49146. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49147. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  49148. /**
  49149. * The PBR material of BJS following the specular glossiness convention.
  49150. *
  49151. * This fits to the PBR convention in the GLTF definition:
  49152. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  49153. */
  49154. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  49155. /**
  49156. * Specifies the diffuse color of the material.
  49157. */
  49158. diffuseColor: Color3;
  49159. /**
  49160. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  49161. * channel.
  49162. */
  49163. diffuseTexture: BaseTexture;
  49164. /**
  49165. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  49166. */
  49167. specularColor: Color3;
  49168. /**
  49169. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  49170. */
  49171. glossiness: number;
  49172. /**
  49173. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  49174. */
  49175. specularGlossinessTexture: BaseTexture;
  49176. /**
  49177. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  49178. *
  49179. * @param name The material name
  49180. * @param scene The scene the material will be use in.
  49181. */
  49182. constructor(name: string, scene: Scene);
  49183. /**
  49184. * Return the currrent class name of the material.
  49185. */
  49186. getClassName(): string;
  49187. /**
  49188. * Makes a duplicate of the current material.
  49189. * @param name - name to use for the new material.
  49190. */
  49191. clone(name: string): PBRSpecularGlossinessMaterial;
  49192. /**
  49193. * Serialize the material to a parsable JSON object.
  49194. */
  49195. serialize(): any;
  49196. /**
  49197. * Parses a JSON object correponding to the serialize function.
  49198. */
  49199. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  49200. }
  49201. }
  49202. declare module "babylonjs/Materials/PBR/index" {
  49203. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  49204. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  49205. export * from "babylonjs/Materials/PBR/pbrMaterial";
  49206. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  49207. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  49208. }
  49209. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  49210. import { Nullable } from "babylonjs/types";
  49211. import { Scene } from "babylonjs/scene";
  49212. import { Matrix } from "babylonjs/Maths/math";
  49213. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49214. /**
  49215. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  49216. * It can help converting any input color in a desired output one. This can then be used to create effects
  49217. * from sepia, black and white to sixties or futuristic rendering...
  49218. *
  49219. * The only supported format is currently 3dl.
  49220. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  49221. */
  49222. export class ColorGradingTexture extends BaseTexture {
  49223. /**
  49224. * The current texture matrix. (will always be identity in color grading texture)
  49225. */
  49226. private _textureMatrix;
  49227. /**
  49228. * The texture URL.
  49229. */
  49230. url: string;
  49231. /**
  49232. * Empty line regex stored for GC.
  49233. */
  49234. private static _noneEmptyLineRegex;
  49235. private _engine;
  49236. /**
  49237. * Instantiates a ColorGradingTexture from the following parameters.
  49238. *
  49239. * @param url The location of the color gradind data (currently only supporting 3dl)
  49240. * @param scene The scene the texture will be used in
  49241. */
  49242. constructor(url: string, scene: Scene);
  49243. /**
  49244. * Returns the texture matrix used in most of the material.
  49245. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  49246. */
  49247. getTextureMatrix(): Matrix;
  49248. /**
  49249. * Occurs when the file being loaded is a .3dl LUT file.
  49250. */
  49251. private load3dlTexture;
  49252. /**
  49253. * Starts the loading process of the texture.
  49254. */
  49255. private loadTexture;
  49256. /**
  49257. * Clones the color gradind texture.
  49258. */
  49259. clone(): ColorGradingTexture;
  49260. /**
  49261. * Called during delayed load for textures.
  49262. */
  49263. delayLoad(): void;
  49264. /**
  49265. * Parses a color grading texture serialized by Babylon.
  49266. * @param parsedTexture The texture information being parsedTexture
  49267. * @param scene The scene to load the texture in
  49268. * @param rootUrl The root url of the data assets to load
  49269. * @return A color gradind texture
  49270. */
  49271. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  49272. /**
  49273. * Serializes the LUT texture to json format.
  49274. */
  49275. serialize(): any;
  49276. }
  49277. }
  49278. declare module "babylonjs/Misc/tga" {
  49279. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49280. /**
  49281. * Based on jsTGALoader - Javascript loader for TGA file
  49282. * By Vincent Thibault
  49283. * @see http://blog.robrowser.com/javascript-tga-loader.html
  49284. */
  49285. export class TGATools {
  49286. private static _TYPE_INDEXED;
  49287. private static _TYPE_RGB;
  49288. private static _TYPE_GREY;
  49289. private static _TYPE_RLE_INDEXED;
  49290. private static _TYPE_RLE_RGB;
  49291. private static _TYPE_RLE_GREY;
  49292. private static _ORIGIN_MASK;
  49293. private static _ORIGIN_SHIFT;
  49294. private static _ORIGIN_BL;
  49295. private static _ORIGIN_BR;
  49296. private static _ORIGIN_UL;
  49297. private static _ORIGIN_UR;
  49298. /**
  49299. * Gets the header of a TGA file
  49300. * @param data defines the TGA data
  49301. * @returns the header
  49302. */
  49303. static GetTGAHeader(data: Uint8Array): any;
  49304. /**
  49305. * Uploads TGA content to a Babylon Texture
  49306. * @hidden
  49307. */
  49308. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  49309. /** @hidden */
  49310. 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;
  49311. /** @hidden */
  49312. 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;
  49313. /** @hidden */
  49314. 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;
  49315. /** @hidden */
  49316. 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;
  49317. /** @hidden */
  49318. 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;
  49319. /** @hidden */
  49320. 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;
  49321. }
  49322. }
  49323. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  49324. import { Nullable } from "babylonjs/types";
  49325. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49326. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49327. /**
  49328. * Implementation of the TGA Texture Loader.
  49329. * @hidden
  49330. */
  49331. export class _TGATextureLoader implements IInternalTextureLoader {
  49332. /**
  49333. * Defines wether the loader supports cascade loading the different faces.
  49334. */
  49335. readonly supportCascades: boolean;
  49336. /**
  49337. * This returns if the loader support the current file information.
  49338. * @param extension defines the file extension of the file being loaded
  49339. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49340. * @param fallback defines the fallback internal texture if any
  49341. * @param isBase64 defines whether the texture is encoded as a base64
  49342. * @param isBuffer defines whether the texture data are stored as a buffer
  49343. * @returns true if the loader can load the specified file
  49344. */
  49345. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49346. /**
  49347. * Transform the url before loading if required.
  49348. * @param rootUrl the url of the texture
  49349. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49350. * @returns the transformed texture
  49351. */
  49352. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49353. /**
  49354. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49355. * @param rootUrl the url of the texture
  49356. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49357. * @returns the fallback texture
  49358. */
  49359. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49360. /**
  49361. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49362. * @param data contains the texture data
  49363. * @param texture defines the BabylonJS internal texture
  49364. * @param createPolynomials will be true if polynomials have been requested
  49365. * @param onLoad defines the callback to trigger once the texture is ready
  49366. * @param onError defines the callback to trigger in case of error
  49367. */
  49368. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49369. /**
  49370. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49371. * @param data contains the texture data
  49372. * @param texture defines the BabylonJS internal texture
  49373. * @param callback defines the method to call once ready to upload
  49374. */
  49375. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49376. }
  49377. }
  49378. declare module "babylonjs/Materials/Textures/Loaders/index" {
  49379. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  49380. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  49381. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  49382. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  49383. }
  49384. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  49385. import { Scene } from "babylonjs/scene";
  49386. import { Texture } from "babylonjs/Materials/Textures/texture";
  49387. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49388. /**
  49389. * 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.
  49390. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49391. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49392. */
  49393. export class CustomProceduralTexture extends ProceduralTexture {
  49394. private _animate;
  49395. private _time;
  49396. private _config;
  49397. private _texturePath;
  49398. /**
  49399. * Instantiates a new Custom Procedural Texture.
  49400. * 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.
  49401. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49402. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49403. * @param name Define the name of the texture
  49404. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49405. * @param size Define the size of the texture to create
  49406. * @param scene Define the scene the texture belongs to
  49407. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49408. * @param generateMipMaps Define if the texture should creates mip maps or not
  49409. */
  49410. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49411. private _loadJson;
  49412. /**
  49413. * Is the texture ready to be used ? (rendered at least once)
  49414. * @returns true if ready, otherwise, false.
  49415. */
  49416. isReady(): boolean;
  49417. /**
  49418. * Render the texture to its associated render target.
  49419. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49420. */
  49421. render(useCameraPostProcess?: boolean): void;
  49422. /**
  49423. * Update the list of dependant textures samplers in the shader.
  49424. */
  49425. updateTextures(): void;
  49426. /**
  49427. * Update the uniform values of the procedural texture in the shader.
  49428. */
  49429. updateShaderUniforms(): void;
  49430. /**
  49431. * Define if the texture animates or not.
  49432. */
  49433. animate: boolean;
  49434. }
  49435. }
  49436. declare module "babylonjs/Shaders/noise.fragment" {
  49437. /** @hidden */
  49438. export var noisePixelShader: {
  49439. name: string;
  49440. shader: string;
  49441. };
  49442. }
  49443. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  49444. import { Nullable } from "babylonjs/types";
  49445. import { Scene } from "babylonjs/scene";
  49446. import { Texture } from "babylonjs/Materials/Textures/texture";
  49447. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49448. import "babylonjs/Shaders/noise.fragment";
  49449. /**
  49450. * Class used to generate noise procedural textures
  49451. */
  49452. export class NoiseProceduralTexture extends ProceduralTexture {
  49453. private _time;
  49454. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49455. brightness: number;
  49456. /** Defines the number of octaves to process */
  49457. octaves: number;
  49458. /** Defines the level of persistence (0.8 by default) */
  49459. persistence: number;
  49460. /** Gets or sets animation speed factor (default is 1) */
  49461. animationSpeedFactor: number;
  49462. /**
  49463. * Creates a new NoiseProceduralTexture
  49464. * @param name defines the name fo the texture
  49465. * @param size defines the size of the texture (default is 256)
  49466. * @param scene defines the hosting scene
  49467. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49468. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49469. */
  49470. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49471. private _updateShaderUniforms;
  49472. protected _getDefines(): string;
  49473. /** Generate the current state of the procedural texture */
  49474. render(useCameraPostProcess?: boolean): void;
  49475. /**
  49476. * Serializes this noise procedural texture
  49477. * @returns a serialized noise procedural texture object
  49478. */
  49479. serialize(): any;
  49480. /**
  49481. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49482. * @param parsedTexture defines parsed texture data
  49483. * @param scene defines the current scene
  49484. * @param rootUrl defines the root URL containing noise procedural texture information
  49485. * @returns a parsed NoiseProceduralTexture
  49486. */
  49487. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  49488. }
  49489. }
  49490. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  49491. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  49492. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  49493. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49494. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  49495. }
  49496. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  49497. import { Nullable } from "babylonjs/types";
  49498. import { Scene } from "babylonjs/scene";
  49499. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49500. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49501. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49502. /**
  49503. * Raw cube texture where the raw buffers are passed in
  49504. */
  49505. export class RawCubeTexture extends CubeTexture {
  49506. /**
  49507. * Creates a cube texture where the raw buffers are passed in.
  49508. * @param scene defines the scene the texture is attached to
  49509. * @param data defines the array of data to use to create each face
  49510. * @param size defines the size of the textures
  49511. * @param format defines the format of the data
  49512. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  49513. * @param generateMipMaps defines if the engine should generate the mip levels
  49514. * @param invertY defines if data must be stored with Y axis inverted
  49515. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  49516. * @param compression defines the compression used (null by default)
  49517. */
  49518. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  49519. /**
  49520. * Updates the raw cube texture.
  49521. * @param data defines the data to store
  49522. * @param format defines the data format
  49523. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  49524. * @param invertY defines if data must be stored with Y axis inverted
  49525. * @param compression defines the compression used (null by default)
  49526. * @param level defines which level of the texture to update
  49527. */
  49528. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  49529. /**
  49530. * Updates a raw cube texture with RGBD encoded data.
  49531. * @param data defines the array of data [mipmap][face] to use to create each face
  49532. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  49533. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49534. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49535. * @returns a promsie that resolves when the operation is complete
  49536. */
  49537. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  49538. /**
  49539. * Clones the raw cube texture.
  49540. * @return a new cube texture
  49541. */
  49542. clone(): CubeTexture;
  49543. /** @hidden */
  49544. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49545. }
  49546. }
  49547. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  49548. import { Scene } from "babylonjs/scene";
  49549. import { Texture } from "babylonjs/Materials/Textures/texture";
  49550. /**
  49551. * Class used to store 3D textures containing user data
  49552. */
  49553. export class RawTexture3D extends Texture {
  49554. /** Gets or sets the texture format to use */
  49555. format: number;
  49556. private _engine;
  49557. /**
  49558. * Create a new RawTexture3D
  49559. * @param data defines the data of the texture
  49560. * @param width defines the width of the texture
  49561. * @param height defines the height of the texture
  49562. * @param depth defines the depth of the texture
  49563. * @param format defines the texture format to use
  49564. * @param scene defines the hosting scene
  49565. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  49566. * @param invertY defines if texture must be stored with Y axis inverted
  49567. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  49568. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  49569. */
  49570. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  49571. /** Gets or sets the texture format to use */
  49572. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  49573. /**
  49574. * Update the texture with new data
  49575. * @param data defines the data to store in the texture
  49576. */
  49577. update(data: ArrayBufferView): void;
  49578. }
  49579. }
  49580. declare module "babylonjs/Materials/Textures/refractionTexture" {
  49581. import { Scene } from "babylonjs/scene";
  49582. import { Plane } from "babylonjs/Maths/math";
  49583. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49584. /**
  49585. * Creates a refraction texture used by refraction channel of the standard material.
  49586. * It is like a mirror but to see through a material.
  49587. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49588. */
  49589. export class RefractionTexture extends RenderTargetTexture {
  49590. /**
  49591. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  49592. * 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.
  49593. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49594. */
  49595. refractionPlane: Plane;
  49596. /**
  49597. * Define how deep under the surface we should see.
  49598. */
  49599. depth: number;
  49600. /**
  49601. * Creates a refraction texture used by refraction channel of the standard material.
  49602. * It is like a mirror but to see through a material.
  49603. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49604. * @param name Define the texture name
  49605. * @param size Define the size of the underlying texture
  49606. * @param scene Define the scene the refraction belongs to
  49607. * @param generateMipMaps Define if we need to generate mips level for the refraction
  49608. */
  49609. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  49610. /**
  49611. * Clone the refraction texture.
  49612. * @returns the cloned texture
  49613. */
  49614. clone(): RefractionTexture;
  49615. /**
  49616. * Serialize the texture to a JSON representation you could use in Parse later on
  49617. * @returns the serialized JSON representation
  49618. */
  49619. serialize(): any;
  49620. }
  49621. }
  49622. declare module "babylonjs/Materials/Textures/index" {
  49623. export * from "babylonjs/Materials/Textures/baseTexture";
  49624. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  49625. export * from "babylonjs/Materials/Textures/cubeTexture";
  49626. export * from "babylonjs/Materials/Textures/dynamicTexture";
  49627. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  49628. export * from "babylonjs/Materials/Textures/internalTexture";
  49629. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  49630. export * from "babylonjs/Materials/Textures/internalTextureTracker";
  49631. export * from "babylonjs/Materials/Textures/Loaders/index";
  49632. export * from "babylonjs/Materials/Textures/mirrorTexture";
  49633. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  49634. export * from "babylonjs/Materials/Textures/Procedurals/index";
  49635. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  49636. export * from "babylonjs/Materials/Textures/rawTexture";
  49637. export * from "babylonjs/Materials/Textures/rawTexture3D";
  49638. export * from "babylonjs/Materials/Textures/refractionTexture";
  49639. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  49640. export * from "babylonjs/Materials/Textures/texture";
  49641. export * from "babylonjs/Materials/Textures/videoTexture";
  49642. }
  49643. declare module "babylonjs/Materials/index" {
  49644. export * from "babylonjs/Materials/Background/index";
  49645. export * from "babylonjs/Materials/colorCurves";
  49646. export * from "babylonjs/Materials/effect";
  49647. export * from "babylonjs/Materials/fresnelParameters";
  49648. export * from "babylonjs/Materials/imageProcessingConfiguration";
  49649. export * from "babylonjs/Materials/material";
  49650. export * from "babylonjs/Materials/materialDefines";
  49651. export * from "babylonjs/Materials/materialHelper";
  49652. export * from "babylonjs/Materials/multiMaterial";
  49653. export * from "babylonjs/Materials/PBR/index";
  49654. export * from "babylonjs/Materials/pushMaterial";
  49655. export * from "babylonjs/Materials/shaderMaterial";
  49656. export * from "babylonjs/Materials/standardMaterial";
  49657. export * from "babylonjs/Materials/Textures/index";
  49658. export * from "babylonjs/Materials/uniformBuffer";
  49659. export * from "babylonjs/Materials/materialFlags";
  49660. }
  49661. declare module "babylonjs/Maths/index" {
  49662. export * from "babylonjs/Maths/math.scalar";
  49663. export * from "babylonjs/Maths/math";
  49664. export * from "babylonjs/Maths/sphericalPolynomial";
  49665. }
  49666. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  49667. import { IDisposable } from "babylonjs/scene";
  49668. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  49669. /**
  49670. * Configuration for Draco compression
  49671. */
  49672. export interface IDracoCompressionConfiguration {
  49673. /**
  49674. * Configuration for the decoder.
  49675. */
  49676. decoder?: {
  49677. /**
  49678. * The url to the WebAssembly module.
  49679. */
  49680. wasmUrl?: string;
  49681. /**
  49682. * The url to the WebAssembly binary.
  49683. */
  49684. wasmBinaryUrl?: string;
  49685. /**
  49686. * The url to the fallback JavaScript module.
  49687. */
  49688. fallbackUrl?: string;
  49689. };
  49690. }
  49691. /**
  49692. * Draco compression (https://google.github.io/draco/)
  49693. *
  49694. * This class wraps the Draco module.
  49695. *
  49696. * **Encoder**
  49697. *
  49698. * The encoder is not currently implemented.
  49699. *
  49700. * **Decoder**
  49701. *
  49702. * 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.
  49703. *
  49704. * To update the configuration, use the following code:
  49705. * ```javascript
  49706. * DracoCompression.Configuration = {
  49707. * decoder: {
  49708. * wasmUrl: "<url to the WebAssembly library>",
  49709. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  49710. * fallbackUrl: "<url to the fallback JavaScript library>",
  49711. * }
  49712. * };
  49713. * ```
  49714. *
  49715. * 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.
  49716. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  49717. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  49718. *
  49719. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  49720. * ```javascript
  49721. * var dracoCompression = new DracoCompression();
  49722. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  49723. * [VertexBuffer.PositionKind]: 0
  49724. * });
  49725. * ```
  49726. *
  49727. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  49728. */
  49729. export class DracoCompression implements IDisposable {
  49730. private static _DecoderModulePromise;
  49731. /**
  49732. * The configuration. Defaults to the following urls:
  49733. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  49734. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  49735. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  49736. */
  49737. static Configuration: IDracoCompressionConfiguration;
  49738. /**
  49739. * Returns true if the decoder is available.
  49740. */
  49741. static readonly DecoderAvailable: boolean;
  49742. /**
  49743. * Constructor
  49744. */
  49745. constructor();
  49746. /**
  49747. * Stop all async operations and release resources.
  49748. */
  49749. dispose(): void;
  49750. /**
  49751. * Decode Draco compressed mesh data to vertex data.
  49752. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  49753. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  49754. * @returns A promise that resolves with the decoded vertex data
  49755. */
  49756. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  49757. [kind: string]: number;
  49758. }): Promise<VertexData>;
  49759. private static _GetDecoderModule;
  49760. private static _LoadScriptAsync;
  49761. private static _LoadFileAsync;
  49762. }
  49763. }
  49764. declare module "babylonjs/Meshes/Compression/index" {
  49765. export * from "babylonjs/Meshes/Compression/dracoCompression";
  49766. }
  49767. declare module "babylonjs/Meshes/csg" {
  49768. import { Nullable } from "babylonjs/types";
  49769. import { Scene } from "babylonjs/scene";
  49770. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  49771. import { Mesh } from "babylonjs/Meshes/mesh";
  49772. import { Material } from "babylonjs/Materials/material";
  49773. /**
  49774. * Class for building Constructive Solid Geometry
  49775. */
  49776. export class CSG {
  49777. private polygons;
  49778. /**
  49779. * The world matrix
  49780. */
  49781. matrix: Matrix;
  49782. /**
  49783. * Stores the position
  49784. */
  49785. position: Vector3;
  49786. /**
  49787. * Stores the rotation
  49788. */
  49789. rotation: Vector3;
  49790. /**
  49791. * Stores the rotation quaternion
  49792. */
  49793. rotationQuaternion: Nullable<Quaternion>;
  49794. /**
  49795. * Stores the scaling vector
  49796. */
  49797. scaling: Vector3;
  49798. /**
  49799. * Convert the Mesh to CSG
  49800. * @param mesh The Mesh to convert to CSG
  49801. * @returns A new CSG from the Mesh
  49802. */
  49803. static FromMesh(mesh: Mesh): CSG;
  49804. /**
  49805. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  49806. * @param polygons Polygons used to construct a CSG solid
  49807. */
  49808. private static FromPolygons;
  49809. /**
  49810. * Clones, or makes a deep copy, of the CSG
  49811. * @returns A new CSG
  49812. */
  49813. clone(): CSG;
  49814. /**
  49815. * Unions this CSG with another CSG
  49816. * @param csg The CSG to union against this CSG
  49817. * @returns The unioned CSG
  49818. */
  49819. union(csg: CSG): CSG;
  49820. /**
  49821. * Unions this CSG with another CSG in place
  49822. * @param csg The CSG to union against this CSG
  49823. */
  49824. unionInPlace(csg: CSG): void;
  49825. /**
  49826. * Subtracts this CSG with another CSG
  49827. * @param csg The CSG to subtract against this CSG
  49828. * @returns A new CSG
  49829. */
  49830. subtract(csg: CSG): CSG;
  49831. /**
  49832. * Subtracts this CSG with another CSG in place
  49833. * @param csg The CSG to subtact against this CSG
  49834. */
  49835. subtractInPlace(csg: CSG): void;
  49836. /**
  49837. * Intersect this CSG with another CSG
  49838. * @param csg The CSG to intersect against this CSG
  49839. * @returns A new CSG
  49840. */
  49841. intersect(csg: CSG): CSG;
  49842. /**
  49843. * Intersects this CSG with another CSG in place
  49844. * @param csg The CSG to intersect against this CSG
  49845. */
  49846. intersectInPlace(csg: CSG): void;
  49847. /**
  49848. * Return a new CSG solid with solid and empty space switched. This solid is
  49849. * not modified.
  49850. * @returns A new CSG solid with solid and empty space switched
  49851. */
  49852. inverse(): CSG;
  49853. /**
  49854. * Inverses the CSG in place
  49855. */
  49856. inverseInPlace(): void;
  49857. /**
  49858. * This is used to keep meshes transformations so they can be restored
  49859. * when we build back a Babylon Mesh
  49860. * NB : All CSG operations are performed in world coordinates
  49861. * @param csg The CSG to copy the transform attributes from
  49862. * @returns This CSG
  49863. */
  49864. copyTransformAttributes(csg: CSG): CSG;
  49865. /**
  49866. * Build Raw mesh from CSG
  49867. * Coordinates here are in world space
  49868. * @param name The name of the mesh geometry
  49869. * @param scene The Scene
  49870. * @param keepSubMeshes Specifies if the submeshes should be kept
  49871. * @returns A new Mesh
  49872. */
  49873. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  49874. /**
  49875. * Build Mesh from CSG taking material and transforms into account
  49876. * @param name The name of the Mesh
  49877. * @param material The material of the Mesh
  49878. * @param scene The Scene
  49879. * @param keepSubMeshes Specifies if submeshes should be kept
  49880. * @returns The new Mesh
  49881. */
  49882. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  49883. }
  49884. }
  49885. declare module "babylonjs/Meshes/trailMesh" {
  49886. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49887. import { Mesh } from "babylonjs/Meshes/mesh";
  49888. import { Scene } from "babylonjs/scene";
  49889. /**
  49890. * Class used to create a trail following a mesh
  49891. */
  49892. export class TrailMesh extends Mesh {
  49893. private _generator;
  49894. private _autoStart;
  49895. private _running;
  49896. private _diameter;
  49897. private _length;
  49898. private _sectionPolygonPointsCount;
  49899. private _sectionVectors;
  49900. private _sectionNormalVectors;
  49901. private _beforeRenderObserver;
  49902. /**
  49903. * @constructor
  49904. * @param name The value used by scene.getMeshByName() to do a lookup.
  49905. * @param generator The mesh to generate a trail.
  49906. * @param scene The scene to add this mesh to.
  49907. * @param diameter Diameter of trailing mesh. Default is 1.
  49908. * @param length Length of trailing mesh. Default is 60.
  49909. * @param autoStart Automatically start trailing mesh. Default true.
  49910. */
  49911. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  49912. /**
  49913. * "TrailMesh"
  49914. * @returns "TrailMesh"
  49915. */
  49916. getClassName(): string;
  49917. private _createMesh;
  49918. /**
  49919. * Start trailing mesh.
  49920. */
  49921. start(): void;
  49922. /**
  49923. * Stop trailing mesh.
  49924. */
  49925. stop(): void;
  49926. /**
  49927. * Update trailing mesh geometry.
  49928. */
  49929. update(): void;
  49930. /**
  49931. * Returns a new TrailMesh object.
  49932. * @param name is a string, the name given to the new mesh
  49933. * @param newGenerator use new generator object for cloned trail mesh
  49934. * @returns a new mesh
  49935. */
  49936. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  49937. /**
  49938. * Serializes this trail mesh
  49939. * @param serializationObject object to write serialization to
  49940. */
  49941. serialize(serializationObject: any): void;
  49942. /**
  49943. * Parses a serialized trail mesh
  49944. * @param parsedMesh the serialized mesh
  49945. * @param scene the scene to create the trail mesh in
  49946. * @returns the created trail mesh
  49947. */
  49948. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  49949. }
  49950. }
  49951. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  49952. import { Nullable } from "babylonjs/types";
  49953. import { Scene } from "babylonjs/scene";
  49954. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  49955. import { Mesh } from "babylonjs/Meshes/mesh";
  49956. /**
  49957. * Class containing static functions to help procedurally build meshes
  49958. */
  49959. export class RibbonBuilder {
  49960. /**
  49961. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49962. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49963. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49964. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49965. * * 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
  49966. * * 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
  49967. * * 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
  49968. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49969. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49970. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49971. * * 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
  49972. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49973. * * 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
  49974. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49975. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49976. * @param name defines the name of the mesh
  49977. * @param options defines the options used to create the mesh
  49978. * @param scene defines the hosting scene
  49979. * @returns the ribbon mesh
  49980. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49981. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49982. */
  49983. static CreateRibbon(name: string, options: {
  49984. pathArray: Vector3[][];
  49985. closeArray?: boolean;
  49986. closePath?: boolean;
  49987. offset?: number;
  49988. updatable?: boolean;
  49989. sideOrientation?: number;
  49990. frontUVs?: Vector4;
  49991. backUVs?: Vector4;
  49992. instance?: Mesh;
  49993. invertUV?: boolean;
  49994. uvs?: Vector2[];
  49995. colors?: Color4[];
  49996. }, scene?: Nullable<Scene>): Mesh;
  49997. }
  49998. }
  49999. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  50000. import { Vector4 } from "babylonjs/Maths/math";
  50001. import { Mesh } from "babylonjs/Meshes/mesh";
  50002. /**
  50003. * Class containing static functions to help procedurally build meshes
  50004. */
  50005. export class TorusKnotBuilder {
  50006. /**
  50007. * Creates a torus knot mesh
  50008. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  50009. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  50010. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  50011. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  50012. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50013. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50014. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50015. * @param name defines the name of the mesh
  50016. * @param options defines the options used to create the mesh
  50017. * @param scene defines the hosting scene
  50018. * @returns the torus knot mesh
  50019. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  50020. */
  50021. static CreateTorusKnot(name: string, options: {
  50022. radius?: number;
  50023. tube?: number;
  50024. radialSegments?: number;
  50025. tubularSegments?: number;
  50026. p?: number;
  50027. q?: number;
  50028. updatable?: boolean;
  50029. sideOrientation?: number;
  50030. frontUVs?: Vector4;
  50031. backUVs?: Vector4;
  50032. }, scene: any): Mesh;
  50033. }
  50034. }
  50035. declare module "babylonjs/Meshes/polygonMesh" {
  50036. import { Scene } from "babylonjs/scene";
  50037. import { Vector2, Path2 } from "babylonjs/Maths/math";
  50038. import { Mesh } from "babylonjs/Meshes/mesh";
  50039. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  50040. /**
  50041. * Polygon
  50042. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  50043. */
  50044. export class Polygon {
  50045. /**
  50046. * Creates a rectangle
  50047. * @param xmin bottom X coord
  50048. * @param ymin bottom Y coord
  50049. * @param xmax top X coord
  50050. * @param ymax top Y coord
  50051. * @returns points that make the resulting rectation
  50052. */
  50053. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  50054. /**
  50055. * Creates a circle
  50056. * @param radius radius of circle
  50057. * @param cx scale in x
  50058. * @param cy scale in y
  50059. * @param numberOfSides number of sides that make up the circle
  50060. * @returns points that make the resulting circle
  50061. */
  50062. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  50063. /**
  50064. * Creates a polygon from input string
  50065. * @param input Input polygon data
  50066. * @returns the parsed points
  50067. */
  50068. static Parse(input: string): Vector2[];
  50069. /**
  50070. * Starts building a polygon from x and y coordinates
  50071. * @param x x coordinate
  50072. * @param y y coordinate
  50073. * @returns the started path2
  50074. */
  50075. static StartingAt(x: number, y: number): Path2;
  50076. }
  50077. /**
  50078. * Builds a polygon
  50079. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  50080. */
  50081. export class PolygonMeshBuilder {
  50082. private _points;
  50083. private _outlinepoints;
  50084. private _holes;
  50085. private _name;
  50086. private _scene;
  50087. private _epoints;
  50088. private _eholes;
  50089. private _addToepoint;
  50090. /**
  50091. * Babylon reference to the earcut plugin.
  50092. */
  50093. bjsEarcut: any;
  50094. /**
  50095. * Creates a PolygonMeshBuilder
  50096. * @param name name of the builder
  50097. * @param contours Path of the polygon
  50098. * @param scene scene to add to
  50099. * @param earcutInjection can be used to inject your own earcut reference
  50100. */
  50101. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  50102. /**
  50103. * Adds a whole within the polygon
  50104. * @param hole Array of points defining the hole
  50105. * @returns this
  50106. */
  50107. addHole(hole: Vector2[]): PolygonMeshBuilder;
  50108. /**
  50109. * Creates the polygon
  50110. * @param updatable If the mesh should be updatable
  50111. * @param depth The depth of the mesh created
  50112. * @returns the created mesh
  50113. */
  50114. build(updatable?: boolean, depth?: number): Mesh;
  50115. /**
  50116. * Creates the polygon
  50117. * @param depth The depth of the mesh created
  50118. * @returns the created VertexData
  50119. */
  50120. buildVertexData(depth?: number): VertexData;
  50121. /**
  50122. * Adds a side to the polygon
  50123. * @param positions points that make the polygon
  50124. * @param normals normals of the polygon
  50125. * @param uvs uvs of the polygon
  50126. * @param indices indices of the polygon
  50127. * @param bounds bounds of the polygon
  50128. * @param points points of the polygon
  50129. * @param depth depth of the polygon
  50130. * @param flip flip of the polygon
  50131. */
  50132. private addSide;
  50133. }
  50134. }
  50135. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  50136. import { Scene } from "babylonjs/scene";
  50137. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  50138. import { Mesh } from "babylonjs/Meshes/mesh";
  50139. /**
  50140. * Class containing static functions to help procedurally build meshes
  50141. */
  50142. export class PolygonBuilder {
  50143. /**
  50144. * Creates a polygon mesh
  50145. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50146. * * 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
  50147. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50148. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50149. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  50150. * * Remember you can only change the shape positions, not their number when updating a polygon
  50151. * @param name defines the name of the mesh
  50152. * @param options defines the options used to create the mesh
  50153. * @param scene defines the hosting scene
  50154. * @param earcutInjection can be used to inject your own earcut reference
  50155. * @returns the polygon mesh
  50156. */
  50157. static CreatePolygon(name: string, options: {
  50158. shape: Vector3[];
  50159. holes?: Vector3[][];
  50160. depth?: number;
  50161. faceUV?: Vector4[];
  50162. faceColors?: Color4[];
  50163. updatable?: boolean;
  50164. sideOrientation?: number;
  50165. frontUVs?: Vector4;
  50166. backUVs?: Vector4;
  50167. }, scene: Scene, earcutInjection?: any): Mesh;
  50168. /**
  50169. * Creates an extruded polygon mesh, with depth in the Y direction.
  50170. * * 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)
  50171. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50172. * @param name defines the name of the mesh
  50173. * @param options defines the options used to create the mesh
  50174. * @param scene defines the hosting scene
  50175. * @param earcutInjection can be used to inject your own earcut reference
  50176. * @returns the polygon mesh
  50177. */
  50178. static ExtrudePolygon(name: string, options: {
  50179. shape: Vector3[];
  50180. holes?: Vector3[][];
  50181. depth?: number;
  50182. faceUV?: Vector4[];
  50183. faceColors?: Color4[];
  50184. updatable?: boolean;
  50185. sideOrientation?: number;
  50186. frontUVs?: Vector4;
  50187. backUVs?: Vector4;
  50188. }, scene: Scene, earcutInjection?: any): Mesh;
  50189. }
  50190. }
  50191. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  50192. import { Nullable } from "babylonjs/types";
  50193. import { Scene } from "babylonjs/scene";
  50194. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50195. import { Mesh } from "babylonjs/Meshes/mesh";
  50196. /**
  50197. * Class containing static functions to help procedurally build meshes
  50198. */
  50199. export class ShapeBuilder {
  50200. /**
  50201. * 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.
  50202. * * 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.
  50203. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50204. * * 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.
  50205. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50206. * * 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
  50207. * * 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
  50208. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50209. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50210. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50211. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50212. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50213. * @param name defines the name of the mesh
  50214. * @param options defines the options used to create the mesh
  50215. * @param scene defines the hosting scene
  50216. * @returns the extruded shape mesh
  50217. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50218. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50219. */
  50220. static ExtrudeShape(name: string, options: {
  50221. shape: Vector3[];
  50222. path: Vector3[];
  50223. scale?: number;
  50224. rotation?: number;
  50225. cap?: number;
  50226. updatable?: boolean;
  50227. sideOrientation?: number;
  50228. frontUVs?: Vector4;
  50229. backUVs?: Vector4;
  50230. instance?: Mesh;
  50231. invertUV?: boolean;
  50232. }, scene?: Nullable<Scene>): Mesh;
  50233. /**
  50234. * Creates an custom extruded shape mesh.
  50235. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50236. * * 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.
  50237. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50238. * * 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
  50239. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50240. * * 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
  50241. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50242. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50243. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50244. * * 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
  50245. * * 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
  50246. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50247. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50248. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50249. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50250. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50251. * @param name defines the name of the mesh
  50252. * @param options defines the options used to create the mesh
  50253. * @param scene defines the hosting scene
  50254. * @returns the custom extruded shape mesh
  50255. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50256. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50257. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50258. */
  50259. static ExtrudeShapeCustom(name: string, options: {
  50260. shape: Vector3[];
  50261. path: Vector3[];
  50262. scaleFunction?: any;
  50263. rotationFunction?: any;
  50264. ribbonCloseArray?: boolean;
  50265. ribbonClosePath?: boolean;
  50266. cap?: number;
  50267. updatable?: boolean;
  50268. sideOrientation?: number;
  50269. frontUVs?: Vector4;
  50270. backUVs?: Vector4;
  50271. instance?: Mesh;
  50272. invertUV?: boolean;
  50273. }, scene: Scene): Mesh;
  50274. private static _ExtrudeShapeGeneric;
  50275. }
  50276. }
  50277. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  50278. import { Scene } from "babylonjs/scene";
  50279. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50280. import { Mesh } from "babylonjs/Meshes/mesh";
  50281. /**
  50282. * Class containing static functions to help procedurally build meshes
  50283. */
  50284. export class LatheBuilder {
  50285. /**
  50286. * Creates lathe mesh.
  50287. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50288. * * 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
  50289. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50290. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50291. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50292. * * 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
  50293. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50294. * * 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
  50295. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50296. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50297. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50298. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50299. * @param name defines the name of the mesh
  50300. * @param options defines the options used to create the mesh
  50301. * @param scene defines the hosting scene
  50302. * @returns the lathe mesh
  50303. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50304. */
  50305. static CreateLathe(name: string, options: {
  50306. shape: Vector3[];
  50307. radius?: number;
  50308. tessellation?: number;
  50309. clip?: number;
  50310. arc?: number;
  50311. closed?: boolean;
  50312. updatable?: boolean;
  50313. sideOrientation?: number;
  50314. frontUVs?: Vector4;
  50315. backUVs?: Vector4;
  50316. cap?: number;
  50317. invertUV?: boolean;
  50318. }, scene: Scene): Mesh;
  50319. }
  50320. }
  50321. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  50322. import { Scene } from "babylonjs/scene";
  50323. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50324. import { Mesh } from "babylonjs/Meshes/mesh";
  50325. /**
  50326. * Class containing static functions to help procedurally build meshes
  50327. */
  50328. export class TubeBuilder {
  50329. /**
  50330. * Creates a tube mesh.
  50331. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50332. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50333. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50334. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50335. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50336. * * 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)
  50337. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50338. * * 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
  50339. * * 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
  50340. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50341. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50342. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50343. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50344. * @param name defines the name of the mesh
  50345. * @param options defines the options used to create the mesh
  50346. * @param scene defines the hosting scene
  50347. * @returns the tube mesh
  50348. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50349. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50350. */
  50351. static CreateTube(name: string, options: {
  50352. path: Vector3[];
  50353. radius?: number;
  50354. tessellation?: number;
  50355. radiusFunction?: {
  50356. (i: number, distance: number): number;
  50357. };
  50358. cap?: number;
  50359. arc?: number;
  50360. updatable?: boolean;
  50361. sideOrientation?: number;
  50362. frontUVs?: Vector4;
  50363. backUVs?: Vector4;
  50364. instance?: Mesh;
  50365. invertUV?: boolean;
  50366. }, scene: Scene): Mesh;
  50367. }
  50368. }
  50369. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  50370. import { Scene } from "babylonjs/scene";
  50371. import { Vector4 } from "babylonjs/Maths/math";
  50372. import { Mesh } from "babylonjs/Meshes/mesh";
  50373. /**
  50374. * Class containing static functions to help procedurally build meshes
  50375. */
  50376. export class IcoSphereBuilder {
  50377. /**
  50378. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50379. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50380. * * 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`)
  50381. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50382. * * 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
  50383. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50384. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50385. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50386. * @param name defines the name of the mesh
  50387. * @param options defines the options used to create the mesh
  50388. * @param scene defines the hosting scene
  50389. * @returns the icosahedron mesh
  50390. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50391. */
  50392. static CreateIcoSphere(name: string, options: {
  50393. radius?: number;
  50394. radiusX?: number;
  50395. radiusY?: number;
  50396. radiusZ?: number;
  50397. flat?: boolean;
  50398. subdivisions?: number;
  50399. sideOrientation?: number;
  50400. frontUVs?: Vector4;
  50401. backUVs?: Vector4;
  50402. updatable?: boolean;
  50403. }, scene: Scene): Mesh;
  50404. }
  50405. }
  50406. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  50407. import { Vector3 } from "babylonjs/Maths/math";
  50408. import { Mesh } from "babylonjs/Meshes/mesh";
  50409. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50410. /**
  50411. * Class containing static functions to help procedurally build meshes
  50412. */
  50413. export class DecalBuilder {
  50414. /**
  50415. * Creates a decal mesh.
  50416. * 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
  50417. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50418. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50419. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50420. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50421. * @param name defines the name of the mesh
  50422. * @param sourceMesh defines the mesh where the decal must be applied
  50423. * @param options defines the options used to create the mesh
  50424. * @param scene defines the hosting scene
  50425. * @returns the decal mesh
  50426. * @see https://doc.babylonjs.com/how_to/decals
  50427. */
  50428. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50429. position?: Vector3;
  50430. normal?: Vector3;
  50431. size?: Vector3;
  50432. angle?: number;
  50433. }): Mesh;
  50434. }
  50435. }
  50436. declare module "babylonjs/Meshes/meshBuilder" {
  50437. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  50438. import { Nullable } from "babylonjs/types";
  50439. import { Scene } from "babylonjs/scene";
  50440. import { Mesh } from "babylonjs/Meshes/mesh";
  50441. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  50442. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  50443. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50444. /**
  50445. * Class containing static functions to help procedurally build meshes
  50446. */
  50447. export class MeshBuilder {
  50448. /**
  50449. * Creates a box mesh
  50450. * * The parameter `size` sets the size (float) of each box side (default 1)
  50451. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50452. * * 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)
  50453. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50454. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50455. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50456. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50457. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50458. * @param name defines the name of the mesh
  50459. * @param options defines the options used to create the mesh
  50460. * @param scene defines the hosting scene
  50461. * @returns the box mesh
  50462. */
  50463. static CreateBox(name: string, options: {
  50464. size?: number;
  50465. width?: number;
  50466. height?: number;
  50467. depth?: number;
  50468. faceUV?: Vector4[];
  50469. faceColors?: Color4[];
  50470. sideOrientation?: number;
  50471. frontUVs?: Vector4;
  50472. backUVs?: Vector4;
  50473. updatable?: boolean;
  50474. }, scene?: Nullable<Scene>): Mesh;
  50475. /**
  50476. * Creates a sphere mesh
  50477. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50478. * * 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`)
  50479. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50480. * * 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
  50481. * * 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)
  50482. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50483. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50484. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50485. * @param name defines the name of the mesh
  50486. * @param options defines the options used to create the mesh
  50487. * @param scene defines the hosting scene
  50488. * @returns the sphere mesh
  50489. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50490. */
  50491. static CreateSphere(name: string, options: {
  50492. segments?: number;
  50493. diameter?: number;
  50494. diameterX?: number;
  50495. diameterY?: number;
  50496. diameterZ?: number;
  50497. arc?: number;
  50498. slice?: number;
  50499. sideOrientation?: number;
  50500. frontUVs?: Vector4;
  50501. backUVs?: Vector4;
  50502. updatable?: boolean;
  50503. }, scene: any): Mesh;
  50504. /**
  50505. * Creates a plane polygonal mesh. By default, this is a disc
  50506. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  50507. * * 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
  50508. * * 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
  50509. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50510. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50511. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50512. * @param name defines the name of the mesh
  50513. * @param options defines the options used to create the mesh
  50514. * @param scene defines the hosting scene
  50515. * @returns the plane polygonal mesh
  50516. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  50517. */
  50518. static CreateDisc(name: string, options: {
  50519. radius?: number;
  50520. tessellation?: number;
  50521. arc?: number;
  50522. updatable?: boolean;
  50523. sideOrientation?: number;
  50524. frontUVs?: Vector4;
  50525. backUVs?: Vector4;
  50526. }, scene?: Nullable<Scene>): Mesh;
  50527. /**
  50528. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50529. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50530. * * 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`)
  50531. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50532. * * 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
  50533. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50534. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50535. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50536. * @param name defines the name of the mesh
  50537. * @param options defines the options used to create the mesh
  50538. * @param scene defines the hosting scene
  50539. * @returns the icosahedron mesh
  50540. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50541. */
  50542. static CreateIcoSphere(name: string, options: {
  50543. radius?: number;
  50544. radiusX?: number;
  50545. radiusY?: number;
  50546. radiusZ?: number;
  50547. flat?: boolean;
  50548. subdivisions?: number;
  50549. sideOrientation?: number;
  50550. frontUVs?: Vector4;
  50551. backUVs?: Vector4;
  50552. updatable?: boolean;
  50553. }, scene: Scene): Mesh;
  50554. /**
  50555. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50556. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50557. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50558. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50559. * * 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
  50560. * * 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
  50561. * * 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
  50562. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50563. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50564. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50565. * * 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
  50566. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50567. * * 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
  50568. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50569. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50570. * @param name defines the name of the mesh
  50571. * @param options defines the options used to create the mesh
  50572. * @param scene defines the hosting scene
  50573. * @returns the ribbon mesh
  50574. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50575. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50576. */
  50577. static CreateRibbon(name: string, options: {
  50578. pathArray: Vector3[][];
  50579. closeArray?: boolean;
  50580. closePath?: boolean;
  50581. offset?: number;
  50582. updatable?: boolean;
  50583. sideOrientation?: number;
  50584. frontUVs?: Vector4;
  50585. backUVs?: Vector4;
  50586. instance?: Mesh;
  50587. invertUV?: boolean;
  50588. uvs?: Vector2[];
  50589. colors?: Color4[];
  50590. }, scene?: Nullable<Scene>): Mesh;
  50591. /**
  50592. * Creates a cylinder or a cone mesh
  50593. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  50594. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  50595. * * 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.
  50596. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  50597. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  50598. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  50599. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  50600. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  50601. * * 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).
  50602. * * 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
  50603. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  50604. * * 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
  50605. * * 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.
  50606. * * If `enclose` is false, a ring surface is one element.
  50607. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  50608. * * 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
  50609. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50610. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50611. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50612. * @param name defines the name of the mesh
  50613. * @param options defines the options used to create the mesh
  50614. * @param scene defines the hosting scene
  50615. * @returns the cylinder mesh
  50616. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  50617. */
  50618. static CreateCylinder(name: string, options: {
  50619. height?: number;
  50620. diameterTop?: number;
  50621. diameterBottom?: number;
  50622. diameter?: number;
  50623. tessellation?: number;
  50624. subdivisions?: number;
  50625. arc?: number;
  50626. faceColors?: Color4[];
  50627. faceUV?: Vector4[];
  50628. updatable?: boolean;
  50629. hasRings?: boolean;
  50630. enclose?: boolean;
  50631. sideOrientation?: number;
  50632. frontUVs?: Vector4;
  50633. backUVs?: Vector4;
  50634. }, scene: any): Mesh;
  50635. /**
  50636. * Creates a torus mesh
  50637. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  50638. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  50639. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  50640. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50641. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50642. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50643. * @param name defines the name of the mesh
  50644. * @param options defines the options used to create the mesh
  50645. * @param scene defines the hosting scene
  50646. * @returns the torus mesh
  50647. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  50648. */
  50649. static CreateTorus(name: string, options: {
  50650. diameter?: number;
  50651. thickness?: number;
  50652. tessellation?: number;
  50653. updatable?: boolean;
  50654. sideOrientation?: number;
  50655. frontUVs?: Vector4;
  50656. backUVs?: Vector4;
  50657. }, scene: any): Mesh;
  50658. /**
  50659. * Creates a torus knot mesh
  50660. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  50661. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  50662. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  50663. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  50664. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50665. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50666. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50667. * @param name defines the name of the mesh
  50668. * @param options defines the options used to create the mesh
  50669. * @param scene defines the hosting scene
  50670. * @returns the torus knot mesh
  50671. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  50672. */
  50673. static CreateTorusKnot(name: string, options: {
  50674. radius?: number;
  50675. tube?: number;
  50676. radialSegments?: number;
  50677. tubularSegments?: number;
  50678. p?: number;
  50679. q?: number;
  50680. updatable?: boolean;
  50681. sideOrientation?: number;
  50682. frontUVs?: Vector4;
  50683. backUVs?: Vector4;
  50684. }, scene: any): Mesh;
  50685. /**
  50686. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  50687. * * 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
  50688. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  50689. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  50690. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  50691. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  50692. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50693. * * 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
  50694. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  50695. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50696. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  50697. * @param name defines the name of the new line system
  50698. * @param options defines the options used to create the line system
  50699. * @param scene defines the hosting scene
  50700. * @returns a new line system mesh
  50701. */
  50702. static CreateLineSystem(name: string, options: {
  50703. lines: Vector3[][];
  50704. updatable?: boolean;
  50705. instance?: Nullable<LinesMesh>;
  50706. colors?: Nullable<Color4[][]>;
  50707. useVertexAlpha?: boolean;
  50708. }, scene: Nullable<Scene>): LinesMesh;
  50709. /**
  50710. * Creates a line mesh
  50711. * 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
  50712. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50713. * * The parameter `points` is an array successive Vector3
  50714. * * 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
  50715. * * The optional parameter `colors` is an array of successive Color4, one per line point
  50716. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  50717. * * When updating an instance, remember that only point positions can change, not the number of points
  50718. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50719. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  50720. * @param name defines the name of the new line system
  50721. * @param options defines the options used to create the line system
  50722. * @param scene defines the hosting scene
  50723. * @returns a new line mesh
  50724. */
  50725. static CreateLines(name: string, options: {
  50726. points: Vector3[];
  50727. updatable?: boolean;
  50728. instance?: Nullable<LinesMesh>;
  50729. colors?: Color4[];
  50730. useVertexAlpha?: boolean;
  50731. }, scene?: Nullable<Scene>): LinesMesh;
  50732. /**
  50733. * Creates a dashed line mesh
  50734. * * 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
  50735. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50736. * * The parameter `points` is an array successive Vector3
  50737. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  50738. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  50739. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  50740. * * 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
  50741. * * When updating an instance, remember that only point positions can change, not the number of points
  50742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50743. * @param name defines the name of the mesh
  50744. * @param options defines the options used to create the mesh
  50745. * @param scene defines the hosting scene
  50746. * @returns the dashed line mesh
  50747. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  50748. */
  50749. static CreateDashedLines(name: string, options: {
  50750. points: Vector3[];
  50751. dashSize?: number;
  50752. gapSize?: number;
  50753. dashNb?: number;
  50754. updatable?: boolean;
  50755. instance?: LinesMesh;
  50756. }, scene?: Nullable<Scene>): LinesMesh;
  50757. /**
  50758. * 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.
  50759. * * 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.
  50760. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50761. * * 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.
  50762. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50763. * * 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
  50764. * * 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
  50765. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50766. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50767. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50768. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50769. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50770. * @param name defines the name of the mesh
  50771. * @param options defines the options used to create the mesh
  50772. * @param scene defines the hosting scene
  50773. * @returns the extruded shape mesh
  50774. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50775. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50776. */
  50777. static ExtrudeShape(name: string, options: {
  50778. shape: Vector3[];
  50779. path: Vector3[];
  50780. scale?: number;
  50781. rotation?: number;
  50782. cap?: number;
  50783. updatable?: boolean;
  50784. sideOrientation?: number;
  50785. frontUVs?: Vector4;
  50786. backUVs?: Vector4;
  50787. instance?: Mesh;
  50788. invertUV?: boolean;
  50789. }, scene?: Nullable<Scene>): Mesh;
  50790. /**
  50791. * Creates an custom extruded shape mesh.
  50792. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50793. * * 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.
  50794. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50795. * * 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
  50796. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50797. * * 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
  50798. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50799. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50800. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50801. * * 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
  50802. * * 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
  50803. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50804. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50805. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50806. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50807. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50808. * @param name defines the name of the mesh
  50809. * @param options defines the options used to create the mesh
  50810. * @param scene defines the hosting scene
  50811. * @returns the custom extruded shape mesh
  50812. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50813. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50814. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50815. */
  50816. static ExtrudeShapeCustom(name: string, options: {
  50817. shape: Vector3[];
  50818. path: Vector3[];
  50819. scaleFunction?: any;
  50820. rotationFunction?: any;
  50821. ribbonCloseArray?: boolean;
  50822. ribbonClosePath?: boolean;
  50823. cap?: number;
  50824. updatable?: boolean;
  50825. sideOrientation?: number;
  50826. frontUVs?: Vector4;
  50827. backUVs?: Vector4;
  50828. instance?: Mesh;
  50829. invertUV?: boolean;
  50830. }, scene: Scene): Mesh;
  50831. /**
  50832. * Creates lathe mesh.
  50833. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50834. * * 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
  50835. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50836. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50837. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50838. * * 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
  50839. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50840. * * 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
  50841. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50842. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50843. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50844. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50845. * @param name defines the name of the mesh
  50846. * @param options defines the options used to create the mesh
  50847. * @param scene defines the hosting scene
  50848. * @returns the lathe mesh
  50849. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50850. */
  50851. static CreateLathe(name: string, options: {
  50852. shape: Vector3[];
  50853. radius?: number;
  50854. tessellation?: number;
  50855. clip?: number;
  50856. arc?: number;
  50857. closed?: boolean;
  50858. updatable?: boolean;
  50859. sideOrientation?: number;
  50860. frontUVs?: Vector4;
  50861. backUVs?: Vector4;
  50862. cap?: number;
  50863. invertUV?: boolean;
  50864. }, scene: Scene): Mesh;
  50865. /**
  50866. * Creates a plane mesh
  50867. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  50868. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  50869. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  50870. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50871. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50872. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50873. * @param name defines the name of the mesh
  50874. * @param options defines the options used to create the mesh
  50875. * @param scene defines the hosting scene
  50876. * @returns the plane mesh
  50877. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  50878. */
  50879. static CreatePlane(name: string, options: {
  50880. size?: number;
  50881. width?: number;
  50882. height?: number;
  50883. sideOrientation?: number;
  50884. frontUVs?: Vector4;
  50885. backUVs?: Vector4;
  50886. updatable?: boolean;
  50887. sourcePlane?: Plane;
  50888. }, scene: Scene): Mesh;
  50889. /**
  50890. * Creates a ground mesh
  50891. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  50892. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  50893. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50894. * @param name defines the name of the mesh
  50895. * @param options defines the options used to create the mesh
  50896. * @param scene defines the hosting scene
  50897. * @returns the ground mesh
  50898. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  50899. */
  50900. static CreateGround(name: string, options: {
  50901. width?: number;
  50902. height?: number;
  50903. subdivisions?: number;
  50904. subdivisionsX?: number;
  50905. subdivisionsY?: number;
  50906. updatable?: boolean;
  50907. }, scene: any): Mesh;
  50908. /**
  50909. * Creates a tiled ground mesh
  50910. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50911. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50912. * * 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
  50913. * * 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
  50914. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50915. * @param name defines the name of the mesh
  50916. * @param options defines the options used to create the mesh
  50917. * @param scene defines the hosting scene
  50918. * @returns the tiled ground mesh
  50919. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50920. */
  50921. static CreateTiledGround(name: string, options: {
  50922. xmin: number;
  50923. zmin: number;
  50924. xmax: number;
  50925. zmax: number;
  50926. subdivisions?: {
  50927. w: number;
  50928. h: number;
  50929. };
  50930. precision?: {
  50931. w: number;
  50932. h: number;
  50933. };
  50934. updatable?: boolean;
  50935. }, scene: Scene): Mesh;
  50936. /**
  50937. * Creates a ground mesh from a height map
  50938. * * The parameter `url` sets the URL of the height map image resource.
  50939. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50940. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50941. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50942. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50943. * * 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.
  50944. * * 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).
  50945. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50946. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50947. * @param name defines the name of the mesh
  50948. * @param url defines the url to the height map
  50949. * @param options defines the options used to create the mesh
  50950. * @param scene defines the hosting scene
  50951. * @returns the ground mesh
  50952. * @see https://doc.babylonjs.com/babylon101/height_map
  50953. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50954. */
  50955. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50956. width?: number;
  50957. height?: number;
  50958. subdivisions?: number;
  50959. minHeight?: number;
  50960. maxHeight?: number;
  50961. colorFilter?: Color3;
  50962. alphaFilter?: number;
  50963. updatable?: boolean;
  50964. onReady?: (mesh: GroundMesh) => void;
  50965. }, scene: Scene): GroundMesh;
  50966. /**
  50967. * Creates a polygon mesh
  50968. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50969. * * 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
  50970. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  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. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  50973. * * Remember you can only change the shape positions, not their number when updating a polygon
  50974. * @param name defines the name of the mesh
  50975. * @param options defines the options used to create the mesh
  50976. * @param scene defines the hosting scene
  50977. * @param earcutInjection can be used to inject your own earcut reference
  50978. * @returns the polygon mesh
  50979. */
  50980. static CreatePolygon(name: string, options: {
  50981. shape: Vector3[];
  50982. holes?: Vector3[][];
  50983. depth?: number;
  50984. faceUV?: Vector4[];
  50985. faceColors?: Color4[];
  50986. updatable?: boolean;
  50987. sideOrientation?: number;
  50988. frontUVs?: Vector4;
  50989. backUVs?: Vector4;
  50990. }, scene: Scene, earcutInjection?: any): Mesh;
  50991. /**
  50992. * Creates an extruded polygon mesh, with depth in the Y direction.
  50993. * * 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)
  50994. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50995. * @param name defines the name of the mesh
  50996. * @param options defines the options used to create the mesh
  50997. * @param scene defines the hosting scene
  50998. * @param earcutInjection can be used to inject your own earcut reference
  50999. * @returns the polygon mesh
  51000. */
  51001. static ExtrudePolygon(name: string, options: {
  51002. shape: Vector3[];
  51003. holes?: Vector3[][];
  51004. depth?: number;
  51005. faceUV?: Vector4[];
  51006. faceColors?: Color4[];
  51007. updatable?: boolean;
  51008. sideOrientation?: number;
  51009. frontUVs?: Vector4;
  51010. backUVs?: Vector4;
  51011. }, scene: Scene, earcutInjection?: any): Mesh;
  51012. /**
  51013. * Creates a tube mesh.
  51014. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51015. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  51016. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  51017. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  51018. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  51019. * * 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)
  51020. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  51021. * * 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
  51022. * * 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
  51023. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51024. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51025. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51026. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51027. * @param name defines the name of the mesh
  51028. * @param options defines the options used to create the mesh
  51029. * @param scene defines the hosting scene
  51030. * @returns the tube mesh
  51031. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51032. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  51033. */
  51034. static CreateTube(name: string, options: {
  51035. path: Vector3[];
  51036. radius?: number;
  51037. tessellation?: number;
  51038. radiusFunction?: {
  51039. (i: number, distance: number): number;
  51040. };
  51041. cap?: number;
  51042. arc?: number;
  51043. updatable?: boolean;
  51044. sideOrientation?: number;
  51045. frontUVs?: Vector4;
  51046. backUVs?: Vector4;
  51047. instance?: Mesh;
  51048. invertUV?: boolean;
  51049. }, scene: Scene): Mesh;
  51050. /**
  51051. * Creates a polyhedron mesh
  51052. * * 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
  51053. * * The parameter `size` (positive float, default 1) sets the polygon size
  51054. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  51055. * * 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`
  51056. * * 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
  51057. * * 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)`)
  51058. * * 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
  51059. * * 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
  51060. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51061. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51062. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51063. * @param name defines the name of the mesh
  51064. * @param options defines the options used to create the mesh
  51065. * @param scene defines the hosting scene
  51066. * @returns the polyhedron mesh
  51067. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  51068. */
  51069. static CreatePolyhedron(name: string, options: {
  51070. type?: number;
  51071. size?: number;
  51072. sizeX?: number;
  51073. sizeY?: number;
  51074. sizeZ?: number;
  51075. custom?: any;
  51076. faceUV?: Vector4[];
  51077. faceColors?: Color4[];
  51078. flat?: boolean;
  51079. updatable?: boolean;
  51080. sideOrientation?: number;
  51081. frontUVs?: Vector4;
  51082. backUVs?: Vector4;
  51083. }, scene: Scene): Mesh;
  51084. /**
  51085. * Creates a decal mesh.
  51086. * 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
  51087. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  51088. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  51089. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  51090. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  51091. * @param name defines the name of the mesh
  51092. * @param sourceMesh defines the mesh where the decal must be applied
  51093. * @param options defines the options used to create the mesh
  51094. * @param scene defines the hosting scene
  51095. * @returns the decal mesh
  51096. * @see https://doc.babylonjs.com/how_to/decals
  51097. */
  51098. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  51099. position?: Vector3;
  51100. normal?: Vector3;
  51101. size?: Vector3;
  51102. angle?: number;
  51103. }): Mesh;
  51104. }
  51105. }
  51106. declare module "babylonjs/Meshes/meshSimplification" {
  51107. import { Mesh } from "babylonjs/Meshes/mesh";
  51108. /**
  51109. * A simplifier interface for future simplification implementations
  51110. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51111. */
  51112. export interface ISimplifier {
  51113. /**
  51114. * Simplification of a given mesh according to the given settings.
  51115. * Since this requires computation, it is assumed that the function runs async.
  51116. * @param settings The settings of the simplification, including quality and distance
  51117. * @param successCallback A callback that will be called after the mesh was simplified.
  51118. * @param errorCallback in case of an error, this callback will be called. optional.
  51119. */
  51120. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  51121. }
  51122. /**
  51123. * Expected simplification settings.
  51124. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  51125. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51126. */
  51127. export interface ISimplificationSettings {
  51128. /**
  51129. * Gets or sets the expected quality
  51130. */
  51131. quality: number;
  51132. /**
  51133. * Gets or sets the distance when this optimized version should be used
  51134. */
  51135. distance: number;
  51136. /**
  51137. * Gets an already optimized mesh
  51138. */
  51139. optimizeMesh?: boolean;
  51140. }
  51141. /**
  51142. * Class used to specify simplification options
  51143. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51144. */
  51145. export class SimplificationSettings implements ISimplificationSettings {
  51146. /** expected quality */
  51147. quality: number;
  51148. /** distance when this optimized version should be used */
  51149. distance: number;
  51150. /** already optimized mesh */
  51151. optimizeMesh?: boolean | undefined;
  51152. /**
  51153. * Creates a SimplificationSettings
  51154. * @param quality expected quality
  51155. * @param distance distance when this optimized version should be used
  51156. * @param optimizeMesh already optimized mesh
  51157. */
  51158. constructor(
  51159. /** expected quality */
  51160. quality: number,
  51161. /** distance when this optimized version should be used */
  51162. distance: number,
  51163. /** already optimized mesh */
  51164. optimizeMesh?: boolean | undefined);
  51165. }
  51166. /**
  51167. * Interface used to define a simplification task
  51168. */
  51169. export interface ISimplificationTask {
  51170. /**
  51171. * Array of settings
  51172. */
  51173. settings: Array<ISimplificationSettings>;
  51174. /**
  51175. * Simplification type
  51176. */
  51177. simplificationType: SimplificationType;
  51178. /**
  51179. * Mesh to simplify
  51180. */
  51181. mesh: Mesh;
  51182. /**
  51183. * Callback called on success
  51184. */
  51185. successCallback?: () => void;
  51186. /**
  51187. * Defines if parallel processing can be used
  51188. */
  51189. parallelProcessing: boolean;
  51190. }
  51191. /**
  51192. * Queue used to order the simplification tasks
  51193. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51194. */
  51195. export class SimplificationQueue {
  51196. private _simplificationArray;
  51197. /**
  51198. * Gets a boolean indicating that the process is still running
  51199. */
  51200. running: boolean;
  51201. /**
  51202. * Creates a new queue
  51203. */
  51204. constructor();
  51205. /**
  51206. * Adds a new simplification task
  51207. * @param task defines a task to add
  51208. */
  51209. addTask(task: ISimplificationTask): void;
  51210. /**
  51211. * Execute next task
  51212. */
  51213. executeNext(): void;
  51214. /**
  51215. * Execute a simplification task
  51216. * @param task defines the task to run
  51217. */
  51218. runSimplification(task: ISimplificationTask): void;
  51219. private getSimplifier;
  51220. }
  51221. /**
  51222. * The implemented types of simplification
  51223. * At the moment only Quadratic Error Decimation is implemented
  51224. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51225. */
  51226. export enum SimplificationType {
  51227. /** Quadratic error decimation */
  51228. QUADRATIC = 0
  51229. }
  51230. }
  51231. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  51232. import { Scene } from "babylonjs/scene";
  51233. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  51234. import { ISceneComponent } from "babylonjs/sceneComponent";
  51235. module "babylonjs/scene" {
  51236. interface Scene {
  51237. /** @hidden (Backing field) */
  51238. _simplificationQueue: SimplificationQueue;
  51239. /**
  51240. * Gets or sets the simplification queue attached to the scene
  51241. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51242. */
  51243. simplificationQueue: SimplificationQueue;
  51244. }
  51245. }
  51246. module "babylonjs/Meshes/mesh" {
  51247. interface Mesh {
  51248. /**
  51249. * Simplify the mesh according to the given array of settings.
  51250. * Function will return immediately and will simplify async
  51251. * @param settings a collection of simplification settings
  51252. * @param parallelProcessing should all levels calculate parallel or one after the other
  51253. * @param simplificationType the type of simplification to run
  51254. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  51255. * @returns the current mesh
  51256. */
  51257. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  51258. }
  51259. }
  51260. /**
  51261. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  51262. * created in a scene
  51263. */
  51264. export class SimplicationQueueSceneComponent implements ISceneComponent {
  51265. /**
  51266. * The component name helpfull to identify the component in the list of scene components.
  51267. */
  51268. readonly name: string;
  51269. /**
  51270. * The scene the component belongs to.
  51271. */
  51272. scene: Scene;
  51273. /**
  51274. * Creates a new instance of the component for the given scene
  51275. * @param scene Defines the scene to register the component in
  51276. */
  51277. constructor(scene: Scene);
  51278. /**
  51279. * Registers the component in a given scene
  51280. */
  51281. register(): void;
  51282. /**
  51283. * Rebuilds the elements related to this component in case of
  51284. * context lost for instance.
  51285. */
  51286. rebuild(): void;
  51287. /**
  51288. * Disposes the component and the associated ressources
  51289. */
  51290. dispose(): void;
  51291. private _beforeCameraUpdate;
  51292. }
  51293. }
  51294. declare module "babylonjs/Meshes/Builders/index" {
  51295. export * from "babylonjs/Meshes/Builders/boxBuilder";
  51296. export * from "babylonjs/Meshes/Builders/discBuilder";
  51297. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  51298. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  51299. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  51300. export * from "babylonjs/Meshes/Builders/torusBuilder";
  51301. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  51302. export * from "babylonjs/Meshes/Builders/linesBuilder";
  51303. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  51304. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  51305. export * from "babylonjs/Meshes/Builders/latheBuilder";
  51306. export * from "babylonjs/Meshes/Builders/planeBuilder";
  51307. export * from "babylonjs/Meshes/Builders/groundBuilder";
  51308. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  51309. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  51310. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  51311. export * from "babylonjs/Meshes/Builders/decalBuilder";
  51312. }
  51313. declare module "babylonjs/Meshes/index" {
  51314. export * from "babylonjs/Meshes/abstractMesh";
  51315. export * from "babylonjs/Meshes/buffer";
  51316. export * from "babylonjs/Meshes/Compression/index";
  51317. export * from "babylonjs/Meshes/csg";
  51318. export * from "babylonjs/Meshes/geometry";
  51319. export * from "babylonjs/Meshes/groundMesh";
  51320. export * from "babylonjs/Meshes/trailMesh";
  51321. export * from "babylonjs/Meshes/instancedMesh";
  51322. export * from "babylonjs/Meshes/linesMesh";
  51323. export * from "babylonjs/Meshes/mesh";
  51324. export * from "babylonjs/Meshes/mesh.vertexData";
  51325. export * from "babylonjs/Meshes/meshBuilder";
  51326. export * from "babylonjs/Meshes/meshSimplification";
  51327. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  51328. export * from "babylonjs/Meshes/polygonMesh";
  51329. export * from "babylonjs/Meshes/subMesh";
  51330. export * from "babylonjs/Meshes/transformNode";
  51331. export * from "babylonjs/Meshes/Builders/index";
  51332. }
  51333. declare module "babylonjs/Morph/index" {
  51334. export * from "babylonjs/Morph/morphTarget";
  51335. export * from "babylonjs/Morph/morphTargetManager";
  51336. }
  51337. declare module "babylonjs/Offline/database" {
  51338. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  51339. /**
  51340. * Class used to enable access to IndexedDB
  51341. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  51342. */
  51343. export class Database implements IOfflineProvider {
  51344. private _callbackManifestChecked;
  51345. private _currentSceneUrl;
  51346. private _db;
  51347. private _enableSceneOffline;
  51348. private _enableTexturesOffline;
  51349. private _manifestVersionFound;
  51350. private _mustUpdateRessources;
  51351. private _hasReachedQuota;
  51352. private _isSupported;
  51353. private _idbFactory;
  51354. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  51355. private static IsUASupportingBlobStorage;
  51356. /**
  51357. * Gets a boolean indicating if Database storate is enabled (off by default)
  51358. */
  51359. static IDBStorageEnabled: boolean;
  51360. /**
  51361. * Gets a boolean indicating if scene must be saved in the database
  51362. */
  51363. readonly enableSceneOffline: boolean;
  51364. /**
  51365. * Gets a boolean indicating if textures must be saved in the database
  51366. */
  51367. readonly enableTexturesOffline: boolean;
  51368. /**
  51369. * Creates a new Database
  51370. * @param urlToScene defines the url to load the scene
  51371. * @param callbackManifestChecked defines the callback to use when manifest is checked
  51372. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  51373. */
  51374. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  51375. private static _ParseURL;
  51376. private static _ReturnFullUrlLocation;
  51377. private _checkManifestFile;
  51378. /**
  51379. * Open the database and make it available
  51380. * @param successCallback defines the callback to call on success
  51381. * @param errorCallback defines the callback to call on error
  51382. */
  51383. open(successCallback: () => void, errorCallback: () => void): void;
  51384. /**
  51385. * Loads an image from the database
  51386. * @param url defines the url to load from
  51387. * @param image defines the target DOM image
  51388. */
  51389. loadImage(url: string, image: HTMLImageElement): void;
  51390. private _loadImageFromDBAsync;
  51391. private _saveImageIntoDBAsync;
  51392. private _checkVersionFromDB;
  51393. private _loadVersionFromDBAsync;
  51394. private _saveVersionIntoDBAsync;
  51395. /**
  51396. * Loads a file from database
  51397. * @param url defines the URL to load from
  51398. * @param sceneLoaded defines a callback to call on success
  51399. * @param progressCallBack defines a callback to call when progress changed
  51400. * @param errorCallback defines a callback to call on error
  51401. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  51402. */
  51403. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  51404. private _loadFileAsync;
  51405. private _saveFileAsync;
  51406. /**
  51407. * Validates if xhr data is correct
  51408. * @param xhr defines the request to validate
  51409. * @param dataType defines the expected data type
  51410. * @returns true if data is correct
  51411. */
  51412. private static _ValidateXHRData;
  51413. }
  51414. }
  51415. declare module "babylonjs/Offline/index" {
  51416. export * from "babylonjs/Offline/database";
  51417. export * from "babylonjs/Offline/IOfflineProvider";
  51418. }
  51419. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  51420. /** @hidden */
  51421. export var gpuUpdateParticlesPixelShader: {
  51422. name: string;
  51423. shader: string;
  51424. };
  51425. }
  51426. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  51427. /** @hidden */
  51428. export var gpuUpdateParticlesVertexShader: {
  51429. name: string;
  51430. shader: string;
  51431. };
  51432. }
  51433. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  51434. /** @hidden */
  51435. export var clipPlaneFragmentDeclaration2: {
  51436. name: string;
  51437. shader: string;
  51438. };
  51439. }
  51440. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  51441. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  51442. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51443. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51444. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51445. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51446. /** @hidden */
  51447. export var gpuRenderParticlesPixelShader: {
  51448. name: string;
  51449. shader: string;
  51450. };
  51451. }
  51452. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  51453. /** @hidden */
  51454. export var clipPlaneVertexDeclaration2: {
  51455. name: string;
  51456. shader: string;
  51457. };
  51458. }
  51459. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  51460. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  51461. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51462. /** @hidden */
  51463. export var gpuRenderParticlesVertexShader: {
  51464. name: string;
  51465. shader: string;
  51466. };
  51467. }
  51468. declare module "babylonjs/Particles/gpuParticleSystem" {
  51469. import { Nullable } from "babylonjs/types";
  51470. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  51471. import { Observable } from "babylonjs/Misc/observable";
  51472. import { Color4, Color3 } from "babylonjs/Maths/math";
  51473. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51474. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  51475. import { Scene, IDisposable } from "babylonjs/scene";
  51476. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  51477. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  51478. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  51479. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  51480. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  51481. /**
  51482. * This represents a GPU particle system in Babylon
  51483. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  51484. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  51485. */
  51486. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  51487. /**
  51488. * The layer mask we are rendering the particles through.
  51489. */
  51490. layerMask: number;
  51491. private _capacity;
  51492. private _activeCount;
  51493. private _currentActiveCount;
  51494. private _accumulatedCount;
  51495. private _renderEffect;
  51496. private _updateEffect;
  51497. private _buffer0;
  51498. private _buffer1;
  51499. private _spriteBuffer;
  51500. private _updateVAO;
  51501. private _renderVAO;
  51502. private _targetIndex;
  51503. private _sourceBuffer;
  51504. private _targetBuffer;
  51505. private _engine;
  51506. private _currentRenderId;
  51507. private _started;
  51508. private _stopped;
  51509. private _timeDelta;
  51510. private _randomTexture;
  51511. private _randomTexture2;
  51512. private _attributesStrideSize;
  51513. private _updateEffectOptions;
  51514. private _randomTextureSize;
  51515. private _actualFrame;
  51516. private readonly _rawTextureWidth;
  51517. /**
  51518. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  51519. */
  51520. static readonly IsSupported: boolean;
  51521. /**
  51522. * An event triggered when the system is disposed.
  51523. */
  51524. onDisposeObservable: Observable<GPUParticleSystem>;
  51525. /**
  51526. * Gets the maximum number of particles active at the same time.
  51527. * @returns The max number of active particles.
  51528. */
  51529. getCapacity(): number;
  51530. /**
  51531. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  51532. * to override the particles.
  51533. */
  51534. forceDepthWrite: boolean;
  51535. /**
  51536. * Gets or set the number of active particles
  51537. */
  51538. activeParticleCount: number;
  51539. private _preWarmDone;
  51540. /**
  51541. * Is this system ready to be used/rendered
  51542. * @return true if the system is ready
  51543. */
  51544. isReady(): boolean;
  51545. /**
  51546. * Gets if the system has been started. (Note: this will still be true after stop is called)
  51547. * @returns True if it has been started, otherwise false.
  51548. */
  51549. isStarted(): boolean;
  51550. /**
  51551. * Starts the particle system and begins to emit
  51552. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  51553. */
  51554. start(delay?: number): void;
  51555. /**
  51556. * Stops the particle system.
  51557. */
  51558. stop(): void;
  51559. /**
  51560. * Remove all active particles
  51561. */
  51562. reset(): void;
  51563. /**
  51564. * Returns the string "GPUParticleSystem"
  51565. * @returns a string containing the class name
  51566. */
  51567. getClassName(): string;
  51568. private _colorGradientsTexture;
  51569. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  51570. /**
  51571. * Adds a new color gradient
  51572. * @param gradient defines the gradient to use (between 0 and 1)
  51573. * @param color1 defines the color to affect to the specified gradient
  51574. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  51575. * @returns the current particle system
  51576. */
  51577. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  51578. /**
  51579. * Remove a specific color gradient
  51580. * @param gradient defines the gradient to remove
  51581. * @returns the current particle system
  51582. */
  51583. removeColorGradient(gradient: number): GPUParticleSystem;
  51584. private _angularSpeedGradientsTexture;
  51585. private _sizeGradientsTexture;
  51586. private _velocityGradientsTexture;
  51587. private _limitVelocityGradientsTexture;
  51588. private _dragGradientsTexture;
  51589. private _addFactorGradient;
  51590. /**
  51591. * Adds a new size gradient
  51592. * @param gradient defines the gradient to use (between 0 and 1)
  51593. * @param factor defines the size factor to affect to the specified gradient
  51594. * @returns the current particle system
  51595. */
  51596. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  51597. /**
  51598. * Remove a specific size gradient
  51599. * @param gradient defines the gradient to remove
  51600. * @returns the current particle system
  51601. */
  51602. removeSizeGradient(gradient: number): GPUParticleSystem;
  51603. /**
  51604. * Adds a new angular speed gradient
  51605. * @param gradient defines the gradient to use (between 0 and 1)
  51606. * @param factor defines the angular speed to affect to the specified gradient
  51607. * @returns the current particle system
  51608. */
  51609. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  51610. /**
  51611. * Remove a specific angular speed gradient
  51612. * @param gradient defines the gradient to remove
  51613. * @returns the current particle system
  51614. */
  51615. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  51616. /**
  51617. * Adds a new velocity gradient
  51618. * @param gradient defines the gradient to use (between 0 and 1)
  51619. * @param factor defines the velocity to affect to the specified gradient
  51620. * @returns the current particle system
  51621. */
  51622. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51623. /**
  51624. * Remove a specific velocity gradient
  51625. * @param gradient defines the gradient to remove
  51626. * @returns the current particle system
  51627. */
  51628. removeVelocityGradient(gradient: number): GPUParticleSystem;
  51629. /**
  51630. * Adds a new limit velocity gradient
  51631. * @param gradient defines the gradient to use (between 0 and 1)
  51632. * @param factor defines the limit velocity value to affect to the specified gradient
  51633. * @returns the current particle system
  51634. */
  51635. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51636. /**
  51637. * Remove a specific limit velocity gradient
  51638. * @param gradient defines the gradient to remove
  51639. * @returns the current particle system
  51640. */
  51641. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  51642. /**
  51643. * Adds a new drag gradient
  51644. * @param gradient defines the gradient to use (between 0 and 1)
  51645. * @param factor defines the drag value to affect to the specified gradient
  51646. * @returns the current particle system
  51647. */
  51648. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  51649. /**
  51650. * Remove a specific drag gradient
  51651. * @param gradient defines the gradient to remove
  51652. * @returns the current particle system
  51653. */
  51654. removeDragGradient(gradient: number): GPUParticleSystem;
  51655. /**
  51656. * Not supported by GPUParticleSystem
  51657. * @param gradient defines the gradient to use (between 0 and 1)
  51658. * @param factor defines the emit rate value to affect to the specified gradient
  51659. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51660. * @returns the current particle system
  51661. */
  51662. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51663. /**
  51664. * Not supported by GPUParticleSystem
  51665. * @param gradient defines the gradient to remove
  51666. * @returns the current particle system
  51667. */
  51668. removeEmitRateGradient(gradient: number): IParticleSystem;
  51669. /**
  51670. * Not supported by GPUParticleSystem
  51671. * @param gradient defines the gradient to use (between 0 and 1)
  51672. * @param factor defines the start size value to affect to the specified gradient
  51673. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51674. * @returns the current particle system
  51675. */
  51676. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51677. /**
  51678. * Not supported by GPUParticleSystem
  51679. * @param gradient defines the gradient to remove
  51680. * @returns the current particle system
  51681. */
  51682. removeStartSizeGradient(gradient: number): IParticleSystem;
  51683. /**
  51684. * Not supported by GPUParticleSystem
  51685. * @param gradient defines the gradient to use (between 0 and 1)
  51686. * @param min defines the color remap minimal range
  51687. * @param max defines the color remap maximal range
  51688. * @returns the current particle system
  51689. */
  51690. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51691. /**
  51692. * Not supported by GPUParticleSystem
  51693. * @param gradient defines the gradient to remove
  51694. * @returns the current particle system
  51695. */
  51696. removeColorRemapGradient(): IParticleSystem;
  51697. /**
  51698. * Not supported by GPUParticleSystem
  51699. * @param gradient defines the gradient to use (between 0 and 1)
  51700. * @param min defines the alpha remap minimal range
  51701. * @param max defines the alpha remap maximal range
  51702. * @returns the current particle system
  51703. */
  51704. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51705. /**
  51706. * Not supported by GPUParticleSystem
  51707. * @param gradient defines the gradient to remove
  51708. * @returns the current particle system
  51709. */
  51710. removeAlphaRemapGradient(): IParticleSystem;
  51711. /**
  51712. * Not supported by GPUParticleSystem
  51713. * @param gradient defines the gradient to use (between 0 and 1)
  51714. * @param color defines the color to affect to the specified gradient
  51715. * @returns the current particle system
  51716. */
  51717. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  51718. /**
  51719. * Not supported by GPUParticleSystem
  51720. * @param gradient defines the gradient to remove
  51721. * @returns the current particle system
  51722. */
  51723. removeRampGradient(): IParticleSystem;
  51724. /**
  51725. * Not supported by GPUParticleSystem
  51726. * @returns the list of ramp gradients
  51727. */
  51728. getRampGradients(): Nullable<Array<Color3Gradient>>;
  51729. /**
  51730. * Not supported by GPUParticleSystem
  51731. * Gets or sets a boolean indicating that ramp gradients must be used
  51732. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  51733. */
  51734. useRampGradients: boolean;
  51735. /**
  51736. * Not supported by GPUParticleSystem
  51737. * @param gradient defines the gradient to use (between 0 and 1)
  51738. * @param factor defines the life time factor to affect to the specified gradient
  51739. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51740. * @returns the current particle system
  51741. */
  51742. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51743. /**
  51744. * Not supported by GPUParticleSystem
  51745. * @param gradient defines the gradient to remove
  51746. * @returns the current particle system
  51747. */
  51748. removeLifeTimeGradient(gradient: number): IParticleSystem;
  51749. /**
  51750. * Instantiates a GPU particle system.
  51751. * 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.
  51752. * @param name The name of the particle system
  51753. * @param options The options used to create the system
  51754. * @param scene The scene the particle system belongs to
  51755. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  51756. */
  51757. constructor(name: string, options: Partial<{
  51758. capacity: number;
  51759. randomTextureSize: number;
  51760. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  51761. protected _reset(): void;
  51762. private _createUpdateVAO;
  51763. private _createRenderVAO;
  51764. private _initialize;
  51765. /** @hidden */
  51766. _recreateUpdateEffect(): void;
  51767. /** @hidden */
  51768. _recreateRenderEffect(): void;
  51769. /**
  51770. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  51771. * @param preWarm defines if we are in the pre-warmimg phase
  51772. */
  51773. animate(preWarm?: boolean): void;
  51774. private _createFactorGradientTexture;
  51775. private _createSizeGradientTexture;
  51776. private _createAngularSpeedGradientTexture;
  51777. private _createVelocityGradientTexture;
  51778. private _createLimitVelocityGradientTexture;
  51779. private _createDragGradientTexture;
  51780. private _createColorGradientTexture;
  51781. /**
  51782. * Renders the particle system in its current state
  51783. * @param preWarm defines if the system should only update the particles but not render them
  51784. * @returns the current number of particles
  51785. */
  51786. render(preWarm?: boolean): number;
  51787. /**
  51788. * Rebuilds the particle system
  51789. */
  51790. rebuild(): void;
  51791. private _releaseBuffers;
  51792. private _releaseVAOs;
  51793. /**
  51794. * Disposes the particle system and free the associated resources
  51795. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  51796. */
  51797. dispose(disposeTexture?: boolean): void;
  51798. /**
  51799. * Clones the particle system.
  51800. * @param name The name of the cloned object
  51801. * @param newEmitter The new emitter to use
  51802. * @returns the cloned particle system
  51803. */
  51804. clone(name: string, newEmitter: any): GPUParticleSystem;
  51805. /**
  51806. * Serializes the particle system to a JSON object.
  51807. * @returns the JSON object
  51808. */
  51809. serialize(): any;
  51810. /**
  51811. * Parses a JSON object to create a GPU particle system.
  51812. * @param parsedParticleSystem The JSON object to parse
  51813. * @param scene The scene to create the particle system in
  51814. * @param rootUrl The root url to use to load external dependencies like texture
  51815. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  51816. * @returns the parsed GPU particle system
  51817. */
  51818. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  51819. }
  51820. }
  51821. declare module "babylonjs/Particles/particleSystemSet" {
  51822. import { Nullable } from "babylonjs/types";
  51823. import { Color3 } from "babylonjs/Maths/math";
  51824. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51825. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51826. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51827. import { Scene, IDisposable } from "babylonjs/scene";
  51828. /**
  51829. * Represents a set of particle systems working together to create a specific effect
  51830. */
  51831. export class ParticleSystemSet implements IDisposable {
  51832. private _emitterCreationOptions;
  51833. private _emitterNode;
  51834. /**
  51835. * Gets the particle system list
  51836. */
  51837. systems: IParticleSystem[];
  51838. /**
  51839. * Gets the emitter node used with this set
  51840. */
  51841. readonly emitterNode: Nullable<TransformNode>;
  51842. /**
  51843. * Creates a new emitter mesh as a sphere
  51844. * @param options defines the options used to create the sphere
  51845. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  51846. * @param scene defines the hosting scene
  51847. */
  51848. setEmitterAsSphere(options: {
  51849. diameter: number;
  51850. segments: number;
  51851. color: Color3;
  51852. }, renderingGroupId: number, scene: Scene): void;
  51853. /**
  51854. * Starts all particle systems of the set
  51855. * @param emitter defines an optional mesh to use as emitter for the particle systems
  51856. */
  51857. start(emitter?: AbstractMesh): void;
  51858. /**
  51859. * Release all associated resources
  51860. */
  51861. dispose(): void;
  51862. /**
  51863. * Serialize the set into a JSON compatible object
  51864. * @returns a JSON compatible representation of the set
  51865. */
  51866. serialize(): any;
  51867. /**
  51868. * Parse a new ParticleSystemSet from a serialized source
  51869. * @param data defines a JSON compatible representation of the set
  51870. * @param scene defines the hosting scene
  51871. * @param gpu defines if we want GPU particles or CPU particles
  51872. * @returns a new ParticleSystemSet
  51873. */
  51874. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  51875. }
  51876. }
  51877. declare module "babylonjs/Particles/particleHelper" {
  51878. import { Nullable } from "babylonjs/types";
  51879. import { Scene } from "babylonjs/scene";
  51880. import { Vector3 } from "babylonjs/Maths/math";
  51881. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51882. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51883. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  51884. /**
  51885. * This class is made for on one-liner static method to help creating particle system set.
  51886. */
  51887. export class ParticleHelper {
  51888. /**
  51889. * Gets or sets base Assets URL
  51890. */
  51891. static BaseAssetsUrl: string;
  51892. /**
  51893. * Create a default particle system that you can tweak
  51894. * @param emitter defines the emitter to use
  51895. * @param capacity defines the system capacity (default is 500 particles)
  51896. * @param scene defines the hosting scene
  51897. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  51898. * @returns the new Particle system
  51899. */
  51900. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  51901. /**
  51902. * This is the main static method (one-liner) of this helper to create different particle systems
  51903. * @param type This string represents the type to the particle system to create
  51904. * @param scene The scene where the particle system should live
  51905. * @param gpu If the system will use gpu
  51906. * @returns the ParticleSystemSet created
  51907. */
  51908. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  51909. /**
  51910. * Static function used to export a particle system to a ParticleSystemSet variable.
  51911. * Please note that the emitter shape is not exported
  51912. * @param systems defines the particle systems to export
  51913. * @returns the created particle system set
  51914. */
  51915. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  51916. }
  51917. }
  51918. declare module "babylonjs/Particles/particleSystemComponent" {
  51919. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51920. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  51921. import "babylonjs/Shaders/particles.vertex";
  51922. module "babylonjs/Engines/engine" {
  51923. interface Engine {
  51924. /**
  51925. * Create an effect to use with particle systems.
  51926. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  51927. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  51928. * @param uniformsNames defines a list of attribute names
  51929. * @param samplers defines an array of string used to represent textures
  51930. * @param defines defines the string containing the defines to use to compile the shaders
  51931. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  51932. * @param onCompiled defines a function to call when the effect creation is successful
  51933. * @param onError defines a function to call when the effect creation has failed
  51934. * @returns the new Effect
  51935. */
  51936. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  51937. }
  51938. }
  51939. module "babylonjs/Meshes/mesh" {
  51940. interface Mesh {
  51941. /**
  51942. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  51943. * @returns an array of IParticleSystem
  51944. */
  51945. getEmittedParticleSystems(): IParticleSystem[];
  51946. /**
  51947. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  51948. * @returns an array of IParticleSystem
  51949. */
  51950. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  51951. }
  51952. }
  51953. /**
  51954. * @hidden
  51955. */
  51956. export var _IDoNeedToBeInTheBuild: number;
  51957. }
  51958. declare module "babylonjs/Particles/index" {
  51959. export * from "babylonjs/Particles/baseParticleSystem";
  51960. export * from "babylonjs/Particles/EmitterTypes/index";
  51961. export * from "babylonjs/Particles/gpuParticleSystem";
  51962. export * from "babylonjs/Particles/IParticleSystem";
  51963. export * from "babylonjs/Particles/particle";
  51964. export * from "babylonjs/Particles/particleHelper";
  51965. export * from "babylonjs/Particles/particleSystem";
  51966. export * from "babylonjs/Particles/particleSystemComponent";
  51967. export * from "babylonjs/Particles/particleSystemSet";
  51968. export * from "babylonjs/Particles/solidParticle";
  51969. export * from "babylonjs/Particles/solidParticleSystem";
  51970. export * from "babylonjs/Particles/subEmitter";
  51971. }
  51972. declare module "babylonjs/Physics/physicsEngineComponent" {
  51973. import { Nullable } from "babylonjs/types";
  51974. import { Observable, Observer } from "babylonjs/Misc/observable";
  51975. import { Vector3 } from "babylonjs/Maths/math";
  51976. import { Mesh } from "babylonjs/Meshes/mesh";
  51977. import { ISceneComponent } from "babylonjs/sceneComponent";
  51978. import { Scene } from "babylonjs/scene";
  51979. import { Node } from "babylonjs/node";
  51980. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51981. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51982. module "babylonjs/scene" {
  51983. interface Scene {
  51984. /** @hidden (Backing field) */
  51985. _physicsEngine: Nullable<IPhysicsEngine>;
  51986. /**
  51987. * Gets the current physics engine
  51988. * @returns a IPhysicsEngine or null if none attached
  51989. */
  51990. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  51991. /**
  51992. * Enables physics to the current scene
  51993. * @param gravity defines the scene's gravity for the physics engine
  51994. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  51995. * @return a boolean indicating if the physics engine was initialized
  51996. */
  51997. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  51998. /**
  51999. * Disables and disposes the physics engine associated with the scene
  52000. */
  52001. disablePhysicsEngine(): void;
  52002. /**
  52003. * Gets a boolean indicating if there is an active physics engine
  52004. * @returns a boolean indicating if there is an active physics engine
  52005. */
  52006. isPhysicsEnabled(): boolean;
  52007. /**
  52008. * Deletes a physics compound impostor
  52009. * @param compound defines the compound to delete
  52010. */
  52011. deleteCompoundImpostor(compound: any): void;
  52012. /**
  52013. * An event triggered when physic simulation is about to be run
  52014. */
  52015. onBeforePhysicsObservable: Observable<Scene>;
  52016. /**
  52017. * An event triggered when physic simulation has been done
  52018. */
  52019. onAfterPhysicsObservable: Observable<Scene>;
  52020. }
  52021. }
  52022. module "babylonjs/Meshes/abstractMesh" {
  52023. interface AbstractMesh {
  52024. /** @hidden */
  52025. _physicsImpostor: Nullable<PhysicsImpostor>;
  52026. /**
  52027. * Gets or sets impostor used for physic simulation
  52028. * @see http://doc.babylonjs.com/features/physics_engine
  52029. */
  52030. physicsImpostor: Nullable<PhysicsImpostor>;
  52031. /**
  52032. * Gets the current physics impostor
  52033. * @see http://doc.babylonjs.com/features/physics_engine
  52034. * @returns a physics impostor or null
  52035. */
  52036. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  52037. /** Apply a physic impulse to the mesh
  52038. * @param force defines the force to apply
  52039. * @param contactPoint defines where to apply the force
  52040. * @returns the current mesh
  52041. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  52042. */
  52043. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  52044. /**
  52045. * Creates a physic joint between two meshes
  52046. * @param otherMesh defines the other mesh to use
  52047. * @param pivot1 defines the pivot to use on this mesh
  52048. * @param pivot2 defines the pivot to use on the other mesh
  52049. * @param options defines additional options (can be plugin dependent)
  52050. * @returns the current mesh
  52051. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  52052. */
  52053. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  52054. /** @hidden */
  52055. _disposePhysicsObserver: Nullable<Observer<Node>>;
  52056. }
  52057. }
  52058. /**
  52059. * Defines the physics engine scene component responsible to manage a physics engine
  52060. */
  52061. export class PhysicsEngineSceneComponent implements ISceneComponent {
  52062. /**
  52063. * The component name helpful to identify the component in the list of scene components.
  52064. */
  52065. readonly name: string;
  52066. /**
  52067. * The scene the component belongs to.
  52068. */
  52069. scene: Scene;
  52070. /**
  52071. * Creates a new instance of the component for the given scene
  52072. * @param scene Defines the scene to register the component in
  52073. */
  52074. constructor(scene: Scene);
  52075. /**
  52076. * Registers the component in a given scene
  52077. */
  52078. register(): void;
  52079. /**
  52080. * Rebuilds the elements related to this component in case of
  52081. * context lost for instance.
  52082. */
  52083. rebuild(): void;
  52084. /**
  52085. * Disposes the component and the associated ressources
  52086. */
  52087. dispose(): void;
  52088. }
  52089. }
  52090. declare module "babylonjs/Physics/physicsHelper" {
  52091. import { Nullable } from "babylonjs/types";
  52092. import { Vector3 } from "babylonjs/Maths/math";
  52093. import { Mesh } from "babylonjs/Meshes/mesh";
  52094. import { Ray } from "babylonjs/Culling/ray";
  52095. import { Scene } from "babylonjs/scene";
  52096. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52097. /**
  52098. * A helper for physics simulations
  52099. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52100. */
  52101. export class PhysicsHelper {
  52102. private _scene;
  52103. private _physicsEngine;
  52104. /**
  52105. * Initializes the Physics helper
  52106. * @param scene Babylon.js scene
  52107. */
  52108. constructor(scene: Scene);
  52109. /**
  52110. * Applies a radial explosion impulse
  52111. * @param origin the origin of the explosion
  52112. * @param radius the explosion radius
  52113. * @param strength the explosion strength
  52114. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52115. * @returns A physics radial explosion event, or null
  52116. */
  52117. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  52118. /**
  52119. * Applies a radial explosion force
  52120. * @param origin the origin of the explosion
  52121. * @param radius the explosion radius
  52122. * @param strength the explosion strength
  52123. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52124. * @returns A physics radial explosion event, or null
  52125. */
  52126. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  52127. /**
  52128. * Creates a gravitational field
  52129. * @param origin the origin of the explosion
  52130. * @param radius the explosion radius
  52131. * @param strength the explosion strength
  52132. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52133. * @returns A physics gravitational field event, or null
  52134. */
  52135. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  52136. /**
  52137. * Creates a physics updraft event
  52138. * @param origin the origin of the updraft
  52139. * @param radius the radius of the updraft
  52140. * @param strength the strength of the updraft
  52141. * @param height the height of the updraft
  52142. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  52143. * @returns A physics updraft event, or null
  52144. */
  52145. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  52146. /**
  52147. * Creates a physics vortex event
  52148. * @param origin the of the vortex
  52149. * @param radius the radius of the vortex
  52150. * @param strength the strength of the vortex
  52151. * @param height the height of the vortex
  52152. * @returns a Physics vortex event, or null
  52153. * A physics vortex event or null
  52154. */
  52155. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  52156. }
  52157. /**
  52158. * Represents a physics radial explosion event
  52159. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52160. */
  52161. export class PhysicsRadialExplosionEvent {
  52162. private _scene;
  52163. private _sphere;
  52164. private _sphereOptions;
  52165. private _rays;
  52166. private _dataFetched;
  52167. /**
  52168. * Initializes a radial explosioin event
  52169. * @param scene BabylonJS scene
  52170. */
  52171. constructor(scene: Scene);
  52172. /**
  52173. * Returns the data related to the radial explosion event (sphere & rays).
  52174. * @returns The radial explosion event data
  52175. */
  52176. getData(): PhysicsRadialExplosionEventData;
  52177. /**
  52178. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  52179. * @param impostor A physics imposter
  52180. * @param origin the origin of the explosion
  52181. * @param radius the explosion radius
  52182. * @param strength the explosion strength
  52183. * @param falloff possible options: Constant & Linear
  52184. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  52185. */
  52186. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  52187. /**
  52188. * Disposes the sphere.
  52189. * @param force Specifies if the sphere should be disposed by force
  52190. */
  52191. dispose(force?: boolean): void;
  52192. /*** Helpers ***/
  52193. private _prepareSphere;
  52194. private _intersectsWithSphere;
  52195. }
  52196. /**
  52197. * Represents a gravitational field event
  52198. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52199. */
  52200. export class PhysicsGravitationalFieldEvent {
  52201. private _physicsHelper;
  52202. private _scene;
  52203. private _origin;
  52204. private _radius;
  52205. private _strength;
  52206. private _falloff;
  52207. private _tickCallback;
  52208. private _sphere;
  52209. private _dataFetched;
  52210. /**
  52211. * Initializes the physics gravitational field event
  52212. * @param physicsHelper A physics helper
  52213. * @param scene BabylonJS scene
  52214. * @param origin The origin position of the gravitational field event
  52215. * @param radius The radius of the gravitational field event
  52216. * @param strength The strength of the gravitational field event
  52217. * @param falloff The falloff for the gravitational field event
  52218. */
  52219. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  52220. /**
  52221. * Returns the data related to the gravitational field event (sphere).
  52222. * @returns A gravitational field event
  52223. */
  52224. getData(): PhysicsGravitationalFieldEventData;
  52225. /**
  52226. * Enables the gravitational field.
  52227. */
  52228. enable(): void;
  52229. /**
  52230. * Disables the gravitational field.
  52231. */
  52232. disable(): void;
  52233. /**
  52234. * Disposes the sphere.
  52235. * @param force The force to dispose from the gravitational field event
  52236. */
  52237. dispose(force?: boolean): void;
  52238. private _tick;
  52239. }
  52240. /**
  52241. * Represents a physics updraft event
  52242. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52243. */
  52244. export class PhysicsUpdraftEvent {
  52245. private _scene;
  52246. private _origin;
  52247. private _radius;
  52248. private _strength;
  52249. private _height;
  52250. private _updraftMode;
  52251. private _physicsEngine;
  52252. private _originTop;
  52253. private _originDirection;
  52254. private _tickCallback;
  52255. private _cylinder;
  52256. private _cylinderPosition;
  52257. private _dataFetched;
  52258. /**
  52259. * Initializes the physics updraft event
  52260. * @param _scene BabylonJS scene
  52261. * @param _origin The origin position of the updraft
  52262. * @param _radius The radius of the updraft
  52263. * @param _strength The strength of the updraft
  52264. * @param _height The height of the updraft
  52265. * @param _updraftMode The mode of the updraft
  52266. */
  52267. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  52268. /**
  52269. * Returns the data related to the updraft event (cylinder).
  52270. * @returns A physics updraft event
  52271. */
  52272. getData(): PhysicsUpdraftEventData;
  52273. /**
  52274. * Enables the updraft.
  52275. */
  52276. enable(): void;
  52277. /**
  52278. * Disables the cortex.
  52279. */
  52280. disable(): void;
  52281. /**
  52282. * Disposes the sphere.
  52283. * @param force Specifies if the updraft should be disposed by force
  52284. */
  52285. dispose(force?: boolean): void;
  52286. private getImpostorForceAndContactPoint;
  52287. private _tick;
  52288. /*** Helpers ***/
  52289. private _prepareCylinder;
  52290. private _intersectsWithCylinder;
  52291. }
  52292. /**
  52293. * Represents a physics vortex event
  52294. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52295. */
  52296. export class PhysicsVortexEvent {
  52297. private _scene;
  52298. private _origin;
  52299. private _radius;
  52300. private _strength;
  52301. private _height;
  52302. private _physicsEngine;
  52303. private _originTop;
  52304. private _centripetalForceThreshold;
  52305. private _updraftMultiplier;
  52306. private _tickCallback;
  52307. private _cylinder;
  52308. private _cylinderPosition;
  52309. private _dataFetched;
  52310. /**
  52311. * Initializes the physics vortex event
  52312. * @param _scene The BabylonJS scene
  52313. * @param _origin The origin position of the vortex
  52314. * @param _radius The radius of the vortex
  52315. * @param _strength The strength of the vortex
  52316. * @param _height The height of the vortex
  52317. */
  52318. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  52319. /**
  52320. * Returns the data related to the vortex event (cylinder).
  52321. * @returns The physics vortex event data
  52322. */
  52323. getData(): PhysicsVortexEventData;
  52324. /**
  52325. * Enables the vortex.
  52326. */
  52327. enable(): void;
  52328. /**
  52329. * Disables the cortex.
  52330. */
  52331. disable(): void;
  52332. /**
  52333. * Disposes the sphere.
  52334. * @param force
  52335. */
  52336. dispose(force?: boolean): void;
  52337. private getImpostorForceAndContactPoint;
  52338. private _tick;
  52339. /*** Helpers ***/
  52340. private _prepareCylinder;
  52341. private _intersectsWithCylinder;
  52342. }
  52343. /**
  52344. * The strenght of the force in correspondence to the distance of the affected object
  52345. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52346. */
  52347. export enum PhysicsRadialImpulseFalloff {
  52348. /** Defines that impulse is constant in strength across it's whole radius */
  52349. Constant = 0,
  52350. /** DEfines that impulse gets weaker if it's further from the origin */
  52351. Linear = 1
  52352. }
  52353. /**
  52354. * The strength of the force in correspondence to the distance of the affected object
  52355. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52356. */
  52357. export enum PhysicsUpdraftMode {
  52358. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  52359. Center = 0,
  52360. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  52361. Perpendicular = 1
  52362. }
  52363. /**
  52364. * Interface for a physics force and contact point
  52365. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52366. */
  52367. export interface PhysicsForceAndContactPoint {
  52368. /**
  52369. * The force applied at the contact point
  52370. */
  52371. force: Vector3;
  52372. /**
  52373. * The contact point
  52374. */
  52375. contactPoint: Vector3;
  52376. }
  52377. /**
  52378. * Interface for radial explosion event data
  52379. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52380. */
  52381. export interface PhysicsRadialExplosionEventData {
  52382. /**
  52383. * A sphere used for the radial explosion event
  52384. */
  52385. sphere: Mesh;
  52386. /**
  52387. * An array of rays for the radial explosion event
  52388. */
  52389. rays: Array<Ray>;
  52390. }
  52391. /**
  52392. * Interface for gravitational field event data
  52393. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52394. */
  52395. export interface PhysicsGravitationalFieldEventData {
  52396. /**
  52397. * A sphere mesh used for the gravitational field event
  52398. */
  52399. sphere: Mesh;
  52400. }
  52401. /**
  52402. * Interface for updraft event data
  52403. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52404. */
  52405. export interface PhysicsUpdraftEventData {
  52406. /**
  52407. * A cylinder used for the updraft event
  52408. */
  52409. cylinder: Mesh;
  52410. }
  52411. /**
  52412. * Interface for vortex event data
  52413. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52414. */
  52415. export interface PhysicsVortexEventData {
  52416. /**
  52417. * A cylinder used for the vortex event
  52418. */
  52419. cylinder: Mesh;
  52420. }
  52421. }
  52422. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52423. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  52424. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52425. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52426. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52427. import { Nullable } from "babylonjs/types";
  52428. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52429. /**
  52430. * AmmoJS Physics plugin
  52431. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52432. * @see https://github.com/kripken/ammo.js/
  52433. */
  52434. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52435. private _useDeltaForWorldStep;
  52436. /**
  52437. * Reference to the Ammo library
  52438. */
  52439. bjsAMMO: any;
  52440. /**
  52441. * Created ammoJS world which physics bodies are added to
  52442. */
  52443. world: any;
  52444. /**
  52445. * Name of the plugin
  52446. */
  52447. name: string;
  52448. private _timeStep;
  52449. private _fixedTimeStep;
  52450. private _maxSteps;
  52451. private _tmpQuaternion;
  52452. private _tmpAmmoTransform;
  52453. private _tmpAmmoQuaternion;
  52454. private _tmpAmmoConcreteContactResultCallback;
  52455. private _collisionConfiguration;
  52456. private _dispatcher;
  52457. private _overlappingPairCache;
  52458. private _solver;
  52459. private _tmpAmmoVectorA;
  52460. private _tmpAmmoVectorB;
  52461. private _tmpAmmoVectorC;
  52462. private _tmpContactCallbackResult;
  52463. private static readonly DISABLE_COLLISION_FLAG;
  52464. private static readonly KINEMATIC_FLAG;
  52465. private static readonly DISABLE_DEACTIVATION_FLAG;
  52466. /**
  52467. * Initializes the ammoJS plugin
  52468. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  52469. * @param ammoInjection can be used to inject your own ammo reference
  52470. */
  52471. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  52472. /**
  52473. * Sets the gravity of the physics world (m/(s^2))
  52474. * @param gravity Gravity to set
  52475. */
  52476. setGravity(gravity: Vector3): void;
  52477. /**
  52478. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  52479. * @param timeStep timestep to use in seconds
  52480. */
  52481. setTimeStep(timeStep: number): void;
  52482. /**
  52483. * 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)
  52484. * @param fixedTimeStep fixedTimeStep to use in seconds
  52485. */
  52486. setFixedTimeStep(fixedTimeStep: number): void;
  52487. /**
  52488. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  52489. * @param maxSteps the maximum number of steps by the physics engine per frame
  52490. */
  52491. setMaxSteps(maxSteps: number): void;
  52492. /**
  52493. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  52494. * @returns the current timestep in seconds
  52495. */
  52496. getTimeStep(): number;
  52497. private _isImpostorInContact;
  52498. private _isImpostorPairInContact;
  52499. private _stepSimulation;
  52500. /**
  52501. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  52502. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  52503. * After the step the babylon meshes are set to the position of the physics imposters
  52504. * @param delta amount of time to step forward
  52505. * @param impostors array of imposters to update before/after the step
  52506. */
  52507. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52508. private _tmpVector;
  52509. private _tmpMatrix;
  52510. /**
  52511. * Applies an implulse on the imposter
  52512. * @param impostor imposter to apply impulse
  52513. * @param force amount of force to be applied to the imposter
  52514. * @param contactPoint the location to apply the impulse on the imposter
  52515. */
  52516. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52517. /**
  52518. * Applies a force on the imposter
  52519. * @param impostor imposter to apply force
  52520. * @param force amount of force to be applied to the imposter
  52521. * @param contactPoint the location to apply the force on the imposter
  52522. */
  52523. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52524. /**
  52525. * Creates a physics body using the plugin
  52526. * @param impostor the imposter to create the physics body on
  52527. */
  52528. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52529. /**
  52530. * Removes the physics body from the imposter and disposes of the body's memory
  52531. * @param impostor imposter to remove the physics body from
  52532. */
  52533. removePhysicsBody(impostor: PhysicsImpostor): void;
  52534. /**
  52535. * Generates a joint
  52536. * @param impostorJoint the imposter joint to create the joint with
  52537. */
  52538. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52539. /**
  52540. * Removes a joint
  52541. * @param impostorJoint the imposter joint to remove the joint from
  52542. */
  52543. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52544. private _addMeshVerts;
  52545. private _createShape;
  52546. /**
  52547. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  52548. * @param impostor imposter containing the physics body and babylon object
  52549. */
  52550. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52551. /**
  52552. * Sets the babylon object's position/rotation from the physics body's position/rotation
  52553. * @param impostor imposter containing the physics body and babylon object
  52554. * @param newPosition new position
  52555. * @param newRotation new rotation
  52556. */
  52557. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52558. /**
  52559. * If this plugin is supported
  52560. * @returns true if its supported
  52561. */
  52562. isSupported(): boolean;
  52563. /**
  52564. * Sets the linear velocity of the physics body
  52565. * @param impostor imposter to set the velocity on
  52566. * @param velocity velocity to set
  52567. */
  52568. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52569. /**
  52570. * Sets the angular velocity of the physics body
  52571. * @param impostor imposter to set the velocity on
  52572. * @param velocity velocity to set
  52573. */
  52574. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52575. /**
  52576. * gets the linear velocity
  52577. * @param impostor imposter to get linear velocity from
  52578. * @returns linear velocity
  52579. */
  52580. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52581. /**
  52582. * gets the angular velocity
  52583. * @param impostor imposter to get angular velocity from
  52584. * @returns angular velocity
  52585. */
  52586. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52587. /**
  52588. * Sets the mass of physics body
  52589. * @param impostor imposter to set the mass on
  52590. * @param mass mass to set
  52591. */
  52592. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52593. /**
  52594. * Gets the mass of the physics body
  52595. * @param impostor imposter to get the mass from
  52596. * @returns mass
  52597. */
  52598. getBodyMass(impostor: PhysicsImpostor): number;
  52599. /**
  52600. * Gets friction of the impostor
  52601. * @param impostor impostor to get friction from
  52602. * @returns friction value
  52603. */
  52604. getBodyFriction(impostor: PhysicsImpostor): number;
  52605. /**
  52606. * Sets friction of the impostor
  52607. * @param impostor impostor to set friction on
  52608. * @param friction friction value
  52609. */
  52610. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52611. /**
  52612. * Gets restitution of the impostor
  52613. * @param impostor impostor to get restitution from
  52614. * @returns restitution value
  52615. */
  52616. getBodyRestitution(impostor: PhysicsImpostor): number;
  52617. /**
  52618. * Sets resitution of the impostor
  52619. * @param impostor impostor to set resitution on
  52620. * @param restitution resitution value
  52621. */
  52622. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52623. /**
  52624. * Sleeps the physics body and stops it from being active
  52625. * @param impostor impostor to sleep
  52626. */
  52627. sleepBody(impostor: PhysicsImpostor): void;
  52628. /**
  52629. * Activates the physics body
  52630. * @param impostor impostor to activate
  52631. */
  52632. wakeUpBody(impostor: PhysicsImpostor): void;
  52633. /**
  52634. * Updates the distance parameters of the joint
  52635. * @param joint joint to update
  52636. * @param maxDistance maximum distance of the joint
  52637. * @param minDistance minimum distance of the joint
  52638. */
  52639. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52640. /**
  52641. * Sets a motor on the joint
  52642. * @param joint joint to set motor on
  52643. * @param speed speed of the motor
  52644. * @param maxForce maximum force of the motor
  52645. * @param motorIndex index of the motor
  52646. */
  52647. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52648. /**
  52649. * Sets the motors limit
  52650. * @param joint joint to set limit on
  52651. * @param upperLimit upper limit
  52652. * @param lowerLimit lower limit
  52653. */
  52654. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52655. /**
  52656. * Syncs the position and rotation of a mesh with the impostor
  52657. * @param mesh mesh to sync
  52658. * @param impostor impostor to update the mesh with
  52659. */
  52660. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52661. /**
  52662. * Gets the radius of the impostor
  52663. * @param impostor impostor to get radius from
  52664. * @returns the radius
  52665. */
  52666. getRadius(impostor: PhysicsImpostor): number;
  52667. /**
  52668. * Gets the box size of the impostor
  52669. * @param impostor impostor to get box size from
  52670. * @param result the resulting box size
  52671. */
  52672. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52673. /**
  52674. * Disposes of the impostor
  52675. */
  52676. dispose(): void;
  52677. }
  52678. }
  52679. declare module "babylonjs/Physics/Plugins/index" {
  52680. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  52681. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  52682. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  52683. }
  52684. declare module "babylonjs/Physics/index" {
  52685. export * from "babylonjs/Physics/IPhysicsEngine";
  52686. export * from "babylonjs/Physics/physicsEngine";
  52687. export * from "babylonjs/Physics/physicsEngineComponent";
  52688. export * from "babylonjs/Physics/physicsHelper";
  52689. export * from "babylonjs/Physics/physicsImpostor";
  52690. export * from "babylonjs/Physics/physicsJoint";
  52691. export * from "babylonjs/Physics/Plugins/index";
  52692. }
  52693. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  52694. /** @hidden */
  52695. export var blackAndWhitePixelShader: {
  52696. name: string;
  52697. shader: string;
  52698. };
  52699. }
  52700. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  52701. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52702. import { Camera } from "babylonjs/Cameras/camera";
  52703. import { Engine } from "babylonjs/Engines/engine";
  52704. import "babylonjs/Shaders/blackAndWhite.fragment";
  52705. /**
  52706. * Post process used to render in black and white
  52707. */
  52708. export class BlackAndWhitePostProcess extends PostProcess {
  52709. /**
  52710. * Linear about to convert he result to black and white (default: 1)
  52711. */
  52712. degree: number;
  52713. /**
  52714. * Creates a black and white post process
  52715. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  52716. * @param name The name of the effect.
  52717. * @param options The required width/height ratio to downsize to before computing the render pass.
  52718. * @param camera The camera to apply the render pass to.
  52719. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52720. * @param engine The engine which the post process will be applied. (default: current engine)
  52721. * @param reusable If the post process can be reused on the same frame. (default: false)
  52722. */
  52723. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52724. }
  52725. }
  52726. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  52727. import { Nullable } from "babylonjs/types";
  52728. import { Camera } from "babylonjs/Cameras/camera";
  52729. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52730. import { Engine } from "babylonjs/Engines/engine";
  52731. /**
  52732. * This represents a set of one or more post processes in Babylon.
  52733. * A post process can be used to apply a shader to a texture after it is rendered.
  52734. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52735. */
  52736. export class PostProcessRenderEffect {
  52737. private _postProcesses;
  52738. private _getPostProcesses;
  52739. private _singleInstance;
  52740. private _cameras;
  52741. private _indicesForCamera;
  52742. /**
  52743. * Name of the effect
  52744. * @hidden
  52745. */
  52746. _name: string;
  52747. /**
  52748. * Instantiates a post process render effect.
  52749. * A post process can be used to apply a shader to a texture after it is rendered.
  52750. * @param engine The engine the effect is tied to
  52751. * @param name The name of the effect
  52752. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  52753. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  52754. */
  52755. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  52756. /**
  52757. * Checks if all the post processes in the effect are supported.
  52758. */
  52759. readonly isSupported: boolean;
  52760. /**
  52761. * Updates the current state of the effect
  52762. * @hidden
  52763. */
  52764. _update(): void;
  52765. /**
  52766. * Attaches the effect on cameras
  52767. * @param cameras The camera to attach to.
  52768. * @hidden
  52769. */
  52770. _attachCameras(cameras: Camera): void;
  52771. /**
  52772. * Attaches the effect on cameras
  52773. * @param cameras The camera to attach to.
  52774. * @hidden
  52775. */
  52776. _attachCameras(cameras: Camera[]): void;
  52777. /**
  52778. * Detatches the effect on cameras
  52779. * @param cameras The camera to detatch from.
  52780. * @hidden
  52781. */
  52782. _detachCameras(cameras: Camera): void;
  52783. /**
  52784. * Detatches the effect on cameras
  52785. * @param cameras The camera to detatch from.
  52786. * @hidden
  52787. */
  52788. _detachCameras(cameras: Camera[]): void;
  52789. /**
  52790. * Enables the effect on given cameras
  52791. * @param cameras The camera to enable.
  52792. * @hidden
  52793. */
  52794. _enable(cameras: Camera): void;
  52795. /**
  52796. * Enables the effect on given cameras
  52797. * @param cameras The camera to enable.
  52798. * @hidden
  52799. */
  52800. _enable(cameras: Nullable<Camera[]>): void;
  52801. /**
  52802. * Disables the effect on the given cameras
  52803. * @param cameras The camera to disable.
  52804. * @hidden
  52805. */
  52806. _disable(cameras: Camera): void;
  52807. /**
  52808. * Disables the effect on the given cameras
  52809. * @param cameras The camera to disable.
  52810. * @hidden
  52811. */
  52812. _disable(cameras: Nullable<Camera[]>): void;
  52813. /**
  52814. * Gets a list of the post processes contained in the effect.
  52815. * @param camera The camera to get the post processes on.
  52816. * @returns The list of the post processes in the effect.
  52817. */
  52818. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  52819. }
  52820. }
  52821. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  52822. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52823. /** @hidden */
  52824. export var extractHighlightsPixelShader: {
  52825. name: string;
  52826. shader: string;
  52827. };
  52828. }
  52829. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  52830. import { Nullable } from "babylonjs/types";
  52831. import { Camera } from "babylonjs/Cameras/camera";
  52832. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52833. import { Engine } from "babylonjs/Engines/engine";
  52834. import "babylonjs/Shaders/extractHighlights.fragment";
  52835. /**
  52836. * 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.
  52837. */
  52838. export class ExtractHighlightsPostProcess extends PostProcess {
  52839. /**
  52840. * The luminance threshold, pixels below this value will be set to black.
  52841. */
  52842. threshold: number;
  52843. /** @hidden */
  52844. _exposure: number;
  52845. /**
  52846. * Post process which has the input texture to be used when performing highlight extraction
  52847. * @hidden
  52848. */
  52849. _inputPostProcess: Nullable<PostProcess>;
  52850. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52851. }
  52852. }
  52853. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  52854. /** @hidden */
  52855. export var bloomMergePixelShader: {
  52856. name: string;
  52857. shader: string;
  52858. };
  52859. }
  52860. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  52861. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52862. import { Nullable } from "babylonjs/types";
  52863. import { Engine } from "babylonjs/Engines/engine";
  52864. import { Camera } from "babylonjs/Cameras/camera";
  52865. import "babylonjs/Shaders/bloomMerge.fragment";
  52866. /**
  52867. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  52868. */
  52869. export class BloomMergePostProcess extends PostProcess {
  52870. /** Weight of the bloom to be added to the original input. */
  52871. weight: number;
  52872. /**
  52873. * Creates a new instance of @see BloomMergePostProcess
  52874. * @param name The name of the effect.
  52875. * @param originalFromInput Post process which's input will be used for the merge.
  52876. * @param blurred Blurred highlights post process which's output will be used.
  52877. * @param weight Weight of the bloom to be added to the original input.
  52878. * @param options The required width/height ratio to downsize to before computing the render pass.
  52879. * @param camera The camera to apply the render pass to.
  52880. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52881. * @param engine The engine which the post process will be applied. (default: current engine)
  52882. * @param reusable If the post process can be reused on the same frame. (default: false)
  52883. * @param textureType Type of textures used when performing the post process. (default: 0)
  52884. * @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)
  52885. */
  52886. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  52887. /** Weight of the bloom to be added to the original input. */
  52888. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52889. }
  52890. }
  52891. declare module "babylonjs/PostProcesses/bloomEffect" {
  52892. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  52893. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52894. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  52895. import { Camera } from "babylonjs/Cameras/camera";
  52896. import { Scene } from "babylonjs/scene";
  52897. /**
  52898. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  52899. */
  52900. export class BloomEffect extends PostProcessRenderEffect {
  52901. private bloomScale;
  52902. /**
  52903. * @hidden Internal
  52904. */
  52905. _effects: Array<PostProcess>;
  52906. /**
  52907. * @hidden Internal
  52908. */
  52909. _downscale: ExtractHighlightsPostProcess;
  52910. private _blurX;
  52911. private _blurY;
  52912. private _merge;
  52913. /**
  52914. * The luminance threshold to find bright areas of the image to bloom.
  52915. */
  52916. threshold: number;
  52917. /**
  52918. * The strength of the bloom.
  52919. */
  52920. weight: number;
  52921. /**
  52922. * Specifies the size of the bloom blur kernel, relative to the final output size
  52923. */
  52924. kernel: number;
  52925. /**
  52926. * Creates a new instance of @see BloomEffect
  52927. * @param scene The scene the effect belongs to.
  52928. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  52929. * @param bloomKernel The size of the kernel to be used when applying the blur.
  52930. * @param bloomWeight The the strength of bloom.
  52931. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52932. * @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)
  52933. */
  52934. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  52935. /**
  52936. * Disposes each of the internal effects for a given camera.
  52937. * @param camera The camera to dispose the effect on.
  52938. */
  52939. disposeEffects(camera: Camera): void;
  52940. /**
  52941. * @hidden Internal
  52942. */
  52943. _updateEffects(): void;
  52944. /**
  52945. * Internal
  52946. * @returns if all the contained post processes are ready.
  52947. * @hidden
  52948. */
  52949. _isReady(): boolean;
  52950. }
  52951. }
  52952. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  52953. /** @hidden */
  52954. export var chromaticAberrationPixelShader: {
  52955. name: string;
  52956. shader: string;
  52957. };
  52958. }
  52959. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  52960. import { Vector2 } from "babylonjs/Maths/math";
  52961. import { Nullable } from "babylonjs/types";
  52962. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52963. import { Camera } from "babylonjs/Cameras/camera";
  52964. import { Engine } from "babylonjs/Engines/engine";
  52965. import "babylonjs/Shaders/chromaticAberration.fragment";
  52966. /**
  52967. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  52968. */
  52969. export class ChromaticAberrationPostProcess extends PostProcess {
  52970. /**
  52971. * The amount of seperation of rgb channels (default: 30)
  52972. */
  52973. aberrationAmount: number;
  52974. /**
  52975. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  52976. */
  52977. radialIntensity: number;
  52978. /**
  52979. * 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))
  52980. */
  52981. direction: Vector2;
  52982. /**
  52983. * 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))
  52984. */
  52985. centerPosition: Vector2;
  52986. /**
  52987. * Creates a new instance ChromaticAberrationPostProcess
  52988. * @param name The name of the effect.
  52989. * @param screenWidth The width of the screen to apply the effect on.
  52990. * @param screenHeight The height of the screen to apply the effect on.
  52991. * @param options The required width/height ratio to downsize to before computing the render pass.
  52992. * @param camera The camera to apply the render pass to.
  52993. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52994. * @param engine The engine which the post process will be applied. (default: current engine)
  52995. * @param reusable If the post process can be reused on the same frame. (default: false)
  52996. * @param textureType Type of textures used when performing the post process. (default: 0)
  52997. * @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)
  52998. */
  52999. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53000. }
  53001. }
  53002. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  53003. /** @hidden */
  53004. export var circleOfConfusionPixelShader: {
  53005. name: string;
  53006. shader: string;
  53007. };
  53008. }
  53009. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  53010. import { Nullable } from "babylonjs/types";
  53011. import { Engine } from "babylonjs/Engines/engine";
  53012. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53013. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53014. import { Camera } from "babylonjs/Cameras/camera";
  53015. import "babylonjs/Shaders/circleOfConfusion.fragment";
  53016. /**
  53017. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  53018. */
  53019. export class CircleOfConfusionPostProcess extends PostProcess {
  53020. /**
  53021. * 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.
  53022. */
  53023. lensSize: number;
  53024. /**
  53025. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  53026. */
  53027. fStop: number;
  53028. /**
  53029. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  53030. */
  53031. focusDistance: number;
  53032. /**
  53033. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  53034. */
  53035. focalLength: number;
  53036. private _depthTexture;
  53037. /**
  53038. * Creates a new instance CircleOfConfusionPostProcess
  53039. * @param name The name of the effect.
  53040. * @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.
  53041. * @param options The required width/height ratio to downsize to before computing the render pass.
  53042. * @param camera The camera to apply the render pass to.
  53043. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53044. * @param engine The engine which the post process will be applied. (default: current engine)
  53045. * @param reusable If the post process can be reused on the same frame. (default: false)
  53046. * @param textureType Type of textures used when performing the post process. (default: 0)
  53047. * @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)
  53048. */
  53049. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53050. /**
  53051. * 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.
  53052. */
  53053. depthTexture: RenderTargetTexture;
  53054. }
  53055. }
  53056. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  53057. /** @hidden */
  53058. export var colorCorrectionPixelShader: {
  53059. name: string;
  53060. shader: string;
  53061. };
  53062. }
  53063. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  53064. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53065. import { Engine } from "babylonjs/Engines/engine";
  53066. import { Camera } from "babylonjs/Cameras/camera";
  53067. import "babylonjs/Shaders/colorCorrection.fragment";
  53068. /**
  53069. *
  53070. * This post-process allows the modification of rendered colors by using
  53071. * a 'look-up table' (LUT). This effect is also called Color Grading.
  53072. *
  53073. * The object needs to be provided an url to a texture containing the color
  53074. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  53075. * Use an image editing software to tweak the LUT to match your needs.
  53076. *
  53077. * For an example of a color LUT, see here:
  53078. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  53079. * For explanations on color grading, see here:
  53080. * @see http://udn.epicgames.com/Three/ColorGrading.html
  53081. *
  53082. */
  53083. export class ColorCorrectionPostProcess extends PostProcess {
  53084. private _colorTableTexture;
  53085. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53086. }
  53087. }
  53088. declare module "babylonjs/Shaders/convolution.fragment" {
  53089. /** @hidden */
  53090. export var convolutionPixelShader: {
  53091. name: string;
  53092. shader: string;
  53093. };
  53094. }
  53095. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  53096. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53097. import { Nullable } from "babylonjs/types";
  53098. import { Camera } from "babylonjs/Cameras/camera";
  53099. import { Engine } from "babylonjs/Engines/engine";
  53100. import "babylonjs/Shaders/convolution.fragment";
  53101. /**
  53102. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  53103. * input texture to perform effects such as edge detection or sharpening
  53104. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  53105. */
  53106. export class ConvolutionPostProcess extends PostProcess {
  53107. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  53108. kernel: number[];
  53109. /**
  53110. * Creates a new instance ConvolutionPostProcess
  53111. * @param name The name of the effect.
  53112. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  53113. * @param options The required width/height ratio to downsize to before computing the render pass.
  53114. * @param camera The camera to apply the render pass to.
  53115. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53116. * @param engine The engine which the post process will be applied. (default: current engine)
  53117. * @param reusable If the post process can be reused on the same frame. (default: false)
  53118. * @param textureType Type of textures used when performing the post process. (default: 0)
  53119. */
  53120. constructor(name: string,
  53121. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  53122. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53123. /**
  53124. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53125. */
  53126. static EdgeDetect0Kernel: number[];
  53127. /**
  53128. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53129. */
  53130. static EdgeDetect1Kernel: number[];
  53131. /**
  53132. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53133. */
  53134. static EdgeDetect2Kernel: number[];
  53135. /**
  53136. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53137. */
  53138. static SharpenKernel: number[];
  53139. /**
  53140. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53141. */
  53142. static EmbossKernel: number[];
  53143. /**
  53144. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53145. */
  53146. static GaussianKernel: number[];
  53147. }
  53148. }
  53149. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  53150. import { Nullable } from "babylonjs/types";
  53151. import { Vector2 } from "babylonjs/Maths/math";
  53152. import { Camera } from "babylonjs/Cameras/camera";
  53153. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53154. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  53155. import { Engine } from "babylonjs/Engines/engine";
  53156. import { Scene } from "babylonjs/scene";
  53157. /**
  53158. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  53159. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  53160. * based on samples that have a large difference in distance than the center pixel.
  53161. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  53162. */
  53163. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  53164. direction: Vector2;
  53165. /**
  53166. * Creates a new instance CircleOfConfusionPostProcess
  53167. * @param name The name of the effect.
  53168. * @param scene The scene the effect belongs to.
  53169. * @param direction The direction the blur should be applied.
  53170. * @param kernel The size of the kernel used to blur.
  53171. * @param options The required width/height ratio to downsize to before computing the render pass.
  53172. * @param camera The camera to apply the render pass to.
  53173. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  53174. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  53175. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53176. * @param engine The engine which the post process will be applied. (default: current engine)
  53177. * @param reusable If the post process can be reused on the same frame. (default: false)
  53178. * @param textureType Type of textures used when performing the post process. (default: 0)
  53179. * @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)
  53180. */
  53181. 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);
  53182. }
  53183. }
  53184. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  53185. /** @hidden */
  53186. export var depthOfFieldMergePixelShader: {
  53187. name: string;
  53188. shader: string;
  53189. };
  53190. }
  53191. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  53192. import { Nullable } from "babylonjs/types";
  53193. import { Camera } from "babylonjs/Cameras/camera";
  53194. import { Effect } from "babylonjs/Materials/effect";
  53195. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53196. import { Engine } from "babylonjs/Engines/engine";
  53197. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  53198. /**
  53199. * Options to be set when merging outputs from the default pipeline.
  53200. */
  53201. export class DepthOfFieldMergePostProcessOptions {
  53202. /**
  53203. * The original image to merge on top of
  53204. */
  53205. originalFromInput: PostProcess;
  53206. /**
  53207. * Parameters to perform the merge of the depth of field effect
  53208. */
  53209. depthOfField?: {
  53210. circleOfConfusion: PostProcess;
  53211. blurSteps: Array<PostProcess>;
  53212. };
  53213. /**
  53214. * Parameters to perform the merge of bloom effect
  53215. */
  53216. bloom?: {
  53217. blurred: PostProcess;
  53218. weight: number;
  53219. };
  53220. }
  53221. /**
  53222. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  53223. */
  53224. export class DepthOfFieldMergePostProcess extends PostProcess {
  53225. private blurSteps;
  53226. /**
  53227. * Creates a new instance of DepthOfFieldMergePostProcess
  53228. * @param name The name of the effect.
  53229. * @param originalFromInput Post process which's input will be used for the merge.
  53230. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  53231. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  53232. * @param options The required width/height ratio to downsize to before computing the render pass.
  53233. * @param camera The camera to apply the render pass to.
  53234. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53235. * @param engine The engine which the post process will be applied. (default: current engine)
  53236. * @param reusable If the post process can be reused on the same frame. (default: false)
  53237. * @param textureType Type of textures used when performing the post process. (default: 0)
  53238. * @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)
  53239. */
  53240. 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);
  53241. /**
  53242. * Updates the effect with the current post process compile time values and recompiles the shader.
  53243. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  53244. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  53245. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  53246. * @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
  53247. * @param onCompiled Called when the shader has been compiled.
  53248. * @param onError Called if there is an error when compiling a shader.
  53249. */
  53250. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  53251. }
  53252. }
  53253. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  53254. import { Nullable } from "babylonjs/types";
  53255. import { Camera } from "babylonjs/Cameras/camera";
  53256. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53257. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53258. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53259. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  53260. import { Scene } from "babylonjs/scene";
  53261. /**
  53262. * Specifies the level of max blur that should be applied when using the depth of field effect
  53263. */
  53264. export enum DepthOfFieldEffectBlurLevel {
  53265. /**
  53266. * Subtle blur
  53267. */
  53268. Low = 0,
  53269. /**
  53270. * Medium blur
  53271. */
  53272. Medium = 1,
  53273. /**
  53274. * Large blur
  53275. */
  53276. High = 2
  53277. }
  53278. /**
  53279. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  53280. */
  53281. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  53282. private _circleOfConfusion;
  53283. /**
  53284. * @hidden Internal, blurs from high to low
  53285. */
  53286. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  53287. private _depthOfFieldBlurY;
  53288. private _dofMerge;
  53289. /**
  53290. * @hidden Internal post processes in depth of field effect
  53291. */
  53292. _effects: Array<PostProcess>;
  53293. /**
  53294. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  53295. */
  53296. focalLength: number;
  53297. /**
  53298. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  53299. */
  53300. fStop: number;
  53301. /**
  53302. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  53303. */
  53304. focusDistance: number;
  53305. /**
  53306. * 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.
  53307. */
  53308. lensSize: number;
  53309. /**
  53310. * Creates a new instance DepthOfFieldEffect
  53311. * @param scene The scene the effect belongs to.
  53312. * @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.
  53313. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  53314. * @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)
  53315. */
  53316. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  53317. /**
  53318. * 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.
  53319. */
  53320. depthTexture: RenderTargetTexture;
  53321. /**
  53322. * Disposes each of the internal effects for a given camera.
  53323. * @param camera The camera to dispose the effect on.
  53324. */
  53325. disposeEffects(camera: Camera): void;
  53326. /**
  53327. * @hidden Internal
  53328. */
  53329. _updateEffects(): void;
  53330. /**
  53331. * Internal
  53332. * @returns if all the contained post processes are ready.
  53333. * @hidden
  53334. */
  53335. _isReady(): boolean;
  53336. }
  53337. }
  53338. declare module "babylonjs/Shaders/displayPass.fragment" {
  53339. /** @hidden */
  53340. export var displayPassPixelShader: {
  53341. name: string;
  53342. shader: string;
  53343. };
  53344. }
  53345. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  53346. import { Nullable } from "babylonjs/types";
  53347. import { Camera } from "babylonjs/Cameras/camera";
  53348. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53349. import { Engine } from "babylonjs/Engines/engine";
  53350. import "babylonjs/Shaders/displayPass.fragment";
  53351. /**
  53352. * DisplayPassPostProcess which produces an output the same as it's input
  53353. */
  53354. export class DisplayPassPostProcess extends PostProcess {
  53355. /**
  53356. * Creates the DisplayPassPostProcess
  53357. * @param name The name of the effect.
  53358. * @param options The required width/height ratio to downsize to before computing the render pass.
  53359. * @param camera The camera to apply the render pass to.
  53360. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53361. * @param engine The engine which the post process will be applied. (default: current engine)
  53362. * @param reusable If the post process can be reused on the same frame. (default: false)
  53363. */
  53364. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53365. }
  53366. }
  53367. declare module "babylonjs/Shaders/filter.fragment" {
  53368. /** @hidden */
  53369. export var filterPixelShader: {
  53370. name: string;
  53371. shader: string;
  53372. };
  53373. }
  53374. declare module "babylonjs/PostProcesses/filterPostProcess" {
  53375. import { Nullable } from "babylonjs/types";
  53376. import { Matrix } from "babylonjs/Maths/math";
  53377. import { Camera } from "babylonjs/Cameras/camera";
  53378. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53379. import { Engine } from "babylonjs/Engines/engine";
  53380. import "babylonjs/Shaders/filter.fragment";
  53381. /**
  53382. * Applies a kernel filter to the image
  53383. */
  53384. export class FilterPostProcess extends PostProcess {
  53385. /** The matrix to be applied to the image */
  53386. kernelMatrix: Matrix;
  53387. /**
  53388. *
  53389. * @param name The name of the effect.
  53390. * @param kernelMatrix The matrix to be applied to the image
  53391. * @param options The required width/height ratio to downsize to before computing the render pass.
  53392. * @param camera The camera to apply the render pass to.
  53393. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53394. * @param engine The engine which the post process will be applied. (default: current engine)
  53395. * @param reusable If the post process can be reused on the same frame. (default: false)
  53396. */
  53397. constructor(name: string,
  53398. /** The matrix to be applied to the image */
  53399. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53400. }
  53401. }
  53402. declare module "babylonjs/Shaders/fxaa.fragment" {
  53403. /** @hidden */
  53404. export var fxaaPixelShader: {
  53405. name: string;
  53406. shader: string;
  53407. };
  53408. }
  53409. declare module "babylonjs/Shaders/fxaa.vertex" {
  53410. /** @hidden */
  53411. export var fxaaVertexShader: {
  53412. name: string;
  53413. shader: string;
  53414. };
  53415. }
  53416. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  53417. import { Nullable } from "babylonjs/types";
  53418. import { Camera } from "babylonjs/Cameras/camera";
  53419. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53420. import { Engine } from "babylonjs/Engines/engine";
  53421. import "babylonjs/Shaders/fxaa.fragment";
  53422. import "babylonjs/Shaders/fxaa.vertex";
  53423. /**
  53424. * Fxaa post process
  53425. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  53426. */
  53427. export class FxaaPostProcess extends PostProcess {
  53428. /** @hidden */
  53429. texelWidth: number;
  53430. /** @hidden */
  53431. texelHeight: number;
  53432. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53433. private _getDefines;
  53434. }
  53435. }
  53436. declare module "babylonjs/Shaders/grain.fragment" {
  53437. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53438. /** @hidden */
  53439. export var grainPixelShader: {
  53440. name: string;
  53441. shader: string;
  53442. };
  53443. }
  53444. declare module "babylonjs/PostProcesses/grainPostProcess" {
  53445. import { Nullable } from "babylonjs/types";
  53446. import { Camera } from "babylonjs/Cameras/camera";
  53447. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53448. import { Engine } from "babylonjs/Engines/engine";
  53449. import "babylonjs/Shaders/grain.fragment";
  53450. /**
  53451. * The GrainPostProcess adds noise to the image at mid luminance levels
  53452. */
  53453. export class GrainPostProcess extends PostProcess {
  53454. /**
  53455. * The intensity of the grain added (default: 30)
  53456. */
  53457. intensity: number;
  53458. /**
  53459. * If the grain should be randomized on every frame
  53460. */
  53461. animated: boolean;
  53462. /**
  53463. * Creates a new instance of @see GrainPostProcess
  53464. * @param name The name of the effect.
  53465. * @param options The required width/height ratio to downsize to before computing the render pass.
  53466. * @param camera The camera to apply the render pass to.
  53467. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53468. * @param engine The engine which the post process will be applied. (default: current engine)
  53469. * @param reusable If the post process can be reused on the same frame. (default: false)
  53470. * @param textureType Type of textures used when performing the post process. (default: 0)
  53471. * @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)
  53472. */
  53473. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53474. }
  53475. }
  53476. declare module "babylonjs/Shaders/highlights.fragment" {
  53477. /** @hidden */
  53478. export var highlightsPixelShader: {
  53479. name: string;
  53480. shader: string;
  53481. };
  53482. }
  53483. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  53484. import { Nullable } from "babylonjs/types";
  53485. import { Camera } from "babylonjs/Cameras/camera";
  53486. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53487. import { Engine } from "babylonjs/Engines/engine";
  53488. import "babylonjs/Shaders/highlights.fragment";
  53489. /**
  53490. * Extracts highlights from the image
  53491. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  53492. */
  53493. export class HighlightsPostProcess extends PostProcess {
  53494. /**
  53495. * Extracts highlights from the image
  53496. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  53497. * @param name The name of the effect.
  53498. * @param options The required width/height ratio to downsize to before computing the render pass.
  53499. * @param camera The camera to apply the render pass to.
  53500. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53501. * @param engine The engine which the post process will be applied. (default: current engine)
  53502. * @param reusable If the post process can be reused on the same frame. (default: false)
  53503. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  53504. */
  53505. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53506. }
  53507. }
  53508. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  53509. /** @hidden */
  53510. export var mrtFragmentDeclaration: {
  53511. name: string;
  53512. shader: string;
  53513. };
  53514. }
  53515. declare module "babylonjs/Shaders/geometry.fragment" {
  53516. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  53517. /** @hidden */
  53518. export var geometryPixelShader: {
  53519. name: string;
  53520. shader: string;
  53521. };
  53522. }
  53523. declare module "babylonjs/Shaders/geometry.vertex" {
  53524. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53525. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53526. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53527. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53528. /** @hidden */
  53529. export var geometryVertexShader: {
  53530. name: string;
  53531. shader: string;
  53532. };
  53533. }
  53534. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  53535. import { Matrix } from "babylonjs/Maths/math";
  53536. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53537. import { Mesh } from "babylonjs/Meshes/mesh";
  53538. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  53539. import { Effect } from "babylonjs/Materials/effect";
  53540. import { Scene } from "babylonjs/scene";
  53541. import "babylonjs/Shaders/geometry.fragment";
  53542. import "babylonjs/Shaders/geometry.vertex";
  53543. /**
  53544. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  53545. */
  53546. export class GeometryBufferRenderer {
  53547. /**
  53548. * Constant used to retrieve the position texture index in the G-Buffer textures array
  53549. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  53550. */
  53551. static readonly POSITION_TEXTURE_TYPE: number;
  53552. /**
  53553. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  53554. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  53555. */
  53556. static readonly VELOCITY_TEXTURE_TYPE: number;
  53557. /**
  53558. * Dictionary used to store the previous transformation matrices of each rendered mesh
  53559. * in order to compute objects velocities when enableVelocity is set to "true"
  53560. * @hidden
  53561. */
  53562. _previousTransformationMatrices: {
  53563. [index: number]: Matrix;
  53564. };
  53565. private _scene;
  53566. private _multiRenderTarget;
  53567. private _ratio;
  53568. private _enablePosition;
  53569. private _enableVelocity;
  53570. private _positionIndex;
  53571. private _velocityIndex;
  53572. protected _effect: Effect;
  53573. protected _cachedDefines: string;
  53574. /**
  53575. * Set the render list (meshes to be rendered) used in the G buffer.
  53576. */
  53577. renderList: Mesh[];
  53578. /**
  53579. * Gets wether or not G buffer are supported by the running hardware.
  53580. * This requires draw buffer supports
  53581. */
  53582. readonly isSupported: boolean;
  53583. /**
  53584. * Returns the index of the given texture type in the G-Buffer textures array
  53585. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  53586. * @returns the index of the given texture type in the G-Buffer textures array
  53587. */
  53588. getTextureIndex(textureType: number): number;
  53589. /**
  53590. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  53591. */
  53592. /**
  53593. * Sets whether or not objects positions are enabled for the G buffer.
  53594. */
  53595. enablePosition: boolean;
  53596. /**
  53597. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  53598. */
  53599. /**
  53600. * Sets wether or not objects velocities are enabled for the G buffer.
  53601. */
  53602. enableVelocity: boolean;
  53603. /**
  53604. * Gets the scene associated with the buffer.
  53605. */
  53606. readonly scene: Scene;
  53607. /**
  53608. * Gets the ratio used by the buffer during its creation.
  53609. * How big is the buffer related to the main canvas.
  53610. */
  53611. readonly ratio: number;
  53612. /** @hidden */
  53613. static _SceneComponentInitialization: (scene: Scene) => void;
  53614. /**
  53615. * Creates a new G Buffer for the scene
  53616. * @param scene The scene the buffer belongs to
  53617. * @param ratio How big is the buffer related to the main canvas.
  53618. */
  53619. constructor(scene: Scene, ratio?: number);
  53620. /**
  53621. * Checks wether everything is ready to render a submesh to the G buffer.
  53622. * @param subMesh the submesh to check readiness for
  53623. * @param useInstances is the mesh drawn using instance or not
  53624. * @returns true if ready otherwise false
  53625. */
  53626. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53627. /**
  53628. * Gets the current underlying G Buffer.
  53629. * @returns the buffer
  53630. */
  53631. getGBuffer(): MultiRenderTarget;
  53632. /**
  53633. * Gets the number of samples used to render the buffer (anti aliasing).
  53634. */
  53635. /**
  53636. * Sets the number of samples used to render the buffer (anti aliasing).
  53637. */
  53638. samples: number;
  53639. /**
  53640. * Disposes the renderer and frees up associated resources.
  53641. */
  53642. dispose(): void;
  53643. protected _createRenderTargets(): void;
  53644. }
  53645. }
  53646. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  53647. import { Nullable } from "babylonjs/types";
  53648. import { Scene } from "babylonjs/scene";
  53649. import { ISceneComponent } from "babylonjs/sceneComponent";
  53650. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  53651. module "babylonjs/scene" {
  53652. interface Scene {
  53653. /** @hidden (Backing field) */
  53654. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  53655. /**
  53656. * Gets or Sets the current geometry buffer associated to the scene.
  53657. */
  53658. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  53659. /**
  53660. * Enables a GeometryBufferRender and associates it with the scene
  53661. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  53662. * @returns the GeometryBufferRenderer
  53663. */
  53664. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  53665. /**
  53666. * Disables the GeometryBufferRender associated with the scene
  53667. */
  53668. disableGeometryBufferRenderer(): void;
  53669. }
  53670. }
  53671. /**
  53672. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  53673. * in several rendering techniques.
  53674. */
  53675. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  53676. /**
  53677. * The component name helpful to identify the component in the list of scene components.
  53678. */
  53679. readonly name: string;
  53680. /**
  53681. * The scene the component belongs to.
  53682. */
  53683. scene: Scene;
  53684. /**
  53685. * Creates a new instance of the component for the given scene
  53686. * @param scene Defines the scene to register the component in
  53687. */
  53688. constructor(scene: Scene);
  53689. /**
  53690. * Registers the component in a given scene
  53691. */
  53692. register(): void;
  53693. /**
  53694. * Rebuilds the elements related to this component in case of
  53695. * context lost for instance.
  53696. */
  53697. rebuild(): void;
  53698. /**
  53699. * Disposes the component and the associated ressources
  53700. */
  53701. dispose(): void;
  53702. private _gatherRenderTargets;
  53703. }
  53704. }
  53705. declare module "babylonjs/Shaders/motionBlur.fragment" {
  53706. /** @hidden */
  53707. export var motionBlurPixelShader: {
  53708. name: string;
  53709. shader: string;
  53710. };
  53711. }
  53712. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  53713. import { Nullable } from "babylonjs/types";
  53714. import { Camera } from "babylonjs/Cameras/camera";
  53715. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53716. import { Scene } from "babylonjs/scene";
  53717. import "babylonjs/Animations/animatable";
  53718. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  53719. import "babylonjs/Shaders/motionBlur.fragment";
  53720. import { Engine } from "babylonjs/Engines/engine";
  53721. /**
  53722. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  53723. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  53724. * As an example, all you have to do is to create the post-process:
  53725. * var mb = new BABYLON.MotionBlurPostProcess(
  53726. * 'mb', // The name of the effect.
  53727. * scene, // The scene containing the objects to blur according to their velocity.
  53728. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  53729. * camera // The camera to apply the render pass to.
  53730. * );
  53731. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  53732. */
  53733. export class MotionBlurPostProcess extends PostProcess {
  53734. /**
  53735. * Defines how much the image is blurred by the movement. Default value is equal to 1
  53736. */
  53737. motionStrength: number;
  53738. /**
  53739. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  53740. */
  53741. /**
  53742. * Sets the number of iterations to be used for motion blur quality
  53743. */
  53744. motionBlurSamples: number;
  53745. private _motionBlurSamples;
  53746. private _geometryBufferRenderer;
  53747. /**
  53748. * Creates a new instance MotionBlurPostProcess
  53749. * @param name The name of the effect.
  53750. * @param scene The scene containing the objects to blur according to their velocity.
  53751. * @param options The required width/height ratio to downsize to before computing the render pass.
  53752. * @param camera The camera to apply the render pass to.
  53753. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53754. * @param engine The engine which the post process will be applied. (default: current engine)
  53755. * @param reusable If the post process can be reused on the same frame. (default: false)
  53756. * @param textureType Type of textures used when performing the post process. (default: 0)
  53757. * @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)
  53758. */
  53759. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53760. /**
  53761. * Disposes the post process.
  53762. * @param camera The camera to dispose the post process on.
  53763. */
  53764. dispose(camera?: Camera): void;
  53765. }
  53766. }
  53767. declare module "babylonjs/Shaders/refraction.fragment" {
  53768. /** @hidden */
  53769. export var refractionPixelShader: {
  53770. name: string;
  53771. shader: string;
  53772. };
  53773. }
  53774. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  53775. import { Color3 } from "babylonjs/Maths/math";
  53776. import { Camera } from "babylonjs/Cameras/camera";
  53777. import { Texture } from "babylonjs/Materials/Textures/texture";
  53778. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53779. import { Engine } from "babylonjs/Engines/engine";
  53780. import "babylonjs/Shaders/refraction.fragment";
  53781. /**
  53782. * Post process which applies a refractin texture
  53783. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  53784. */
  53785. export class RefractionPostProcess extends PostProcess {
  53786. /** the base color of the refraction (used to taint the rendering) */
  53787. color: Color3;
  53788. /** simulated refraction depth */
  53789. depth: number;
  53790. /** the coefficient of the base color (0 to remove base color tainting) */
  53791. colorLevel: number;
  53792. private _refTexture;
  53793. private _ownRefractionTexture;
  53794. /**
  53795. * Gets or sets the refraction texture
  53796. * Please note that you are responsible for disposing the texture if you set it manually
  53797. */
  53798. refractionTexture: Texture;
  53799. /**
  53800. * Initializes the RefractionPostProcess
  53801. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  53802. * @param name The name of the effect.
  53803. * @param refractionTextureUrl Url of the refraction texture to use
  53804. * @param color the base color of the refraction (used to taint the rendering)
  53805. * @param depth simulated refraction depth
  53806. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  53807. * @param camera The camera to apply the render pass to.
  53808. * @param options The required width/height ratio to downsize to before computing the render pass.
  53809. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53810. * @param engine The engine which the post process will be applied. (default: current engine)
  53811. * @param reusable If the post process can be reused on the same frame. (default: false)
  53812. */
  53813. constructor(name: string, refractionTextureUrl: string,
  53814. /** the base color of the refraction (used to taint the rendering) */
  53815. color: Color3,
  53816. /** simulated refraction depth */
  53817. depth: number,
  53818. /** the coefficient of the base color (0 to remove base color tainting) */
  53819. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53820. /**
  53821. * Disposes of the post process
  53822. * @param camera Camera to dispose post process on
  53823. */
  53824. dispose(camera: Camera): void;
  53825. }
  53826. }
  53827. declare module "babylonjs/Shaders/sharpen.fragment" {
  53828. /** @hidden */
  53829. export var sharpenPixelShader: {
  53830. name: string;
  53831. shader: string;
  53832. };
  53833. }
  53834. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  53835. import { Nullable } from "babylonjs/types";
  53836. import { Camera } from "babylonjs/Cameras/camera";
  53837. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53838. import "babylonjs/Shaders/sharpen.fragment";
  53839. import { Engine } from "babylonjs/Engines/engine";
  53840. /**
  53841. * The SharpenPostProcess applies a sharpen kernel to every pixel
  53842. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  53843. */
  53844. export class SharpenPostProcess extends PostProcess {
  53845. /**
  53846. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  53847. */
  53848. colorAmount: number;
  53849. /**
  53850. * How much sharpness should be applied (default: 0.3)
  53851. */
  53852. edgeAmount: number;
  53853. /**
  53854. * Creates a new instance ConvolutionPostProcess
  53855. * @param name The name of the effect.
  53856. * @param options The required width/height ratio to downsize to before computing the render pass.
  53857. * @param camera The camera to apply the render pass to.
  53858. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53859. * @param engine The engine which the post process will be applied. (default: current engine)
  53860. * @param reusable If the post process can be reused on the same frame. (default: false)
  53861. * @param textureType Type of textures used when performing the post process. (default: 0)
  53862. * @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)
  53863. */
  53864. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53865. }
  53866. }
  53867. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  53868. import { Nullable } from "babylonjs/types";
  53869. import { Camera } from "babylonjs/Cameras/camera";
  53870. import { Engine } from "babylonjs/Engines/engine";
  53871. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53872. /**
  53873. * PostProcessRenderPipeline
  53874. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53875. */
  53876. export class PostProcessRenderPipeline {
  53877. private engine;
  53878. private _renderEffects;
  53879. private _renderEffectsForIsolatedPass;
  53880. /**
  53881. * @hidden
  53882. */
  53883. protected _cameras: Camera[];
  53884. /** @hidden */
  53885. _name: string;
  53886. /**
  53887. * Gets pipeline name
  53888. */
  53889. readonly name: string;
  53890. /**
  53891. * Initializes a PostProcessRenderPipeline
  53892. * @param engine engine to add the pipeline to
  53893. * @param name name of the pipeline
  53894. */
  53895. constructor(engine: Engine, name: string);
  53896. /**
  53897. * Gets the class name
  53898. * @returns "PostProcessRenderPipeline"
  53899. */
  53900. getClassName(): string;
  53901. /**
  53902. * If all the render effects in the pipeline are supported
  53903. */
  53904. readonly isSupported: boolean;
  53905. /**
  53906. * Adds an effect to the pipeline
  53907. * @param renderEffect the effect to add
  53908. */
  53909. addEffect(renderEffect: PostProcessRenderEffect): void;
  53910. /** @hidden */
  53911. _rebuild(): void;
  53912. /** @hidden */
  53913. _enableEffect(renderEffectName: string, cameras: Camera): void;
  53914. /** @hidden */
  53915. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  53916. /** @hidden */
  53917. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53918. /** @hidden */
  53919. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53920. /** @hidden */
  53921. _attachCameras(cameras: Camera, unique: boolean): void;
  53922. /** @hidden */
  53923. _attachCameras(cameras: Camera[], unique: boolean): void;
  53924. /** @hidden */
  53925. _detachCameras(cameras: Camera): void;
  53926. /** @hidden */
  53927. _detachCameras(cameras: Nullable<Camera[]>): void;
  53928. /** @hidden */
  53929. _update(): void;
  53930. /** @hidden */
  53931. _reset(): void;
  53932. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  53933. /**
  53934. * Disposes of the pipeline
  53935. */
  53936. dispose(): void;
  53937. }
  53938. }
  53939. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  53940. import { Camera } from "babylonjs/Cameras/camera";
  53941. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53942. /**
  53943. * PostProcessRenderPipelineManager class
  53944. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53945. */
  53946. export class PostProcessRenderPipelineManager {
  53947. private _renderPipelines;
  53948. /**
  53949. * Initializes a PostProcessRenderPipelineManager
  53950. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53951. */
  53952. constructor();
  53953. /**
  53954. * Gets the list of supported render pipelines
  53955. */
  53956. readonly supportedPipelines: PostProcessRenderPipeline[];
  53957. /**
  53958. * Adds a pipeline to the manager
  53959. * @param renderPipeline The pipeline to add
  53960. */
  53961. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  53962. /**
  53963. * Attaches a camera to the pipeline
  53964. * @param renderPipelineName The name of the pipeline to attach to
  53965. * @param cameras the camera to attach
  53966. * @param unique if the camera can be attached multiple times to the pipeline
  53967. */
  53968. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  53969. /**
  53970. * Detaches a camera from the pipeline
  53971. * @param renderPipelineName The name of the pipeline to detach from
  53972. * @param cameras the camera to detach
  53973. */
  53974. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  53975. /**
  53976. * Enables an effect by name on a pipeline
  53977. * @param renderPipelineName the name of the pipeline to enable the effect in
  53978. * @param renderEffectName the name of the effect to enable
  53979. * @param cameras the cameras that the effect should be enabled on
  53980. */
  53981. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53982. /**
  53983. * Disables an effect by name on a pipeline
  53984. * @param renderPipelineName the name of the pipeline to disable the effect in
  53985. * @param renderEffectName the name of the effect to disable
  53986. * @param cameras the cameras that the effect should be disabled on
  53987. */
  53988. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53989. /**
  53990. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  53991. */
  53992. update(): void;
  53993. /** @hidden */
  53994. _rebuild(): void;
  53995. /**
  53996. * Disposes of the manager and pipelines
  53997. */
  53998. dispose(): void;
  53999. }
  54000. }
  54001. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  54002. import { ISceneComponent } from "babylonjs/sceneComponent";
  54003. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  54004. import { Scene } from "babylonjs/scene";
  54005. module "babylonjs/scene" {
  54006. interface Scene {
  54007. /** @hidden (Backing field) */
  54008. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  54009. /**
  54010. * Gets the postprocess render pipeline manager
  54011. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54012. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  54013. */
  54014. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  54015. }
  54016. }
  54017. /**
  54018. * Defines the Render Pipeline scene component responsible to rendering pipelines
  54019. */
  54020. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  54021. /**
  54022. * The component name helpfull to identify the component in the list of scene components.
  54023. */
  54024. readonly name: string;
  54025. /**
  54026. * The scene the component belongs to.
  54027. */
  54028. scene: Scene;
  54029. /**
  54030. * Creates a new instance of the component for the given scene
  54031. * @param scene Defines the scene to register the component in
  54032. */
  54033. constructor(scene: Scene);
  54034. /**
  54035. * Registers the component in a given scene
  54036. */
  54037. register(): void;
  54038. /**
  54039. * Rebuilds the elements related to this component in case of
  54040. * context lost for instance.
  54041. */
  54042. rebuild(): void;
  54043. /**
  54044. * Disposes the component and the associated ressources
  54045. */
  54046. dispose(): void;
  54047. private _gatherRenderTargets;
  54048. }
  54049. }
  54050. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  54051. import { IAnimatable } from "babylonjs/Misc/tools";
  54052. import { Camera } from "babylonjs/Cameras/camera";
  54053. import { IDisposable } from "babylonjs/scene";
  54054. import { Scene } from "babylonjs/scene";
  54055. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  54056. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  54057. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  54058. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  54059. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  54060. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54061. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  54062. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  54063. import { Animation } from "babylonjs/Animations/animation";
  54064. /**
  54065. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  54066. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  54067. */
  54068. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  54069. private _scene;
  54070. private _camerasToBeAttached;
  54071. /**
  54072. * ID of the sharpen post process,
  54073. */
  54074. private readonly SharpenPostProcessId;
  54075. /**
  54076. * @ignore
  54077. * ID of the image processing post process;
  54078. */
  54079. readonly ImageProcessingPostProcessId: string;
  54080. /**
  54081. * @ignore
  54082. * ID of the Fast Approximate Anti-Aliasing post process;
  54083. */
  54084. readonly FxaaPostProcessId: string;
  54085. /**
  54086. * ID of the chromatic aberration post process,
  54087. */
  54088. private readonly ChromaticAberrationPostProcessId;
  54089. /**
  54090. * ID of the grain post process
  54091. */
  54092. private readonly GrainPostProcessId;
  54093. /**
  54094. * Sharpen post process which will apply a sharpen convolution to enhance edges
  54095. */
  54096. sharpen: SharpenPostProcess;
  54097. private _sharpenEffect;
  54098. private bloom;
  54099. /**
  54100. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  54101. */
  54102. depthOfField: DepthOfFieldEffect;
  54103. /**
  54104. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  54105. */
  54106. fxaa: FxaaPostProcess;
  54107. /**
  54108. * Image post processing pass used to perform operations such as tone mapping or color grading.
  54109. */
  54110. imageProcessing: ImageProcessingPostProcess;
  54111. /**
  54112. * Chromatic aberration post process which will shift rgb colors in the image
  54113. */
  54114. chromaticAberration: ChromaticAberrationPostProcess;
  54115. private _chromaticAberrationEffect;
  54116. /**
  54117. * Grain post process which add noise to the image
  54118. */
  54119. grain: GrainPostProcess;
  54120. private _grainEffect;
  54121. /**
  54122. * Glow post process which adds a glow to emissive areas of the image
  54123. */
  54124. private _glowLayer;
  54125. /**
  54126. * Animations which can be used to tweak settings over a period of time
  54127. */
  54128. animations: Animation[];
  54129. private _imageProcessingConfigurationObserver;
  54130. private _sharpenEnabled;
  54131. private _bloomEnabled;
  54132. private _depthOfFieldEnabled;
  54133. private _depthOfFieldBlurLevel;
  54134. private _fxaaEnabled;
  54135. private _imageProcessingEnabled;
  54136. private _defaultPipelineTextureType;
  54137. private _bloomScale;
  54138. private _chromaticAberrationEnabled;
  54139. private _grainEnabled;
  54140. private _buildAllowed;
  54141. /**
  54142. * Gets active scene
  54143. */
  54144. readonly scene: Scene;
  54145. /**
  54146. * Enable or disable the sharpen process from the pipeline
  54147. */
  54148. sharpenEnabled: boolean;
  54149. private _resizeObserver;
  54150. private _hardwareScaleLevel;
  54151. private _bloomKernel;
  54152. /**
  54153. * Specifies the size of the bloom blur kernel, relative to the final output size
  54154. */
  54155. bloomKernel: number;
  54156. /**
  54157. * Specifies the weight of the bloom in the final rendering
  54158. */
  54159. private _bloomWeight;
  54160. /**
  54161. * Specifies the luma threshold for the area that will be blurred by the bloom
  54162. */
  54163. private _bloomThreshold;
  54164. private _hdr;
  54165. /**
  54166. * The strength of the bloom.
  54167. */
  54168. bloomWeight: number;
  54169. /**
  54170. * The strength of the bloom.
  54171. */
  54172. bloomThreshold: number;
  54173. /**
  54174. * The scale of the bloom, lower value will provide better performance.
  54175. */
  54176. bloomScale: number;
  54177. /**
  54178. * Enable or disable the bloom from the pipeline
  54179. */
  54180. bloomEnabled: boolean;
  54181. private _rebuildBloom;
  54182. /**
  54183. * If the depth of field is enabled.
  54184. */
  54185. depthOfFieldEnabled: boolean;
  54186. /**
  54187. * Blur level of the depth of field effect. (Higher blur will effect performance)
  54188. */
  54189. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  54190. /**
  54191. * If the anti aliasing is enabled.
  54192. */
  54193. fxaaEnabled: boolean;
  54194. private _samples;
  54195. /**
  54196. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  54197. */
  54198. samples: number;
  54199. /**
  54200. * If image processing is enabled.
  54201. */
  54202. imageProcessingEnabled: boolean;
  54203. /**
  54204. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  54205. */
  54206. glowLayerEnabled: boolean;
  54207. /**
  54208. * Enable or disable the chromaticAberration process from the pipeline
  54209. */
  54210. chromaticAberrationEnabled: boolean;
  54211. /**
  54212. * Enable or disable the grain process from the pipeline
  54213. */
  54214. grainEnabled: boolean;
  54215. /**
  54216. * @constructor
  54217. * @param name - The rendering pipeline name (default: "")
  54218. * @param hdr - If high dynamic range textures should be used (default: true)
  54219. * @param scene - The scene linked to this pipeline (default: the last created scene)
  54220. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  54221. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  54222. */
  54223. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  54224. /**
  54225. * Get the class name
  54226. * @returns "DefaultRenderingPipeline"
  54227. */
  54228. getClassName(): string;
  54229. /**
  54230. * Force the compilation of the entire pipeline.
  54231. */
  54232. prepare(): void;
  54233. private _hasCleared;
  54234. private _prevPostProcess;
  54235. private _prevPrevPostProcess;
  54236. private _setAutoClearAndTextureSharing;
  54237. private _depthOfFieldSceneObserver;
  54238. private _buildPipeline;
  54239. private _disposePostProcesses;
  54240. /**
  54241. * Adds a camera to the pipeline
  54242. * @param camera the camera to be added
  54243. */
  54244. addCamera(camera: Camera): void;
  54245. /**
  54246. * Removes a camera from the pipeline
  54247. * @param camera the camera to remove
  54248. */
  54249. removeCamera(camera: Camera): void;
  54250. /**
  54251. * Dispose of the pipeline and stop all post processes
  54252. */
  54253. dispose(): void;
  54254. /**
  54255. * Serialize the rendering pipeline (Used when exporting)
  54256. * @returns the serialized object
  54257. */
  54258. serialize(): any;
  54259. /**
  54260. * Parse the serialized pipeline
  54261. * @param source Source pipeline.
  54262. * @param scene The scene to load the pipeline to.
  54263. * @param rootUrl The URL of the serialized pipeline.
  54264. * @returns An instantiated pipeline from the serialized object.
  54265. */
  54266. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  54267. }
  54268. }
  54269. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  54270. /** @hidden */
  54271. export var lensHighlightsPixelShader: {
  54272. name: string;
  54273. shader: string;
  54274. };
  54275. }
  54276. declare module "babylonjs/Shaders/depthOfField.fragment" {
  54277. /** @hidden */
  54278. export var depthOfFieldPixelShader: {
  54279. name: string;
  54280. shader: string;
  54281. };
  54282. }
  54283. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  54284. import { Camera } from "babylonjs/Cameras/camera";
  54285. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54286. import { Scene } from "babylonjs/scene";
  54287. import "babylonjs/Shaders/chromaticAberration.fragment";
  54288. import "babylonjs/Shaders/lensHighlights.fragment";
  54289. import "babylonjs/Shaders/depthOfField.fragment";
  54290. /**
  54291. * BABYLON.JS Chromatic Aberration GLSL Shader
  54292. * Author: Olivier Guyot
  54293. * Separates very slightly R, G and B colors on the edges of the screen
  54294. * Inspired by Francois Tarlier & Martins Upitis
  54295. */
  54296. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  54297. /**
  54298. * @ignore
  54299. * The chromatic aberration PostProcess id in the pipeline
  54300. */
  54301. LensChromaticAberrationEffect: string;
  54302. /**
  54303. * @ignore
  54304. * The highlights enhancing PostProcess id in the pipeline
  54305. */
  54306. HighlightsEnhancingEffect: string;
  54307. /**
  54308. * @ignore
  54309. * The depth-of-field PostProcess id in the pipeline
  54310. */
  54311. LensDepthOfFieldEffect: string;
  54312. private _scene;
  54313. private _depthTexture;
  54314. private _grainTexture;
  54315. private _chromaticAberrationPostProcess;
  54316. private _highlightsPostProcess;
  54317. private _depthOfFieldPostProcess;
  54318. private _edgeBlur;
  54319. private _grainAmount;
  54320. private _chromaticAberration;
  54321. private _distortion;
  54322. private _highlightsGain;
  54323. private _highlightsThreshold;
  54324. private _dofDistance;
  54325. private _dofAperture;
  54326. private _dofDarken;
  54327. private _dofPentagon;
  54328. private _blurNoise;
  54329. /**
  54330. * @constructor
  54331. *
  54332. * Effect parameters are as follow:
  54333. * {
  54334. * chromatic_aberration: number; // from 0 to x (1 for realism)
  54335. * edge_blur: number; // from 0 to x (1 for realism)
  54336. * distortion: number; // from 0 to x (1 for realism)
  54337. * grain_amount: number; // from 0 to 1
  54338. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  54339. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  54340. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  54341. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  54342. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  54343. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  54344. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  54345. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  54346. * }
  54347. * Note: if an effect parameter is unset, effect is disabled
  54348. *
  54349. * @param name The rendering pipeline name
  54350. * @param parameters - An object containing all parameters (see above)
  54351. * @param scene The scene linked to this pipeline
  54352. * @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)
  54353. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54354. */
  54355. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  54356. /**
  54357. * Sets the amount of blur at the edges
  54358. * @param amount blur amount
  54359. */
  54360. setEdgeBlur(amount: number): void;
  54361. /**
  54362. * Sets edge blur to 0
  54363. */
  54364. disableEdgeBlur(): void;
  54365. /**
  54366. * Sets the amout of grain
  54367. * @param amount Amount of grain
  54368. */
  54369. setGrainAmount(amount: number): void;
  54370. /**
  54371. * Set grain amount to 0
  54372. */
  54373. disableGrain(): void;
  54374. /**
  54375. * Sets the chromatic aberration amount
  54376. * @param amount amount of chromatic aberration
  54377. */
  54378. setChromaticAberration(amount: number): void;
  54379. /**
  54380. * Sets chromatic aberration amount to 0
  54381. */
  54382. disableChromaticAberration(): void;
  54383. /**
  54384. * Sets the EdgeDistortion amount
  54385. * @param amount amount of EdgeDistortion
  54386. */
  54387. setEdgeDistortion(amount: number): void;
  54388. /**
  54389. * Sets edge distortion to 0
  54390. */
  54391. disableEdgeDistortion(): void;
  54392. /**
  54393. * Sets the FocusDistance amount
  54394. * @param amount amount of FocusDistance
  54395. */
  54396. setFocusDistance(amount: number): void;
  54397. /**
  54398. * Disables depth of field
  54399. */
  54400. disableDepthOfField(): void;
  54401. /**
  54402. * Sets the Aperture amount
  54403. * @param amount amount of Aperture
  54404. */
  54405. setAperture(amount: number): void;
  54406. /**
  54407. * Sets the DarkenOutOfFocus amount
  54408. * @param amount amount of DarkenOutOfFocus
  54409. */
  54410. setDarkenOutOfFocus(amount: number): void;
  54411. /**
  54412. * Creates a pentagon bokeh effect
  54413. */
  54414. enablePentagonBokeh(): void;
  54415. /**
  54416. * Disables the pentagon bokeh effect
  54417. */
  54418. disablePentagonBokeh(): void;
  54419. /**
  54420. * Enables noise blur
  54421. */
  54422. enableNoiseBlur(): void;
  54423. /**
  54424. * Disables noise blur
  54425. */
  54426. disableNoiseBlur(): void;
  54427. /**
  54428. * Sets the HighlightsGain amount
  54429. * @param amount amount of HighlightsGain
  54430. */
  54431. setHighlightsGain(amount: number): void;
  54432. /**
  54433. * Sets the HighlightsThreshold amount
  54434. * @param amount amount of HighlightsThreshold
  54435. */
  54436. setHighlightsThreshold(amount: number): void;
  54437. /**
  54438. * Disables highlights
  54439. */
  54440. disableHighlights(): void;
  54441. /**
  54442. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  54443. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  54444. */
  54445. dispose(disableDepthRender?: boolean): void;
  54446. private _createChromaticAberrationPostProcess;
  54447. private _createHighlightsPostProcess;
  54448. private _createDepthOfFieldPostProcess;
  54449. private _createGrainTexture;
  54450. }
  54451. }
  54452. declare module "babylonjs/Shaders/ssao2.fragment" {
  54453. /** @hidden */
  54454. export var ssao2PixelShader: {
  54455. name: string;
  54456. shader: string;
  54457. };
  54458. }
  54459. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  54460. /** @hidden */
  54461. export var ssaoCombinePixelShader: {
  54462. name: string;
  54463. shader: string;
  54464. };
  54465. }
  54466. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  54467. import { Camera } from "babylonjs/Cameras/camera";
  54468. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54469. import { Scene } from "babylonjs/scene";
  54470. import "babylonjs/Shaders/ssao2.fragment";
  54471. import "babylonjs/Shaders/ssaoCombine.fragment";
  54472. /**
  54473. * Render pipeline to produce ssao effect
  54474. */
  54475. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  54476. /**
  54477. * @ignore
  54478. * The PassPostProcess id in the pipeline that contains the original scene color
  54479. */
  54480. SSAOOriginalSceneColorEffect: string;
  54481. /**
  54482. * @ignore
  54483. * The SSAO PostProcess id in the pipeline
  54484. */
  54485. SSAORenderEffect: string;
  54486. /**
  54487. * @ignore
  54488. * The horizontal blur PostProcess id in the pipeline
  54489. */
  54490. SSAOBlurHRenderEffect: string;
  54491. /**
  54492. * @ignore
  54493. * The vertical blur PostProcess id in the pipeline
  54494. */
  54495. SSAOBlurVRenderEffect: string;
  54496. /**
  54497. * @ignore
  54498. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  54499. */
  54500. SSAOCombineRenderEffect: string;
  54501. /**
  54502. * The output strength of the SSAO post-process. Default value is 1.0.
  54503. */
  54504. totalStrength: number;
  54505. /**
  54506. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  54507. */
  54508. maxZ: number;
  54509. /**
  54510. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  54511. */
  54512. minZAspect: number;
  54513. private _samples;
  54514. /**
  54515. * Number of samples used for the SSAO calculations. Default value is 8
  54516. */
  54517. samples: number;
  54518. private _textureSamples;
  54519. /**
  54520. * Number of samples to use for antialiasing
  54521. */
  54522. textureSamples: number;
  54523. /**
  54524. * Ratio object used for SSAO ratio and blur ratio
  54525. */
  54526. private _ratio;
  54527. /**
  54528. * Dynamically generated sphere sampler.
  54529. */
  54530. private _sampleSphere;
  54531. /**
  54532. * Blur filter offsets
  54533. */
  54534. private _samplerOffsets;
  54535. private _expensiveBlur;
  54536. /**
  54537. * If bilateral blur should be used
  54538. */
  54539. expensiveBlur: boolean;
  54540. /**
  54541. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  54542. */
  54543. radius: number;
  54544. /**
  54545. * The base color of the SSAO post-process
  54546. * The final result is "base + ssao" between [0, 1]
  54547. */
  54548. base: number;
  54549. /**
  54550. * Support test.
  54551. */
  54552. static readonly IsSupported: boolean;
  54553. private _scene;
  54554. private _depthTexture;
  54555. private _normalTexture;
  54556. private _randomTexture;
  54557. private _originalColorPostProcess;
  54558. private _ssaoPostProcess;
  54559. private _blurHPostProcess;
  54560. private _blurVPostProcess;
  54561. private _ssaoCombinePostProcess;
  54562. private _firstUpdate;
  54563. /**
  54564. * Gets active scene
  54565. */
  54566. readonly scene: Scene;
  54567. /**
  54568. * @constructor
  54569. * @param name The rendering pipeline name
  54570. * @param scene The scene linked to this pipeline
  54571. * @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 }
  54572. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54573. */
  54574. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  54575. /**
  54576. * Get the class name
  54577. * @returns "SSAO2RenderingPipeline"
  54578. */
  54579. getClassName(): string;
  54580. /**
  54581. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  54582. */
  54583. dispose(disableGeometryBufferRenderer?: boolean): void;
  54584. private _createBlurPostProcess;
  54585. /** @hidden */
  54586. _rebuild(): void;
  54587. private _bits;
  54588. private _radicalInverse_VdC;
  54589. private _hammersley;
  54590. private _hemisphereSample_uniform;
  54591. private _generateHemisphere;
  54592. private _createSSAOPostProcess;
  54593. private _createSSAOCombinePostProcess;
  54594. private _createRandomTexture;
  54595. /**
  54596. * Serialize the rendering pipeline (Used when exporting)
  54597. * @returns the serialized object
  54598. */
  54599. serialize(): any;
  54600. /**
  54601. * Parse the serialized pipeline
  54602. * @param source Source pipeline.
  54603. * @param scene The scene to load the pipeline to.
  54604. * @param rootUrl The URL of the serialized pipeline.
  54605. * @returns An instantiated pipeline from the serialized object.
  54606. */
  54607. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  54608. }
  54609. }
  54610. declare module "babylonjs/Shaders/ssao.fragment" {
  54611. /** @hidden */
  54612. export var ssaoPixelShader: {
  54613. name: string;
  54614. shader: string;
  54615. };
  54616. }
  54617. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  54618. import { Camera } from "babylonjs/Cameras/camera";
  54619. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54620. import { Scene } from "babylonjs/scene";
  54621. import "babylonjs/Shaders/ssao.fragment";
  54622. import "babylonjs/Shaders/ssaoCombine.fragment";
  54623. /**
  54624. * Render pipeline to produce ssao effect
  54625. */
  54626. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  54627. /**
  54628. * @ignore
  54629. * The PassPostProcess id in the pipeline that contains the original scene color
  54630. */
  54631. SSAOOriginalSceneColorEffect: string;
  54632. /**
  54633. * @ignore
  54634. * The SSAO PostProcess id in the pipeline
  54635. */
  54636. SSAORenderEffect: string;
  54637. /**
  54638. * @ignore
  54639. * The horizontal blur PostProcess id in the pipeline
  54640. */
  54641. SSAOBlurHRenderEffect: string;
  54642. /**
  54643. * @ignore
  54644. * The vertical blur PostProcess id in the pipeline
  54645. */
  54646. SSAOBlurVRenderEffect: string;
  54647. /**
  54648. * @ignore
  54649. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  54650. */
  54651. SSAOCombineRenderEffect: string;
  54652. /**
  54653. * The output strength of the SSAO post-process. Default value is 1.0.
  54654. */
  54655. totalStrength: number;
  54656. /**
  54657. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  54658. */
  54659. radius: number;
  54660. /**
  54661. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  54662. * Must not be equal to fallOff and superior to fallOff.
  54663. * Default value is 0.0075
  54664. */
  54665. area: number;
  54666. /**
  54667. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  54668. * Must not be equal to area and inferior to area.
  54669. * Default value is 0.000001
  54670. */
  54671. fallOff: number;
  54672. /**
  54673. * The base color of the SSAO post-process
  54674. * The final result is "base + ssao" between [0, 1]
  54675. */
  54676. base: number;
  54677. private _scene;
  54678. private _depthTexture;
  54679. private _randomTexture;
  54680. private _originalColorPostProcess;
  54681. private _ssaoPostProcess;
  54682. private _blurHPostProcess;
  54683. private _blurVPostProcess;
  54684. private _ssaoCombinePostProcess;
  54685. private _firstUpdate;
  54686. /**
  54687. * Gets active scene
  54688. */
  54689. readonly scene: Scene;
  54690. /**
  54691. * @constructor
  54692. * @param name - The rendering pipeline name
  54693. * @param scene - The scene linked to this pipeline
  54694. * @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 }
  54695. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  54696. */
  54697. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  54698. /**
  54699. * Get the class name
  54700. * @returns "SSAORenderingPipeline"
  54701. */
  54702. getClassName(): string;
  54703. /**
  54704. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  54705. */
  54706. dispose(disableDepthRender?: boolean): void;
  54707. private _createBlurPostProcess;
  54708. /** @hidden */
  54709. _rebuild(): void;
  54710. private _createSSAOPostProcess;
  54711. private _createSSAOCombinePostProcess;
  54712. private _createRandomTexture;
  54713. }
  54714. }
  54715. declare module "babylonjs/Shaders/standard.fragment" {
  54716. /** @hidden */
  54717. export var standardPixelShader: {
  54718. name: string;
  54719. shader: string;
  54720. };
  54721. }
  54722. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  54723. import { Nullable } from "babylonjs/types";
  54724. import { IAnimatable } from "babylonjs/Misc/tools";
  54725. import { Camera } from "babylonjs/Cameras/camera";
  54726. import { Texture } from "babylonjs/Materials/Textures/texture";
  54727. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54728. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54729. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  54730. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  54731. import { IDisposable } from "babylonjs/scene";
  54732. import { SpotLight } from "babylonjs/Lights/spotLight";
  54733. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  54734. import { Scene } from "babylonjs/scene";
  54735. import { Animation } from "babylonjs/Animations/animation";
  54736. import "babylonjs/Shaders/standard.fragment";
  54737. /**
  54738. * Standard rendering pipeline
  54739. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  54740. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  54741. */
  54742. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  54743. /**
  54744. * Public members
  54745. */
  54746. /**
  54747. * Post-process which contains the original scene color before the pipeline applies all the effects
  54748. */
  54749. originalPostProcess: Nullable<PostProcess>;
  54750. /**
  54751. * Post-process used to down scale an image x4
  54752. */
  54753. downSampleX4PostProcess: Nullable<PostProcess>;
  54754. /**
  54755. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  54756. */
  54757. brightPassPostProcess: Nullable<PostProcess>;
  54758. /**
  54759. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  54760. */
  54761. blurHPostProcesses: PostProcess[];
  54762. /**
  54763. * Post-process array storing all the vertical blur post-processes used by the pipeline
  54764. */
  54765. blurVPostProcesses: PostProcess[];
  54766. /**
  54767. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  54768. */
  54769. textureAdderPostProcess: Nullable<PostProcess>;
  54770. /**
  54771. * Post-process used to create volumetric lighting effect
  54772. */
  54773. volumetricLightPostProcess: Nullable<PostProcess>;
  54774. /**
  54775. * Post-process used to smooth the previous volumetric light post-process on the X axis
  54776. */
  54777. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  54778. /**
  54779. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  54780. */
  54781. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  54782. /**
  54783. * Post-process used to merge the volumetric light effect and the real scene color
  54784. */
  54785. volumetricLightMergePostProces: Nullable<PostProcess>;
  54786. /**
  54787. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  54788. */
  54789. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  54790. /**
  54791. * Base post-process used to calculate the average luminance of the final image for HDR
  54792. */
  54793. luminancePostProcess: Nullable<PostProcess>;
  54794. /**
  54795. * Post-processes used to create down sample post-processes in order to get
  54796. * the average luminance of the final image for HDR
  54797. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  54798. */
  54799. luminanceDownSamplePostProcesses: PostProcess[];
  54800. /**
  54801. * Post-process used to create a HDR effect (light adaptation)
  54802. */
  54803. hdrPostProcess: Nullable<PostProcess>;
  54804. /**
  54805. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  54806. */
  54807. textureAdderFinalPostProcess: Nullable<PostProcess>;
  54808. /**
  54809. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  54810. */
  54811. lensFlareFinalPostProcess: Nullable<PostProcess>;
  54812. /**
  54813. * Post-process used to merge the final HDR post-process and the real scene color
  54814. */
  54815. hdrFinalPostProcess: Nullable<PostProcess>;
  54816. /**
  54817. * Post-process used to create a lens flare effect
  54818. */
  54819. lensFlarePostProcess: Nullable<PostProcess>;
  54820. /**
  54821. * Post-process that merges the result of the lens flare post-process and the real scene color
  54822. */
  54823. lensFlareComposePostProcess: Nullable<PostProcess>;
  54824. /**
  54825. * Post-process used to create a motion blur effect
  54826. */
  54827. motionBlurPostProcess: Nullable<PostProcess>;
  54828. /**
  54829. * Post-process used to create a depth of field effect
  54830. */
  54831. depthOfFieldPostProcess: Nullable<PostProcess>;
  54832. /**
  54833. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  54834. */
  54835. fxaaPostProcess: Nullable<FxaaPostProcess>;
  54836. /**
  54837. * Represents the brightness threshold in order to configure the illuminated surfaces
  54838. */
  54839. brightThreshold: number;
  54840. /**
  54841. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  54842. */
  54843. blurWidth: number;
  54844. /**
  54845. * Sets if the blur for highlighted surfaces must be only horizontal
  54846. */
  54847. horizontalBlur: boolean;
  54848. /**
  54849. * Sets the overall exposure used by the pipeline
  54850. */
  54851. exposure: number;
  54852. /**
  54853. * Texture used typically to simulate "dirty" on camera lens
  54854. */
  54855. lensTexture: Nullable<Texture>;
  54856. /**
  54857. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  54858. */
  54859. volumetricLightCoefficient: number;
  54860. /**
  54861. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  54862. */
  54863. volumetricLightPower: number;
  54864. /**
  54865. * Used the set the blur intensity to smooth the volumetric lights
  54866. */
  54867. volumetricLightBlurScale: number;
  54868. /**
  54869. * Light (spot or directional) used to generate the volumetric lights rays
  54870. * The source light must have a shadow generate so the pipeline can get its
  54871. * depth map
  54872. */
  54873. sourceLight: Nullable<SpotLight | DirectionalLight>;
  54874. /**
  54875. * For eye adaptation, represents the minimum luminance the eye can see
  54876. */
  54877. hdrMinimumLuminance: number;
  54878. /**
  54879. * For eye adaptation, represents the decrease luminance speed
  54880. */
  54881. hdrDecreaseRate: number;
  54882. /**
  54883. * For eye adaptation, represents the increase luminance speed
  54884. */
  54885. hdrIncreaseRate: number;
  54886. /**
  54887. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  54888. */
  54889. lensColorTexture: Nullable<Texture>;
  54890. /**
  54891. * The overall strengh for the lens flare effect
  54892. */
  54893. lensFlareStrength: number;
  54894. /**
  54895. * Dispersion coefficient for lens flare ghosts
  54896. */
  54897. lensFlareGhostDispersal: number;
  54898. /**
  54899. * Main lens flare halo width
  54900. */
  54901. lensFlareHaloWidth: number;
  54902. /**
  54903. * Based on the lens distortion effect, defines how much the lens flare result
  54904. * is distorted
  54905. */
  54906. lensFlareDistortionStrength: number;
  54907. /**
  54908. * Lens star texture must be used to simulate rays on the flares and is available
  54909. * in the documentation
  54910. */
  54911. lensStarTexture: Nullable<Texture>;
  54912. /**
  54913. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  54914. * flare effect by taking account of the dirt texture
  54915. */
  54916. lensFlareDirtTexture: Nullable<Texture>;
  54917. /**
  54918. * Represents the focal length for the depth of field effect
  54919. */
  54920. depthOfFieldDistance: number;
  54921. /**
  54922. * Represents the blur intensity for the blurred part of the depth of field effect
  54923. */
  54924. depthOfFieldBlurWidth: number;
  54925. /**
  54926. * For motion blur, defines how much the image is blurred by the movement
  54927. */
  54928. motionStrength: number;
  54929. /**
  54930. * List of animations for the pipeline (IAnimatable implementation)
  54931. */
  54932. animations: Animation[];
  54933. /**
  54934. * Private members
  54935. */
  54936. private _scene;
  54937. private _currentDepthOfFieldSource;
  54938. private _basePostProcess;
  54939. private _hdrCurrentLuminance;
  54940. private _floatTextureType;
  54941. private _ratio;
  54942. private _bloomEnabled;
  54943. private _depthOfFieldEnabled;
  54944. private _vlsEnabled;
  54945. private _lensFlareEnabled;
  54946. private _hdrEnabled;
  54947. private _motionBlurEnabled;
  54948. private _fxaaEnabled;
  54949. private _motionBlurSamples;
  54950. private _volumetricLightStepsCount;
  54951. private _samples;
  54952. /**
  54953. * @ignore
  54954. * Specifies if the bloom pipeline is enabled
  54955. */
  54956. BloomEnabled: boolean;
  54957. /**
  54958. * @ignore
  54959. * Specifies if the depth of field pipeline is enabed
  54960. */
  54961. DepthOfFieldEnabled: boolean;
  54962. /**
  54963. * @ignore
  54964. * Specifies if the lens flare pipeline is enabed
  54965. */
  54966. LensFlareEnabled: boolean;
  54967. /**
  54968. * @ignore
  54969. * Specifies if the HDR pipeline is enabled
  54970. */
  54971. HDREnabled: boolean;
  54972. /**
  54973. * @ignore
  54974. * Specifies if the volumetric lights scattering effect is enabled
  54975. */
  54976. VLSEnabled: boolean;
  54977. /**
  54978. * @ignore
  54979. * Specifies if the motion blur effect is enabled
  54980. */
  54981. MotionBlurEnabled: boolean;
  54982. /**
  54983. * Specifies if anti-aliasing is enabled
  54984. */
  54985. fxaaEnabled: boolean;
  54986. /**
  54987. * Specifies the number of steps used to calculate the volumetric lights
  54988. * Typically in interval [50, 200]
  54989. */
  54990. volumetricLightStepsCount: number;
  54991. /**
  54992. * Specifies the number of samples used for the motion blur effect
  54993. * Typically in interval [16, 64]
  54994. */
  54995. motionBlurSamples: number;
  54996. /**
  54997. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  54998. */
  54999. samples: number;
  55000. /**
  55001. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  55002. * @constructor
  55003. * @param name The rendering pipeline name
  55004. * @param scene The scene linked to this pipeline
  55005. * @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)
  55006. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  55007. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55008. */
  55009. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  55010. private _buildPipeline;
  55011. private _createDownSampleX4PostProcess;
  55012. private _createBrightPassPostProcess;
  55013. private _createBlurPostProcesses;
  55014. private _createTextureAdderPostProcess;
  55015. private _createVolumetricLightPostProcess;
  55016. private _createLuminancePostProcesses;
  55017. private _createHdrPostProcess;
  55018. private _createLensFlarePostProcess;
  55019. private _createDepthOfFieldPostProcess;
  55020. private _createMotionBlurPostProcess;
  55021. private _getDepthTexture;
  55022. private _disposePostProcesses;
  55023. /**
  55024. * Dispose of the pipeline and stop all post processes
  55025. */
  55026. dispose(): void;
  55027. /**
  55028. * Serialize the rendering pipeline (Used when exporting)
  55029. * @returns the serialized object
  55030. */
  55031. serialize(): any;
  55032. /**
  55033. * Parse the serialized pipeline
  55034. * @param source Source pipeline.
  55035. * @param scene The scene to load the pipeline to.
  55036. * @param rootUrl The URL of the serialized pipeline.
  55037. * @returns An instantiated pipeline from the serialized object.
  55038. */
  55039. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  55040. /**
  55041. * Luminance steps
  55042. */
  55043. static LuminanceSteps: number;
  55044. }
  55045. }
  55046. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  55047. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  55048. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  55049. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  55050. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  55051. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  55052. }
  55053. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  55054. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  55055. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55056. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55057. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  55058. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  55059. }
  55060. declare module "babylonjs/Shaders/tonemap.fragment" {
  55061. /** @hidden */
  55062. export var tonemapPixelShader: {
  55063. name: string;
  55064. shader: string;
  55065. };
  55066. }
  55067. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  55068. import { Camera } from "babylonjs/Cameras/camera";
  55069. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55070. import "babylonjs/Shaders/tonemap.fragment";
  55071. import { Engine } from "babylonjs/Engines/engine";
  55072. /** Defines operator used for tonemapping */
  55073. export enum TonemappingOperator {
  55074. /** Hable */
  55075. Hable = 0,
  55076. /** Reinhard */
  55077. Reinhard = 1,
  55078. /** HejiDawson */
  55079. HejiDawson = 2,
  55080. /** Photographic */
  55081. Photographic = 3
  55082. }
  55083. /**
  55084. * Defines a post process to apply tone mapping
  55085. */
  55086. export class TonemapPostProcess extends PostProcess {
  55087. private _operator;
  55088. /** Defines the required exposure adjustement */
  55089. exposureAdjustment: number;
  55090. /**
  55091. * Creates a new TonemapPostProcess
  55092. * @param name defines the name of the postprocess
  55093. * @param _operator defines the operator to use
  55094. * @param exposureAdjustment defines the required exposure adjustement
  55095. * @param camera defines the camera to use (can be null)
  55096. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  55097. * @param engine defines the hosting engine (can be ignore if camera is set)
  55098. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  55099. */
  55100. constructor(name: string, _operator: TonemappingOperator,
  55101. /** Defines the required exposure adjustement */
  55102. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  55103. }
  55104. }
  55105. declare module "babylonjs/Shaders/depth.vertex" {
  55106. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55107. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55108. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55109. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55110. /** @hidden */
  55111. export var depthVertexShader: {
  55112. name: string;
  55113. shader: string;
  55114. };
  55115. }
  55116. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  55117. /** @hidden */
  55118. export var volumetricLightScatteringPixelShader: {
  55119. name: string;
  55120. shader: string;
  55121. };
  55122. }
  55123. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  55124. /** @hidden */
  55125. export var volumetricLightScatteringPassPixelShader: {
  55126. name: string;
  55127. shader: string;
  55128. };
  55129. }
  55130. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  55131. import { Vector3 } from "babylonjs/Maths/math";
  55132. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55133. import { Mesh } from "babylonjs/Meshes/mesh";
  55134. import { Camera } from "babylonjs/Cameras/camera";
  55135. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55136. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55137. import { Scene } from "babylonjs/scene";
  55138. import "babylonjs/Meshes/Builders/planeBuilder";
  55139. import "babylonjs/Shaders/depth.vertex";
  55140. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  55141. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  55142. import { Engine } from "babylonjs/Engines/engine";
  55143. /**
  55144. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  55145. */
  55146. export class VolumetricLightScatteringPostProcess extends PostProcess {
  55147. private _volumetricLightScatteringPass;
  55148. private _volumetricLightScatteringRTT;
  55149. private _viewPort;
  55150. private _screenCoordinates;
  55151. private _cachedDefines;
  55152. /**
  55153. * If not undefined, the mesh position is computed from the attached node position
  55154. */
  55155. attachedNode: {
  55156. position: Vector3;
  55157. };
  55158. /**
  55159. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  55160. */
  55161. customMeshPosition: Vector3;
  55162. /**
  55163. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  55164. */
  55165. useCustomMeshPosition: boolean;
  55166. /**
  55167. * If the post-process should inverse the light scattering direction
  55168. */
  55169. invert: boolean;
  55170. /**
  55171. * The internal mesh used by the post-process
  55172. */
  55173. mesh: Mesh;
  55174. /**
  55175. * @hidden
  55176. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  55177. */
  55178. useDiffuseColor: boolean;
  55179. /**
  55180. * Array containing the excluded meshes not rendered in the internal pass
  55181. */
  55182. excludedMeshes: AbstractMesh[];
  55183. /**
  55184. * Controls the overall intensity of the post-process
  55185. */
  55186. exposure: number;
  55187. /**
  55188. * Dissipates each sample's contribution in range [0, 1]
  55189. */
  55190. decay: number;
  55191. /**
  55192. * Controls the overall intensity of each sample
  55193. */
  55194. weight: number;
  55195. /**
  55196. * Controls the density of each sample
  55197. */
  55198. density: number;
  55199. /**
  55200. * @constructor
  55201. * @param name The post-process name
  55202. * @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)
  55203. * @param camera The camera that the post-process will be attached to
  55204. * @param mesh The mesh used to create the light scattering
  55205. * @param samples The post-process quality, default 100
  55206. * @param samplingModeThe post-process filtering mode
  55207. * @param engine The babylon engine
  55208. * @param reusable If the post-process is reusable
  55209. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  55210. */
  55211. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  55212. /**
  55213. * Returns the string "VolumetricLightScatteringPostProcess"
  55214. * @returns "VolumetricLightScatteringPostProcess"
  55215. */
  55216. getClassName(): string;
  55217. private _isReady;
  55218. /**
  55219. * Sets the new light position for light scattering effect
  55220. * @param position The new custom light position
  55221. */
  55222. setCustomMeshPosition(position: Vector3): void;
  55223. /**
  55224. * Returns the light position for light scattering effect
  55225. * @return Vector3 The custom light position
  55226. */
  55227. getCustomMeshPosition(): Vector3;
  55228. /**
  55229. * Disposes the internal assets and detaches the post-process from the camera
  55230. */
  55231. dispose(camera: Camera): void;
  55232. /**
  55233. * Returns the render target texture used by the post-process
  55234. * @return the render target texture used by the post-process
  55235. */
  55236. getPass(): RenderTargetTexture;
  55237. private _meshExcluded;
  55238. private _createPass;
  55239. private _updateMeshScreenCoordinates;
  55240. /**
  55241. * Creates a default mesh for the Volumeric Light Scattering post-process
  55242. * @param name The mesh name
  55243. * @param scene The scene where to create the mesh
  55244. * @return the default mesh
  55245. */
  55246. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  55247. }
  55248. }
  55249. declare module "babylonjs/PostProcesses/index" {
  55250. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  55251. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  55252. export * from "babylonjs/PostProcesses/bloomEffect";
  55253. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  55254. export * from "babylonjs/PostProcesses/blurPostProcess";
  55255. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  55256. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  55257. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  55258. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  55259. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  55260. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  55261. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  55262. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  55263. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  55264. export * from "babylonjs/PostProcesses/filterPostProcess";
  55265. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  55266. export * from "babylonjs/PostProcesses/grainPostProcess";
  55267. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  55268. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  55269. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  55270. export * from "babylonjs/PostProcesses/passPostProcess";
  55271. export * from "babylonjs/PostProcesses/postProcess";
  55272. export * from "babylonjs/PostProcesses/postProcessManager";
  55273. export * from "babylonjs/PostProcesses/refractionPostProcess";
  55274. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  55275. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  55276. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  55277. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  55278. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  55279. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  55280. }
  55281. declare module "babylonjs/Probes/index" {
  55282. export * from "babylonjs/Probes/reflectionProbe";
  55283. }
  55284. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  55285. import { Scene } from "babylonjs/scene";
  55286. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55287. import { Color3 } from "babylonjs/Maths/math";
  55288. import { SmartArray } from "babylonjs/Misc/smartArray";
  55289. import { ISceneComponent } from "babylonjs/sceneComponent";
  55290. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  55291. import "babylonjs/Meshes/Builders/boxBuilder";
  55292. import "babylonjs/Shaders/color.fragment";
  55293. import "babylonjs/Shaders/color.vertex";
  55294. module "babylonjs/scene" {
  55295. interface Scene {
  55296. /** @hidden (Backing field) */
  55297. _boundingBoxRenderer: BoundingBoxRenderer;
  55298. /** @hidden (Backing field) */
  55299. _forceShowBoundingBoxes: boolean;
  55300. /**
  55301. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  55302. */
  55303. forceShowBoundingBoxes: boolean;
  55304. /**
  55305. * Gets the bounding box renderer associated with the scene
  55306. * @returns a BoundingBoxRenderer
  55307. */
  55308. getBoundingBoxRenderer(): BoundingBoxRenderer;
  55309. }
  55310. }
  55311. module "babylonjs/Meshes/abstractMesh" {
  55312. interface AbstractMesh {
  55313. /** @hidden (Backing field) */
  55314. _showBoundingBox: boolean;
  55315. /**
  55316. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  55317. */
  55318. showBoundingBox: boolean;
  55319. }
  55320. }
  55321. /**
  55322. * Component responsible of rendering the bounding box of the meshes in a scene.
  55323. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  55324. */
  55325. export class BoundingBoxRenderer implements ISceneComponent {
  55326. /**
  55327. * The component name helpfull to identify the component in the list of scene components.
  55328. */
  55329. readonly name: string;
  55330. /**
  55331. * The scene the component belongs to.
  55332. */
  55333. scene: Scene;
  55334. /**
  55335. * Color of the bounding box lines placed in front of an object
  55336. */
  55337. frontColor: Color3;
  55338. /**
  55339. * Color of the bounding box lines placed behind an object
  55340. */
  55341. backColor: Color3;
  55342. /**
  55343. * Defines if the renderer should show the back lines or not
  55344. */
  55345. showBackLines: boolean;
  55346. /**
  55347. * @hidden
  55348. */
  55349. renderList: SmartArray<BoundingBox>;
  55350. private _colorShader;
  55351. private _vertexBuffers;
  55352. private _indexBuffer;
  55353. /**
  55354. * Instantiates a new bounding box renderer in a scene.
  55355. * @param scene the scene the renderer renders in
  55356. */
  55357. constructor(scene: Scene);
  55358. /**
  55359. * Registers the component in a given scene
  55360. */
  55361. register(): void;
  55362. private _evaluateSubMesh;
  55363. private _activeMesh;
  55364. private _prepareRessources;
  55365. private _createIndexBuffer;
  55366. /**
  55367. * Rebuilds the elements related to this component in case of
  55368. * context lost for instance.
  55369. */
  55370. rebuild(): void;
  55371. /**
  55372. * @hidden
  55373. */
  55374. reset(): void;
  55375. /**
  55376. * Render the bounding boxes of a specific rendering group
  55377. * @param renderingGroupId defines the rendering group to render
  55378. */
  55379. render(renderingGroupId: number): void;
  55380. /**
  55381. * In case of occlusion queries, we can render the occlusion bounding box through this method
  55382. * @param mesh Define the mesh to render the occlusion bounding box for
  55383. */
  55384. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  55385. /**
  55386. * Dispose and release the resources attached to this renderer.
  55387. */
  55388. dispose(): void;
  55389. }
  55390. }
  55391. declare module "babylonjs/Shaders/depth.fragment" {
  55392. /** @hidden */
  55393. export var depthPixelShader: {
  55394. name: string;
  55395. shader: string;
  55396. };
  55397. }
  55398. declare module "babylonjs/Rendering/depthRenderer" {
  55399. import { Nullable } from "babylonjs/types";
  55400. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55401. import { Scene } from "babylonjs/scene";
  55402. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55403. import { Camera } from "babylonjs/Cameras/camera";
  55404. import "babylonjs/Shaders/depth.fragment";
  55405. import "babylonjs/Shaders/depth.vertex";
  55406. /**
  55407. * This represents a depth renderer in Babylon.
  55408. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  55409. */
  55410. export class DepthRenderer {
  55411. private _scene;
  55412. private _depthMap;
  55413. private _effect;
  55414. private _cachedDefines;
  55415. private _camera;
  55416. /**
  55417. * Specifiess that the depth renderer will only be used within
  55418. * the camera it is created for.
  55419. * This can help forcing its rendering during the camera processing.
  55420. */
  55421. useOnlyInActiveCamera: boolean;
  55422. /** @hidden */
  55423. static _SceneComponentInitialization: (scene: Scene) => void;
  55424. /**
  55425. * Instantiates a depth renderer
  55426. * @param scene The scene the renderer belongs to
  55427. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  55428. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  55429. */
  55430. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  55431. /**
  55432. * Creates the depth rendering effect and checks if the effect is ready.
  55433. * @param subMesh The submesh to be used to render the depth map of
  55434. * @param useInstances If multiple world instances should be used
  55435. * @returns if the depth renderer is ready to render the depth map
  55436. */
  55437. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55438. /**
  55439. * Gets the texture which the depth map will be written to.
  55440. * @returns The depth map texture
  55441. */
  55442. getDepthMap(): RenderTargetTexture;
  55443. /**
  55444. * Disposes of the depth renderer.
  55445. */
  55446. dispose(): void;
  55447. }
  55448. }
  55449. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  55450. import { Nullable } from "babylonjs/types";
  55451. import { Scene } from "babylonjs/scene";
  55452. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  55453. import { Camera } from "babylonjs/Cameras/camera";
  55454. import { ISceneComponent } from "babylonjs/sceneComponent";
  55455. module "babylonjs/scene" {
  55456. interface Scene {
  55457. /** @hidden (Backing field) */
  55458. _depthRenderer: {
  55459. [id: string]: DepthRenderer;
  55460. };
  55461. /**
  55462. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  55463. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  55464. * @returns the created depth renderer
  55465. */
  55466. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  55467. /**
  55468. * Disables a depth renderer for a given camera
  55469. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  55470. */
  55471. disableDepthRenderer(camera?: Nullable<Camera>): void;
  55472. }
  55473. }
  55474. /**
  55475. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  55476. * in several rendering techniques.
  55477. */
  55478. export class DepthRendererSceneComponent implements ISceneComponent {
  55479. /**
  55480. * The component name helpfull to identify the component in the list of scene components.
  55481. */
  55482. readonly name: string;
  55483. /**
  55484. * The scene the component belongs to.
  55485. */
  55486. scene: Scene;
  55487. /**
  55488. * Creates a new instance of the component for the given scene
  55489. * @param scene Defines the scene to register the component in
  55490. */
  55491. constructor(scene: Scene);
  55492. /**
  55493. * Registers the component in a given scene
  55494. */
  55495. register(): void;
  55496. /**
  55497. * Rebuilds the elements related to this component in case of
  55498. * context lost for instance.
  55499. */
  55500. rebuild(): void;
  55501. /**
  55502. * Disposes the component and the associated ressources
  55503. */
  55504. dispose(): void;
  55505. private _gatherRenderTargets;
  55506. private _gatherActiveCameraRenderTargets;
  55507. }
  55508. }
  55509. declare module "babylonjs/Shaders/outline.fragment" {
  55510. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  55511. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  55512. /** @hidden */
  55513. export var outlinePixelShader: {
  55514. name: string;
  55515. shader: string;
  55516. };
  55517. }
  55518. declare module "babylonjs/Shaders/outline.vertex" {
  55519. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55520. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55521. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  55522. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55523. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55524. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  55525. /** @hidden */
  55526. export var outlineVertexShader: {
  55527. name: string;
  55528. shader: string;
  55529. };
  55530. }
  55531. declare module "babylonjs/Rendering/outlineRenderer" {
  55532. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55533. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  55534. import { Scene } from "babylonjs/scene";
  55535. import { ISceneComponent } from "babylonjs/sceneComponent";
  55536. import "babylonjs/Shaders/outline.fragment";
  55537. import "babylonjs/Shaders/outline.vertex";
  55538. module "babylonjs/scene" {
  55539. interface Scene {
  55540. /** @hidden */
  55541. _outlineRenderer: OutlineRenderer;
  55542. /**
  55543. * Gets the outline renderer associated with the scene
  55544. * @returns a OutlineRenderer
  55545. */
  55546. getOutlineRenderer(): OutlineRenderer;
  55547. }
  55548. }
  55549. module "babylonjs/Meshes/abstractMesh" {
  55550. interface AbstractMesh {
  55551. /** @hidden (Backing field) */
  55552. _renderOutline: boolean;
  55553. /**
  55554. * Gets or sets a boolean indicating if the outline must be rendered as well
  55555. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  55556. */
  55557. renderOutline: boolean;
  55558. /** @hidden (Backing field) */
  55559. _renderOverlay: boolean;
  55560. /**
  55561. * Gets or sets a boolean indicating if the overlay must be rendered as well
  55562. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  55563. */
  55564. renderOverlay: boolean;
  55565. }
  55566. }
  55567. /**
  55568. * This class is responsible to draw bothe outline/overlay of meshes.
  55569. * It should not be used directly but through the available method on mesh.
  55570. */
  55571. export class OutlineRenderer implements ISceneComponent {
  55572. /**
  55573. * The name of the component. Each component must have a unique name.
  55574. */
  55575. name: string;
  55576. /**
  55577. * The scene the component belongs to.
  55578. */
  55579. scene: Scene;
  55580. /**
  55581. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  55582. */
  55583. zOffset: number;
  55584. private _engine;
  55585. private _effect;
  55586. private _cachedDefines;
  55587. private _savedDepthWrite;
  55588. /**
  55589. * Instantiates a new outline renderer. (There could be only one per scene).
  55590. * @param scene Defines the scene it belongs to
  55591. */
  55592. constructor(scene: Scene);
  55593. /**
  55594. * Register the component to one instance of a scene.
  55595. */
  55596. register(): void;
  55597. /**
  55598. * Rebuilds the elements related to this component in case of
  55599. * context lost for instance.
  55600. */
  55601. rebuild(): void;
  55602. /**
  55603. * Disposes the component and the associated ressources.
  55604. */
  55605. dispose(): void;
  55606. /**
  55607. * Renders the outline in the canvas.
  55608. * @param subMesh Defines the sumesh to render
  55609. * @param batch Defines the batch of meshes in case of instances
  55610. * @param useOverlay Defines if the rendering is for the overlay or the outline
  55611. */
  55612. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  55613. /**
  55614. * Returns whether or not the outline renderer is ready for a given submesh.
  55615. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  55616. * @param subMesh Defines the submesh to check readyness for
  55617. * @param useInstances Defines wheter wee are trying to render instances or not
  55618. * @returns true if ready otherwise false
  55619. */
  55620. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55621. private _beforeRenderingMesh;
  55622. private _afterRenderingMesh;
  55623. }
  55624. }
  55625. declare module "babylonjs/Rendering/index" {
  55626. export * from "babylonjs/Rendering/boundingBoxRenderer";
  55627. export * from "babylonjs/Rendering/depthRenderer";
  55628. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  55629. export * from "babylonjs/Rendering/edgesRenderer";
  55630. export * from "babylonjs/Rendering/geometryBufferRenderer";
  55631. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  55632. export * from "babylonjs/Rendering/outlineRenderer";
  55633. export * from "babylonjs/Rendering/renderingGroup";
  55634. export * from "babylonjs/Rendering/renderingManager";
  55635. export * from "babylonjs/Rendering/utilityLayerRenderer";
  55636. }
  55637. declare module "babylonjs/Sprites/index" {
  55638. export * from "babylonjs/Sprites/sprite";
  55639. export * from "babylonjs/Sprites/spriteManager";
  55640. export * from "babylonjs/Sprites/spriteSceneComponent";
  55641. }
  55642. declare module "babylonjs/Misc/assetsManager" {
  55643. import { Scene } from "babylonjs/scene";
  55644. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55645. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  55646. import { Skeleton } from "babylonjs/Bones/skeleton";
  55647. import { Observable } from "babylonjs/Misc/observable";
  55648. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55649. import { Texture } from "babylonjs/Materials/Textures/texture";
  55650. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  55651. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  55652. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  55653. /**
  55654. * Defines the list of states available for a task inside a AssetsManager
  55655. */
  55656. export enum AssetTaskState {
  55657. /**
  55658. * Initialization
  55659. */
  55660. INIT = 0,
  55661. /**
  55662. * Running
  55663. */
  55664. RUNNING = 1,
  55665. /**
  55666. * Done
  55667. */
  55668. DONE = 2,
  55669. /**
  55670. * Error
  55671. */
  55672. ERROR = 3
  55673. }
  55674. /**
  55675. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  55676. */
  55677. export abstract class AbstractAssetTask {
  55678. /**
  55679. * Task name
  55680. */ name: string;
  55681. /**
  55682. * Callback called when the task is successful
  55683. */
  55684. onSuccess: (task: any) => void;
  55685. /**
  55686. * Callback called when the task is not successful
  55687. */
  55688. onError: (task: any, message?: string, exception?: any) => void;
  55689. /**
  55690. * Creates a new AssetsManager
  55691. * @param name defines the name of the task
  55692. */
  55693. constructor(
  55694. /**
  55695. * Task name
  55696. */ name: string);
  55697. private _isCompleted;
  55698. private _taskState;
  55699. private _errorObject;
  55700. /**
  55701. * Get if the task is completed
  55702. */
  55703. readonly isCompleted: boolean;
  55704. /**
  55705. * Gets the current state of the task
  55706. */
  55707. readonly taskState: AssetTaskState;
  55708. /**
  55709. * Gets the current error object (if task is in error)
  55710. */
  55711. readonly errorObject: {
  55712. message?: string;
  55713. exception?: any;
  55714. };
  55715. /**
  55716. * Internal only
  55717. * @hidden
  55718. */
  55719. _setErrorObject(message?: string, exception?: any): void;
  55720. /**
  55721. * Execute the current task
  55722. * @param scene defines the scene where you want your assets to be loaded
  55723. * @param onSuccess is a callback called when the task is successfully executed
  55724. * @param onError is a callback called if an error occurs
  55725. */
  55726. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55727. /**
  55728. * Execute the current task
  55729. * @param scene defines the scene where you want your assets to be loaded
  55730. * @param onSuccess is a callback called when the task is successfully executed
  55731. * @param onError is a callback called if an error occurs
  55732. */
  55733. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55734. /**
  55735. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  55736. * This can be used with failed tasks that have the reason for failure fixed.
  55737. */
  55738. reset(): void;
  55739. private onErrorCallback;
  55740. private onDoneCallback;
  55741. }
  55742. /**
  55743. * Define the interface used by progress events raised during assets loading
  55744. */
  55745. export interface IAssetsProgressEvent {
  55746. /**
  55747. * Defines the number of remaining tasks to process
  55748. */
  55749. remainingCount: number;
  55750. /**
  55751. * Defines the total number of tasks
  55752. */
  55753. totalCount: number;
  55754. /**
  55755. * Defines the task that was just processed
  55756. */
  55757. task: AbstractAssetTask;
  55758. }
  55759. /**
  55760. * Class used to share progress information about assets loading
  55761. */
  55762. export class AssetsProgressEvent implements IAssetsProgressEvent {
  55763. /**
  55764. * Defines the number of remaining tasks to process
  55765. */
  55766. remainingCount: number;
  55767. /**
  55768. * Defines the total number of tasks
  55769. */
  55770. totalCount: number;
  55771. /**
  55772. * Defines the task that was just processed
  55773. */
  55774. task: AbstractAssetTask;
  55775. /**
  55776. * Creates a AssetsProgressEvent
  55777. * @param remainingCount defines the number of remaining tasks to process
  55778. * @param totalCount defines the total number of tasks
  55779. * @param task defines the task that was just processed
  55780. */
  55781. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  55782. }
  55783. /**
  55784. * Define a task used by AssetsManager to load meshes
  55785. */
  55786. export class MeshAssetTask extends AbstractAssetTask {
  55787. /**
  55788. * Defines the name of the task
  55789. */
  55790. name: string;
  55791. /**
  55792. * Defines the list of mesh's names you want to load
  55793. */
  55794. meshesNames: any;
  55795. /**
  55796. * Defines the root url to use as a base to load your meshes and associated resources
  55797. */
  55798. rootUrl: string;
  55799. /**
  55800. * Defines the filename of the scene to load from
  55801. */
  55802. sceneFilename: string;
  55803. /**
  55804. * Gets the list of loaded meshes
  55805. */
  55806. loadedMeshes: Array<AbstractMesh>;
  55807. /**
  55808. * Gets the list of loaded particle systems
  55809. */
  55810. loadedParticleSystems: Array<IParticleSystem>;
  55811. /**
  55812. * Gets the list of loaded skeletons
  55813. */
  55814. loadedSkeletons: Array<Skeleton>;
  55815. /**
  55816. * Gets the list of loaded animation groups
  55817. */
  55818. loadedAnimationGroups: Array<AnimationGroup>;
  55819. /**
  55820. * Callback called when the task is successful
  55821. */
  55822. onSuccess: (task: MeshAssetTask) => void;
  55823. /**
  55824. * Callback called when the task is successful
  55825. */
  55826. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  55827. /**
  55828. * Creates a new MeshAssetTask
  55829. * @param name defines the name of the task
  55830. * @param meshesNames defines the list of mesh's names you want to load
  55831. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  55832. * @param sceneFilename defines the filename of the scene to load from
  55833. */
  55834. constructor(
  55835. /**
  55836. * Defines the name of the task
  55837. */
  55838. name: string,
  55839. /**
  55840. * Defines the list of mesh's names you want to load
  55841. */
  55842. meshesNames: any,
  55843. /**
  55844. * Defines the root url to use as a base to load your meshes and associated resources
  55845. */
  55846. rootUrl: string,
  55847. /**
  55848. * Defines the filename of the scene to load from
  55849. */
  55850. sceneFilename: string);
  55851. /**
  55852. * Execute the current task
  55853. * @param scene defines the scene where you want your assets to be loaded
  55854. * @param onSuccess is a callback called when the task is successfully executed
  55855. * @param onError is a callback called if an error occurs
  55856. */
  55857. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55858. }
  55859. /**
  55860. * Define a task used by AssetsManager to load text content
  55861. */
  55862. export class TextFileAssetTask extends AbstractAssetTask {
  55863. /**
  55864. * Defines the name of the task
  55865. */
  55866. name: string;
  55867. /**
  55868. * Defines the location of the file to load
  55869. */
  55870. url: string;
  55871. /**
  55872. * Gets the loaded text string
  55873. */
  55874. text: string;
  55875. /**
  55876. * Callback called when the task is successful
  55877. */
  55878. onSuccess: (task: TextFileAssetTask) => void;
  55879. /**
  55880. * Callback called when the task is successful
  55881. */
  55882. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  55883. /**
  55884. * Creates a new TextFileAssetTask object
  55885. * @param name defines the name of the task
  55886. * @param url defines the location of the file to load
  55887. */
  55888. constructor(
  55889. /**
  55890. * Defines the name of the task
  55891. */
  55892. name: string,
  55893. /**
  55894. * Defines the location of the file to load
  55895. */
  55896. url: string);
  55897. /**
  55898. * Execute the current task
  55899. * @param scene defines the scene where you want your assets to be loaded
  55900. * @param onSuccess is a callback called when the task is successfully executed
  55901. * @param onError is a callback called if an error occurs
  55902. */
  55903. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55904. }
  55905. /**
  55906. * Define a task used by AssetsManager to load binary data
  55907. */
  55908. export class BinaryFileAssetTask extends AbstractAssetTask {
  55909. /**
  55910. * Defines the name of the task
  55911. */
  55912. name: string;
  55913. /**
  55914. * Defines the location of the file to load
  55915. */
  55916. url: string;
  55917. /**
  55918. * Gets the lodaded data (as an array buffer)
  55919. */
  55920. data: ArrayBuffer;
  55921. /**
  55922. * Callback called when the task is successful
  55923. */
  55924. onSuccess: (task: BinaryFileAssetTask) => void;
  55925. /**
  55926. * Callback called when the task is successful
  55927. */
  55928. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  55929. /**
  55930. * Creates a new BinaryFileAssetTask object
  55931. * @param name defines the name of the new task
  55932. * @param url defines the location of the file to load
  55933. */
  55934. constructor(
  55935. /**
  55936. * Defines the name of the task
  55937. */
  55938. name: string,
  55939. /**
  55940. * Defines the location of the file to load
  55941. */
  55942. url: string);
  55943. /**
  55944. * Execute the current task
  55945. * @param scene defines the scene where you want your assets to be loaded
  55946. * @param onSuccess is a callback called when the task is successfully executed
  55947. * @param onError is a callback called if an error occurs
  55948. */
  55949. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55950. }
  55951. /**
  55952. * Define a task used by AssetsManager to load images
  55953. */
  55954. export class ImageAssetTask extends AbstractAssetTask {
  55955. /**
  55956. * Defines the name of the task
  55957. */
  55958. name: string;
  55959. /**
  55960. * Defines the location of the image to load
  55961. */
  55962. url: string;
  55963. /**
  55964. * Gets the loaded images
  55965. */
  55966. image: HTMLImageElement;
  55967. /**
  55968. * Callback called when the task is successful
  55969. */
  55970. onSuccess: (task: ImageAssetTask) => void;
  55971. /**
  55972. * Callback called when the task is successful
  55973. */
  55974. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  55975. /**
  55976. * Creates a new ImageAssetTask
  55977. * @param name defines the name of the task
  55978. * @param url defines the location of the image to load
  55979. */
  55980. constructor(
  55981. /**
  55982. * Defines the name of the task
  55983. */
  55984. name: string,
  55985. /**
  55986. * Defines the location of the image to load
  55987. */
  55988. url: string);
  55989. /**
  55990. * Execute the current task
  55991. * @param scene defines the scene where you want your assets to be loaded
  55992. * @param onSuccess is a callback called when the task is successfully executed
  55993. * @param onError is a callback called if an error occurs
  55994. */
  55995. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55996. }
  55997. /**
  55998. * Defines the interface used by texture loading tasks
  55999. */
  56000. export interface ITextureAssetTask<TEX extends BaseTexture> {
  56001. /**
  56002. * Gets the loaded texture
  56003. */
  56004. texture: TEX;
  56005. }
  56006. /**
  56007. * Define a task used by AssetsManager to load 2D textures
  56008. */
  56009. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  56010. /**
  56011. * Defines the name of the task
  56012. */
  56013. name: string;
  56014. /**
  56015. * Defines the location of the file to load
  56016. */
  56017. url: string;
  56018. /**
  56019. * Defines if mipmap should not be generated (default is false)
  56020. */
  56021. noMipmap?: boolean | undefined;
  56022. /**
  56023. * Defines if texture must be inverted on Y axis (default is false)
  56024. */
  56025. invertY?: boolean | undefined;
  56026. /**
  56027. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  56028. */
  56029. samplingMode: number;
  56030. /**
  56031. * Gets the loaded texture
  56032. */
  56033. texture: Texture;
  56034. /**
  56035. * Callback called when the task is successful
  56036. */
  56037. onSuccess: (task: TextureAssetTask) => void;
  56038. /**
  56039. * Callback called when the task is successful
  56040. */
  56041. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  56042. /**
  56043. * Creates a new TextureAssetTask object
  56044. * @param name defines the name of the task
  56045. * @param url defines the location of the file to load
  56046. * @param noMipmap defines if mipmap should not be generated (default is false)
  56047. * @param invertY defines if texture must be inverted on Y axis (default is false)
  56048. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  56049. */
  56050. constructor(
  56051. /**
  56052. * Defines the name of the task
  56053. */
  56054. name: string,
  56055. /**
  56056. * Defines the location of the file to load
  56057. */
  56058. url: string,
  56059. /**
  56060. * Defines if mipmap should not be generated (default is false)
  56061. */
  56062. noMipmap?: boolean | undefined,
  56063. /**
  56064. * Defines if texture must be inverted on Y axis (default is false)
  56065. */
  56066. invertY?: boolean | undefined,
  56067. /**
  56068. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  56069. */
  56070. samplingMode?: number);
  56071. /**
  56072. * Execute the current task
  56073. * @param scene defines the scene where you want your assets to be loaded
  56074. * @param onSuccess is a callback called when the task is successfully executed
  56075. * @param onError is a callback called if an error occurs
  56076. */
  56077. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56078. }
  56079. /**
  56080. * Define a task used by AssetsManager to load cube textures
  56081. */
  56082. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  56083. /**
  56084. * Defines the name of the task
  56085. */
  56086. name: string;
  56087. /**
  56088. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56089. */
  56090. url: string;
  56091. /**
  56092. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56093. */
  56094. extensions?: string[] | undefined;
  56095. /**
  56096. * Defines if mipmaps should not be generated (default is false)
  56097. */
  56098. noMipmap?: boolean | undefined;
  56099. /**
  56100. * Defines the explicit list of files (undefined by default)
  56101. */
  56102. files?: string[] | undefined;
  56103. /**
  56104. * Gets the loaded texture
  56105. */
  56106. texture: CubeTexture;
  56107. /**
  56108. * Callback called when the task is successful
  56109. */
  56110. onSuccess: (task: CubeTextureAssetTask) => void;
  56111. /**
  56112. * Callback called when the task is successful
  56113. */
  56114. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  56115. /**
  56116. * Creates a new CubeTextureAssetTask
  56117. * @param name defines the name of the task
  56118. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56119. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56120. * @param noMipmap defines if mipmaps should not be generated (default is false)
  56121. * @param files defines the explicit list of files (undefined by default)
  56122. */
  56123. constructor(
  56124. /**
  56125. * Defines the name of the task
  56126. */
  56127. name: string,
  56128. /**
  56129. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56130. */
  56131. url: string,
  56132. /**
  56133. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56134. */
  56135. extensions?: string[] | undefined,
  56136. /**
  56137. * Defines if mipmaps should not be generated (default is false)
  56138. */
  56139. noMipmap?: boolean | undefined,
  56140. /**
  56141. * Defines the explicit list of files (undefined by default)
  56142. */
  56143. files?: string[] | undefined);
  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. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56151. }
  56152. /**
  56153. * Define a task used by AssetsManager to load HDR cube textures
  56154. */
  56155. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  56156. /**
  56157. * Defines the name of the task
  56158. */
  56159. name: string;
  56160. /**
  56161. * Defines the location of the file to load
  56162. */
  56163. url: string;
  56164. /**
  56165. * Defines the desired size (the more it increases the longer the generation will be)
  56166. */
  56167. size: number;
  56168. /**
  56169. * Defines if mipmaps should not be generated (default is false)
  56170. */
  56171. noMipmap: boolean;
  56172. /**
  56173. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56174. */
  56175. generateHarmonics: boolean;
  56176. /**
  56177. * 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)
  56178. */
  56179. gammaSpace: boolean;
  56180. /**
  56181. * Internal Use Only
  56182. */
  56183. reserved: boolean;
  56184. /**
  56185. * Gets the loaded texture
  56186. */
  56187. texture: HDRCubeTexture;
  56188. /**
  56189. * Callback called when the task is successful
  56190. */
  56191. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  56192. /**
  56193. * Callback called when the task is successful
  56194. */
  56195. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  56196. /**
  56197. * Creates a new HDRCubeTextureAssetTask object
  56198. * @param name defines the name of the task
  56199. * @param url defines the location of the file to load
  56200. * @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.
  56201. * @param noMipmap defines if mipmaps should not be generated (default is false)
  56202. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56203. * @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)
  56204. * @param reserved Internal use only
  56205. */
  56206. constructor(
  56207. /**
  56208. * Defines the name of the task
  56209. */
  56210. name: string,
  56211. /**
  56212. * Defines the location of the file to load
  56213. */
  56214. url: string,
  56215. /**
  56216. * Defines the desired size (the more it increases the longer the generation will be)
  56217. */
  56218. size: number,
  56219. /**
  56220. * Defines if mipmaps should not be generated (default is false)
  56221. */
  56222. noMipmap?: boolean,
  56223. /**
  56224. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56225. */
  56226. generateHarmonics?: boolean,
  56227. /**
  56228. * 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)
  56229. */
  56230. gammaSpace?: boolean,
  56231. /**
  56232. * Internal Use Only
  56233. */
  56234. reserved?: boolean);
  56235. /**
  56236. * Execute the current task
  56237. * @param scene defines the scene where you want your assets to be loaded
  56238. * @param onSuccess is a callback called when the task is successfully executed
  56239. * @param onError is a callback called if an error occurs
  56240. */
  56241. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56242. }
  56243. /**
  56244. * This class can be used to easily import assets into a scene
  56245. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  56246. */
  56247. export class AssetsManager {
  56248. private _scene;
  56249. private _isLoading;
  56250. protected _tasks: AbstractAssetTask[];
  56251. protected _waitingTasksCount: number;
  56252. protected _totalTasksCount: number;
  56253. /**
  56254. * Callback called when all tasks are processed
  56255. */
  56256. onFinish: (tasks: AbstractAssetTask[]) => void;
  56257. /**
  56258. * Callback called when a task is successful
  56259. */
  56260. onTaskSuccess: (task: AbstractAssetTask) => void;
  56261. /**
  56262. * Callback called when a task had an error
  56263. */
  56264. onTaskError: (task: AbstractAssetTask) => void;
  56265. /**
  56266. * Callback called when a task is done (whatever the result is)
  56267. */
  56268. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  56269. /**
  56270. * Observable called when all tasks are processed
  56271. */
  56272. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  56273. /**
  56274. * Observable called when a task had an error
  56275. */
  56276. onTaskErrorObservable: Observable<AbstractAssetTask>;
  56277. /**
  56278. * Observable called when all tasks were executed
  56279. */
  56280. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  56281. /**
  56282. * Observable called when a task is done (whatever the result is)
  56283. */
  56284. onProgressObservable: Observable<IAssetsProgressEvent>;
  56285. /**
  56286. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  56287. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  56288. */
  56289. useDefaultLoadingScreen: boolean;
  56290. /**
  56291. * Creates a new AssetsManager
  56292. * @param scene defines the scene to work on
  56293. */
  56294. constructor(scene: Scene);
  56295. /**
  56296. * Add a MeshAssetTask to the list of active tasks
  56297. * @param taskName defines the name of the new task
  56298. * @param meshesNames defines the name of meshes to load
  56299. * @param rootUrl defines the root url to use to locate files
  56300. * @param sceneFilename defines the filename of the scene file
  56301. * @returns a new MeshAssetTask object
  56302. */
  56303. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  56304. /**
  56305. * Add a TextFileAssetTask to the list of active tasks
  56306. * @param taskName defines the name of the new task
  56307. * @param url defines the url of the file to load
  56308. * @returns a new TextFileAssetTask object
  56309. */
  56310. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  56311. /**
  56312. * Add a BinaryFileAssetTask to the list of active tasks
  56313. * @param taskName defines the name of the new task
  56314. * @param url defines the url of the file to load
  56315. * @returns a new BinaryFileAssetTask object
  56316. */
  56317. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  56318. /**
  56319. * Add a ImageAssetTask to the list of active tasks
  56320. * @param taskName defines the name of the new task
  56321. * @param url defines the url of the file to load
  56322. * @returns a new ImageAssetTask object
  56323. */
  56324. addImageTask(taskName: string, url: string): ImageAssetTask;
  56325. /**
  56326. * Add a TextureAssetTask to the list of active tasks
  56327. * @param taskName defines the name of the new task
  56328. * @param url defines the url of the file to load
  56329. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56330. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  56331. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56332. * @returns a new TextureAssetTask object
  56333. */
  56334. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  56335. /**
  56336. * Add a CubeTextureAssetTask to the list of active tasks
  56337. * @param taskName defines the name of the new task
  56338. * @param url defines the url of the file to load
  56339. * @param extensions defines the extension to use to load the cube map (can be null)
  56340. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56341. * @param files defines the list of files to load (can be null)
  56342. * @returns a new CubeTextureAssetTask object
  56343. */
  56344. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  56345. /**
  56346. *
  56347. * Add a HDRCubeTextureAssetTask to the list of active tasks
  56348. * @param taskName defines the name of the new task
  56349. * @param url defines the url of the file to load
  56350. * @param size defines the size you want for the cubemap (can be null)
  56351. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56352. * @param generateHarmonics defines if you want to automatically generate (true by default)
  56353. * @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)
  56354. * @param reserved Internal use only
  56355. * @returns a new HDRCubeTextureAssetTask object
  56356. */
  56357. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  56358. /**
  56359. * Remove a task from the assets manager.
  56360. * @param task the task to remove
  56361. */
  56362. removeTask(task: AbstractAssetTask): void;
  56363. private _decreaseWaitingTasksCount;
  56364. private _runTask;
  56365. /**
  56366. * Reset the AssetsManager and remove all tasks
  56367. * @return the current instance of the AssetsManager
  56368. */
  56369. reset(): AssetsManager;
  56370. /**
  56371. * Start the loading process
  56372. * @return the current instance of the AssetsManager
  56373. */
  56374. load(): AssetsManager;
  56375. /**
  56376. * Start the loading process as an async operation
  56377. * @return a promise returning the list of failed tasks
  56378. */
  56379. loadAsync(): Promise<void>;
  56380. }
  56381. }
  56382. declare module "babylonjs/Misc/deferred" {
  56383. /**
  56384. * Wrapper class for promise with external resolve and reject.
  56385. */
  56386. export class Deferred<T> {
  56387. /**
  56388. * The promise associated with this deferred object.
  56389. */
  56390. readonly promise: Promise<T>;
  56391. private _resolve;
  56392. private _reject;
  56393. /**
  56394. * The resolve method of the promise associated with this deferred object.
  56395. */
  56396. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  56397. /**
  56398. * The reject method of the promise associated with this deferred object.
  56399. */
  56400. readonly reject: (reason?: any) => void;
  56401. /**
  56402. * Constructor for this deferred object.
  56403. */
  56404. constructor();
  56405. }
  56406. }
  56407. declare module "babylonjs/Misc/meshExploder" {
  56408. import { Mesh } from "babylonjs/Meshes/mesh";
  56409. /**
  56410. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  56411. */
  56412. export class MeshExploder {
  56413. private _centerMesh;
  56414. private _meshes;
  56415. private _meshesOrigins;
  56416. private _toCenterVectors;
  56417. private _scaledDirection;
  56418. private _newPosition;
  56419. private _centerPosition;
  56420. /**
  56421. * Explodes meshes from a center mesh.
  56422. * @param meshes The meshes to explode.
  56423. * @param centerMesh The mesh to be center of explosion.
  56424. */
  56425. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  56426. private _setCenterMesh;
  56427. /**
  56428. * Get class name
  56429. * @returns "MeshExploder"
  56430. */
  56431. getClassName(): string;
  56432. /**
  56433. * "Exploded meshes"
  56434. * @returns Array of meshes with the centerMesh at index 0.
  56435. */
  56436. getMeshes(): Array<Mesh>;
  56437. /**
  56438. * Explodes meshes giving a specific direction
  56439. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  56440. */
  56441. explode(direction?: number): void;
  56442. }
  56443. }
  56444. declare module "babylonjs/Misc/filesInput" {
  56445. import { Engine } from "babylonjs/Engines/engine";
  56446. import { Scene } from "babylonjs/scene";
  56447. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  56448. /**
  56449. * Class used to help managing file picking and drag'n'drop
  56450. */
  56451. export class FilesInput {
  56452. /**
  56453. * List of files ready to be loaded
  56454. */
  56455. static readonly FilesToLoad: {
  56456. [key: string]: File;
  56457. };
  56458. /**
  56459. * Callback called when a file is processed
  56460. */
  56461. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  56462. private _engine;
  56463. private _currentScene;
  56464. private _sceneLoadedCallback;
  56465. private _progressCallback;
  56466. private _additionalRenderLoopLogicCallback;
  56467. private _textureLoadingCallback;
  56468. private _startingProcessingFilesCallback;
  56469. private _onReloadCallback;
  56470. private _errorCallback;
  56471. private _elementToMonitor;
  56472. private _sceneFileToLoad;
  56473. private _filesToLoad;
  56474. /**
  56475. * Creates a new FilesInput
  56476. * @param engine defines the rendering engine
  56477. * @param scene defines the hosting scene
  56478. * @param sceneLoadedCallback callback called when scene is loaded
  56479. * @param progressCallback callback called to track progress
  56480. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  56481. * @param textureLoadingCallback callback called when a texture is loading
  56482. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  56483. * @param onReloadCallback callback called when a reload is requested
  56484. * @param errorCallback callback call if an error occurs
  56485. */
  56486. 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);
  56487. private _dragEnterHandler;
  56488. private _dragOverHandler;
  56489. private _dropHandler;
  56490. /**
  56491. * Calls this function to listen to drag'n'drop events on a specific DOM element
  56492. * @param elementToMonitor defines the DOM element to track
  56493. */
  56494. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  56495. /**
  56496. * Release all associated resources
  56497. */
  56498. dispose(): void;
  56499. private renderFunction;
  56500. private drag;
  56501. private drop;
  56502. private _traverseFolder;
  56503. private _processFiles;
  56504. /**
  56505. * Load files from a drop event
  56506. * @param event defines the drop event to use as source
  56507. */
  56508. loadFiles(event: any): void;
  56509. private _processReload;
  56510. /**
  56511. * Reload the current scene from the loaded files
  56512. */
  56513. reload(): void;
  56514. }
  56515. }
  56516. declare module "babylonjs/Misc/HighDynamicRange/index" {
  56517. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  56518. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  56519. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  56520. }
  56521. declare module "babylonjs/Misc/sceneOptimizer" {
  56522. import { Scene, IDisposable } from "babylonjs/scene";
  56523. import { Observable } from "babylonjs/Misc/observable";
  56524. /**
  56525. * Defines the root class used to create scene optimization to use with SceneOptimizer
  56526. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56527. */
  56528. export class SceneOptimization {
  56529. /**
  56530. * Defines the priority of this optimization (0 by default which means first in the list)
  56531. */
  56532. priority: number;
  56533. /**
  56534. * Gets a string describing the action executed by the current optimization
  56535. * @returns description string
  56536. */
  56537. getDescription(): string;
  56538. /**
  56539. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56540. * @param scene defines the current scene where to apply this optimization
  56541. * @param optimizer defines the current optimizer
  56542. * @returns true if everything that can be done was applied
  56543. */
  56544. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56545. /**
  56546. * Creates the SceneOptimization object
  56547. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56548. * @param desc defines the description associated with the optimization
  56549. */
  56550. constructor(
  56551. /**
  56552. * Defines the priority of this optimization (0 by default which means first in the list)
  56553. */
  56554. priority?: number);
  56555. }
  56556. /**
  56557. * Defines an optimization used to reduce the size of render target textures
  56558. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56559. */
  56560. export class TextureOptimization extends SceneOptimization {
  56561. /**
  56562. * Defines the priority of this optimization (0 by default which means first in the list)
  56563. */
  56564. priority: number;
  56565. /**
  56566. * 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
  56567. */
  56568. maximumSize: number;
  56569. /**
  56570. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56571. */
  56572. step: number;
  56573. /**
  56574. * Gets a string describing the action executed by the current optimization
  56575. * @returns description string
  56576. */
  56577. getDescription(): string;
  56578. /**
  56579. * Creates the TextureOptimization object
  56580. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56581. * @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
  56582. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56583. */
  56584. constructor(
  56585. /**
  56586. * Defines the priority of this optimization (0 by default which means first in the list)
  56587. */
  56588. priority?: number,
  56589. /**
  56590. * 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
  56591. */
  56592. maximumSize?: number,
  56593. /**
  56594. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56595. */
  56596. step?: number);
  56597. /**
  56598. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56599. * @param scene defines the current scene where to apply this optimization
  56600. * @param optimizer defines the current optimizer
  56601. * @returns true if everything that can be done was applied
  56602. */
  56603. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56604. }
  56605. /**
  56606. * Defines an optimization used to increase or decrease the rendering resolution
  56607. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56608. */
  56609. export class HardwareScalingOptimization extends SceneOptimization {
  56610. /**
  56611. * Defines the priority of this optimization (0 by default which means first in the list)
  56612. */
  56613. priority: number;
  56614. /**
  56615. * Defines the maximum scale to use (2 by default)
  56616. */
  56617. maximumScale: number;
  56618. /**
  56619. * Defines the step to use between two passes (0.5 by default)
  56620. */
  56621. step: number;
  56622. private _currentScale;
  56623. private _directionOffset;
  56624. /**
  56625. * Gets a string describing the action executed by the current optimization
  56626. * @return description string
  56627. */
  56628. getDescription(): string;
  56629. /**
  56630. * Creates the HardwareScalingOptimization object
  56631. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56632. * @param maximumScale defines the maximum scale to use (2 by default)
  56633. * @param step defines the step to use between two passes (0.5 by default)
  56634. */
  56635. constructor(
  56636. /**
  56637. * Defines the priority of this optimization (0 by default which means first in the list)
  56638. */
  56639. priority?: number,
  56640. /**
  56641. * Defines the maximum scale to use (2 by default)
  56642. */
  56643. maximumScale?: number,
  56644. /**
  56645. * Defines the step to use between two passes (0.5 by default)
  56646. */
  56647. step?: number);
  56648. /**
  56649. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56650. * @param scene defines the current scene where to apply this optimization
  56651. * @param optimizer defines the current optimizer
  56652. * @returns true if everything that can be done was applied
  56653. */
  56654. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56655. }
  56656. /**
  56657. * Defines an optimization used to remove shadows
  56658. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56659. */
  56660. export class ShadowsOptimization extends SceneOptimization {
  56661. /**
  56662. * Gets a string describing the action executed by the current optimization
  56663. * @return description string
  56664. */
  56665. getDescription(): string;
  56666. /**
  56667. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56668. * @param scene defines the current scene where to apply this optimization
  56669. * @param optimizer defines the current optimizer
  56670. * @returns true if everything that can be done was applied
  56671. */
  56672. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56673. }
  56674. /**
  56675. * Defines an optimization used to turn post-processes off
  56676. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56677. */
  56678. export class PostProcessesOptimization extends SceneOptimization {
  56679. /**
  56680. * Gets a string describing the action executed by the current optimization
  56681. * @return description string
  56682. */
  56683. getDescription(): string;
  56684. /**
  56685. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56686. * @param scene defines the current scene where to apply this optimization
  56687. * @param optimizer defines the current optimizer
  56688. * @returns true if everything that can be done was applied
  56689. */
  56690. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56691. }
  56692. /**
  56693. * Defines an optimization used to turn lens flares off
  56694. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56695. */
  56696. export class LensFlaresOptimization extends SceneOptimization {
  56697. /**
  56698. * Gets a string describing the action executed by the current optimization
  56699. * @return description string
  56700. */
  56701. getDescription(): string;
  56702. /**
  56703. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56704. * @param scene defines the current scene where to apply this optimization
  56705. * @param optimizer defines the current optimizer
  56706. * @returns true if everything that can be done was applied
  56707. */
  56708. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56709. }
  56710. /**
  56711. * Defines an optimization based on user defined callback.
  56712. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56713. */
  56714. export class CustomOptimization extends SceneOptimization {
  56715. /**
  56716. * Callback called to apply the custom optimization.
  56717. */
  56718. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  56719. /**
  56720. * Callback called to get custom description
  56721. */
  56722. onGetDescription: () => string;
  56723. /**
  56724. * Gets a string describing the action executed by the current optimization
  56725. * @returns description string
  56726. */
  56727. getDescription(): string;
  56728. /**
  56729. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56730. * @param scene defines the current scene where to apply this optimization
  56731. * @param optimizer defines the current optimizer
  56732. * @returns true if everything that can be done was applied
  56733. */
  56734. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56735. }
  56736. /**
  56737. * Defines an optimization used to turn particles off
  56738. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56739. */
  56740. export class ParticlesOptimization extends SceneOptimization {
  56741. /**
  56742. * Gets a string describing the action executed by the current optimization
  56743. * @return description string
  56744. */
  56745. getDescription(): string;
  56746. /**
  56747. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56748. * @param scene defines the current scene where to apply this optimization
  56749. * @param optimizer defines the current optimizer
  56750. * @returns true if everything that can be done was applied
  56751. */
  56752. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56753. }
  56754. /**
  56755. * Defines an optimization used to turn render targets off
  56756. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56757. */
  56758. export class RenderTargetsOptimization extends SceneOptimization {
  56759. /**
  56760. * Gets a string describing the action executed by the current optimization
  56761. * @return description string
  56762. */
  56763. getDescription(): string;
  56764. /**
  56765. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56766. * @param scene defines the current scene where to apply this optimization
  56767. * @param optimizer defines the current optimizer
  56768. * @returns true if everything that can be done was applied
  56769. */
  56770. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56771. }
  56772. /**
  56773. * Defines an optimization used to merge meshes with compatible materials
  56774. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56775. */
  56776. export class MergeMeshesOptimization extends SceneOptimization {
  56777. private static _UpdateSelectionTree;
  56778. /**
  56779. * Gets or sets a boolean which defines if optimization octree has to be updated
  56780. */
  56781. /**
  56782. * Gets or sets a boolean which defines if optimization octree has to be updated
  56783. */
  56784. static UpdateSelectionTree: boolean;
  56785. /**
  56786. * Gets a string describing the action executed by the current optimization
  56787. * @return description string
  56788. */
  56789. getDescription(): string;
  56790. private _canBeMerged;
  56791. /**
  56792. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56793. * @param scene defines the current scene where to apply this optimization
  56794. * @param optimizer defines the current optimizer
  56795. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  56796. * @returns true if everything that can be done was applied
  56797. */
  56798. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  56799. }
  56800. /**
  56801. * Defines a list of options used by SceneOptimizer
  56802. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56803. */
  56804. export class SceneOptimizerOptions {
  56805. /**
  56806. * Defines the target frame rate to reach (60 by default)
  56807. */
  56808. targetFrameRate: number;
  56809. /**
  56810. * Defines the interval between two checkes (2000ms by default)
  56811. */
  56812. trackerDuration: number;
  56813. /**
  56814. * Gets the list of optimizations to apply
  56815. */
  56816. optimizations: SceneOptimization[];
  56817. /**
  56818. * Creates a new list of options used by SceneOptimizer
  56819. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  56820. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  56821. */
  56822. constructor(
  56823. /**
  56824. * Defines the target frame rate to reach (60 by default)
  56825. */
  56826. targetFrameRate?: number,
  56827. /**
  56828. * Defines the interval between two checkes (2000ms by default)
  56829. */
  56830. trackerDuration?: number);
  56831. /**
  56832. * Add a new optimization
  56833. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  56834. * @returns the current SceneOptimizerOptions
  56835. */
  56836. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  56837. /**
  56838. * Add a new custom optimization
  56839. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  56840. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  56841. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56842. * @returns the current SceneOptimizerOptions
  56843. */
  56844. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  56845. /**
  56846. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  56847. * @param targetFrameRate defines the target frame rate (60 by default)
  56848. * @returns a SceneOptimizerOptions object
  56849. */
  56850. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56851. /**
  56852. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  56853. * @param targetFrameRate defines the target frame rate (60 by default)
  56854. * @returns a SceneOptimizerOptions object
  56855. */
  56856. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56857. /**
  56858. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  56859. * @param targetFrameRate defines the target frame rate (60 by default)
  56860. * @returns a SceneOptimizerOptions object
  56861. */
  56862. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56863. }
  56864. /**
  56865. * Class used to run optimizations in order to reach a target frame rate
  56866. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56867. */
  56868. export class SceneOptimizer implements IDisposable {
  56869. private _isRunning;
  56870. private _options;
  56871. private _scene;
  56872. private _currentPriorityLevel;
  56873. private _targetFrameRate;
  56874. private _trackerDuration;
  56875. private _currentFrameRate;
  56876. private _sceneDisposeObserver;
  56877. private _improvementMode;
  56878. /**
  56879. * Defines an observable called when the optimizer reaches the target frame rate
  56880. */
  56881. onSuccessObservable: Observable<SceneOptimizer>;
  56882. /**
  56883. * Defines an observable called when the optimizer enables an optimization
  56884. */
  56885. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  56886. /**
  56887. * Defines an observable called when the optimizer is not able to reach the target frame rate
  56888. */
  56889. onFailureObservable: Observable<SceneOptimizer>;
  56890. /**
  56891. * Gets a boolean indicating if the optimizer is in improvement mode
  56892. */
  56893. readonly isInImprovementMode: boolean;
  56894. /**
  56895. * Gets the current priority level (0 at start)
  56896. */
  56897. readonly currentPriorityLevel: number;
  56898. /**
  56899. * Gets the current frame rate checked by the SceneOptimizer
  56900. */
  56901. readonly currentFrameRate: number;
  56902. /**
  56903. * Gets or sets the current target frame rate (60 by default)
  56904. */
  56905. /**
  56906. * Gets or sets the current target frame rate (60 by default)
  56907. */
  56908. targetFrameRate: number;
  56909. /**
  56910. * Gets or sets the current interval between two checks (every 2000ms by default)
  56911. */
  56912. /**
  56913. * Gets or sets the current interval between two checks (every 2000ms by default)
  56914. */
  56915. trackerDuration: number;
  56916. /**
  56917. * Gets the list of active optimizations
  56918. */
  56919. readonly optimizations: SceneOptimization[];
  56920. /**
  56921. * Creates a new SceneOptimizer
  56922. * @param scene defines the scene to work on
  56923. * @param options defines the options to use with the SceneOptimizer
  56924. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  56925. * @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)
  56926. */
  56927. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  56928. /**
  56929. * Stops the current optimizer
  56930. */
  56931. stop(): void;
  56932. /**
  56933. * Reset the optimizer to initial step (current priority level = 0)
  56934. */
  56935. reset(): void;
  56936. /**
  56937. * Start the optimizer. By default it will try to reach a specific framerate
  56938. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  56939. */
  56940. start(): void;
  56941. private _checkCurrentState;
  56942. /**
  56943. * Release all resources
  56944. */
  56945. dispose(): void;
  56946. /**
  56947. * Helper function to create a SceneOptimizer with one single line of code
  56948. * @param scene defines the scene to work on
  56949. * @param options defines the options to use with the SceneOptimizer
  56950. * @param onSuccess defines a callback to call on success
  56951. * @param onFailure defines a callback to call on failure
  56952. * @returns the new SceneOptimizer object
  56953. */
  56954. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  56955. }
  56956. }
  56957. declare module "babylonjs/Misc/sceneSerializer" {
  56958. import { Scene } from "babylonjs/scene";
  56959. /**
  56960. * Class used to serialize a scene into a string
  56961. */
  56962. export class SceneSerializer {
  56963. /**
  56964. * Clear cache used by a previous serialization
  56965. */
  56966. static ClearCache(): void;
  56967. /**
  56968. * Serialize a scene into a JSON compatible object
  56969. * @param scene defines the scene to serialize
  56970. * @returns a JSON compatible object
  56971. */
  56972. static Serialize(scene: Scene): any;
  56973. /**
  56974. * Serialize a mesh into a JSON compatible object
  56975. * @param toSerialize defines the mesh to serialize
  56976. * @param withParents defines if parents must be serialized as well
  56977. * @param withChildren defines if children must be serialized as well
  56978. * @returns a JSON compatible object
  56979. */
  56980. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  56981. }
  56982. }
  56983. declare module "babylonjs/Misc/videoRecorder" {
  56984. import { Nullable } from "babylonjs/types";
  56985. import { Engine } from "babylonjs/Engines/engine";
  56986. /**
  56987. * This represents the different options avilable for the video capture.
  56988. */
  56989. export interface VideoRecorderOptions {
  56990. /** Defines the mime type of the video */
  56991. mimeType: string;
  56992. /** Defines the video the video should be recorded at */
  56993. fps: number;
  56994. /** Defines the chunk size for the recording data */
  56995. recordChunckSize: number;
  56996. /** The audio tracks to attach to the record */
  56997. audioTracks?: MediaStreamTrack[];
  56998. }
  56999. /**
  57000. * This can helps recording videos from BabylonJS.
  57001. * This is based on the available WebRTC functionalities of the browser.
  57002. *
  57003. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  57004. */
  57005. export class VideoRecorder {
  57006. private static readonly _defaultOptions;
  57007. /**
  57008. * Returns wehther or not the VideoRecorder is available in your browser.
  57009. * @param engine Defines the Babylon Engine to check the support for
  57010. * @returns true if supported otherwise false
  57011. */
  57012. static IsSupported(engine: Engine): boolean;
  57013. private readonly _options;
  57014. private _canvas;
  57015. private _mediaRecorder;
  57016. private _recordedChunks;
  57017. private _fileName;
  57018. private _resolve;
  57019. private _reject;
  57020. /**
  57021. * True wether a recording is already in progress.
  57022. */
  57023. readonly isRecording: boolean;
  57024. /**
  57025. * Create a new VideoCapture object which can help converting what you see in Babylon to
  57026. * a video file.
  57027. * @param engine Defines the BabylonJS Engine you wish to record
  57028. * @param options Defines options that can be used to customized the capture
  57029. */
  57030. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  57031. /**
  57032. * Stops the current recording before the default capture timeout passed in the startRecording
  57033. * functions.
  57034. */
  57035. stopRecording(): void;
  57036. /**
  57037. * Starts recording the canvas for a max duration specified in parameters.
  57038. * @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.
  57039. * @param maxDuration Defines the maximum recording time in seconds.
  57040. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  57041. * @return a promise callback at the end of the recording with the video data in Blob.
  57042. */
  57043. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  57044. /**
  57045. * Releases internal resources used during the recording.
  57046. */
  57047. dispose(): void;
  57048. private _handleDataAvailable;
  57049. private _handleError;
  57050. private _handleStop;
  57051. }
  57052. }
  57053. declare module "babylonjs/Misc/workerPool" {
  57054. import { IDisposable } from "babylonjs/scene";
  57055. /**
  57056. * Helper class to push actions to a pool of workers.
  57057. */
  57058. export class WorkerPool implements IDisposable {
  57059. private _workerInfos;
  57060. private _pendingActions;
  57061. /**
  57062. * Constructor
  57063. * @param workers Array of workers to use for actions
  57064. */
  57065. constructor(workers: Array<Worker>);
  57066. /**
  57067. * Terminates all workers and clears any pending actions.
  57068. */
  57069. dispose(): void;
  57070. /**
  57071. * Pushes an action to the worker pool. If all the workers are active, the action will be
  57072. * pended until a worker has completed its action.
  57073. * @param action The action to perform. Call onComplete when the action is complete.
  57074. */
  57075. push(action: (worker: Worker, onComplete: () => void) => void): void;
  57076. private _execute;
  57077. }
  57078. }
  57079. declare module "babylonjs/Misc/screenshotTools" {
  57080. import { Camera } from "babylonjs/Cameras/camera";
  57081. import { Engine } from "babylonjs/Engines/engine";
  57082. /**
  57083. * Class containing a set of static utilities functions for screenshots
  57084. */
  57085. export class ScreenshotTools {
  57086. /**
  57087. * Captures a screenshot of the current rendering
  57088. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  57089. * @param engine defines the rendering engine
  57090. * @param camera defines the source camera
  57091. * @param size This parameter can be set to a single number or to an object with the
  57092. * following (optional) properties: precision, width, height. If a single number is passed,
  57093. * it will be used for both width and height. If an object is passed, the screenshot size
  57094. * will be derived from the parameters. The precision property is a multiplier allowing
  57095. * rendering at a higher or lower resolution
  57096. * @param successCallback defines the callback receives a single parameter which contains the
  57097. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  57098. * src parameter of an <img> to display it
  57099. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  57100. * Check your browser for supported MIME types
  57101. */
  57102. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  57103. /**
  57104. * Generates an image screenshot from the specified camera.
  57105. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  57106. * @param engine The engine to use for rendering
  57107. * @param camera The camera to use for rendering
  57108. * @param size This parameter can be set to a single number or to an object with the
  57109. * following (optional) properties: precision, width, height. If a single number is passed,
  57110. * it will be used for both width and height. If an object is passed, the screenshot size
  57111. * will be derived from the parameters. The precision property is a multiplier allowing
  57112. * rendering at a higher or lower resolution
  57113. * @param successCallback The callback receives a single parameter which contains the
  57114. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  57115. * src parameter of an <img> to display it
  57116. * @param mimeType The MIME type of the screenshot image (default: image/png).
  57117. * Check your browser for supported MIME types
  57118. * @param samples Texture samples (default: 1)
  57119. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  57120. * @param fileName A name for for the downloaded file.
  57121. */
  57122. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  57123. }
  57124. }
  57125. declare module "babylonjs/Misc/index" {
  57126. export * from "babylonjs/Misc/andOrNotEvaluator";
  57127. export * from "babylonjs/Misc/assetsManager";
  57128. export * from "babylonjs/Misc/dds";
  57129. export * from "babylonjs/Misc/decorators";
  57130. export * from "babylonjs/Misc/deferred";
  57131. export * from "babylonjs/Misc/environmentTextureTools";
  57132. export * from "babylonjs/Misc/meshExploder";
  57133. export * from "babylonjs/Misc/filesInput";
  57134. export * from "babylonjs/Misc/HighDynamicRange/index";
  57135. export * from "babylonjs/Misc/khronosTextureContainer";
  57136. export * from "babylonjs/Misc/observable";
  57137. export * from "babylonjs/Misc/performanceMonitor";
  57138. export * from "babylonjs/Misc/promise";
  57139. export * from "babylonjs/Misc/sceneOptimizer";
  57140. export * from "babylonjs/Misc/sceneSerializer";
  57141. export * from "babylonjs/Misc/smartArray";
  57142. export * from "babylonjs/Misc/stringDictionary";
  57143. export * from "babylonjs/Misc/tags";
  57144. export * from "babylonjs/Misc/textureTools";
  57145. export * from "babylonjs/Misc/tga";
  57146. export * from "babylonjs/Misc/tools";
  57147. export * from "babylonjs/Misc/videoRecorder";
  57148. export * from "babylonjs/Misc/virtualJoystick";
  57149. export * from "babylonjs/Misc/workerPool";
  57150. export * from "babylonjs/Misc/logger";
  57151. export * from "babylonjs/Misc/typeStore";
  57152. export * from "babylonjs/Misc/filesInputStore";
  57153. export * from "babylonjs/Misc/deepCopier";
  57154. export * from "babylonjs/Misc/pivotTools";
  57155. export * from "babylonjs/Misc/precisionDate";
  57156. export * from "babylonjs/Misc/screenshotTools";
  57157. export * from "babylonjs/Misc/typeStore";
  57158. export * from "babylonjs/Misc/webRequest";
  57159. }
  57160. declare module "babylonjs/index" {
  57161. export * from "babylonjs/abstractScene";
  57162. export * from "babylonjs/Actions/index";
  57163. export * from "babylonjs/Animations/index";
  57164. export * from "babylonjs/assetContainer";
  57165. export * from "babylonjs/Audio/index";
  57166. export * from "babylonjs/Behaviors/index";
  57167. export * from "babylonjs/Bones/index";
  57168. export * from "babylonjs/Cameras/index";
  57169. export * from "babylonjs/Collisions/index";
  57170. export * from "babylonjs/Culling/index";
  57171. export * from "babylonjs/Debug/index";
  57172. export * from "babylonjs/Engines/index";
  57173. export * from "babylonjs/Events/index";
  57174. export * from "babylonjs/Gamepads/index";
  57175. export * from "babylonjs/Gizmos/index";
  57176. export * from "babylonjs/Helpers/index";
  57177. export * from "babylonjs/Instrumentation/index";
  57178. export * from "babylonjs/Layers/index";
  57179. export * from "babylonjs/LensFlares/index";
  57180. export * from "babylonjs/Lights/index";
  57181. export * from "babylonjs/Loading/index";
  57182. export * from "babylonjs/Materials/index";
  57183. export * from "babylonjs/Maths/index";
  57184. export * from "babylonjs/Meshes/index";
  57185. export * from "babylonjs/Morph/index";
  57186. export * from "babylonjs/node";
  57187. export * from "babylonjs/Offline/index";
  57188. export * from "babylonjs/Particles/index";
  57189. export * from "babylonjs/Physics/index";
  57190. export * from "babylonjs/PostProcesses/index";
  57191. export * from "babylonjs/Probes/index";
  57192. export * from "babylonjs/Rendering/index";
  57193. export * from "babylonjs/scene";
  57194. export * from "babylonjs/sceneComponent";
  57195. export * from "babylonjs/Sprites/index";
  57196. export * from "babylonjs/States/index";
  57197. export * from "babylonjs/Misc/index";
  57198. export * from "babylonjs/types";
  57199. }
  57200. declare module "babylonjs/Animations/pathCursor" {
  57201. import { Path2, Vector3 } from "babylonjs/Maths/math";
  57202. /**
  57203. * A cursor which tracks a point on a path
  57204. */
  57205. export class PathCursor {
  57206. private path;
  57207. /**
  57208. * Stores path cursor callbacks for when an onchange event is triggered
  57209. */
  57210. private _onchange;
  57211. /**
  57212. * The value of the path cursor
  57213. */
  57214. value: number;
  57215. /**
  57216. * The animation array of the path cursor
  57217. */
  57218. animations: Animation[];
  57219. /**
  57220. * Initializes the path cursor
  57221. * @param path The path to track
  57222. */
  57223. constructor(path: Path2);
  57224. /**
  57225. * Gets the cursor point on the path
  57226. * @returns A point on the path cursor at the cursor location
  57227. */
  57228. getPoint(): Vector3;
  57229. /**
  57230. * Moves the cursor ahead by the step amount
  57231. * @param step The amount to move the cursor forward
  57232. * @returns This path cursor
  57233. */
  57234. moveAhead(step?: number): PathCursor;
  57235. /**
  57236. * Moves the cursor behind by the step amount
  57237. * @param step The amount to move the cursor back
  57238. * @returns This path cursor
  57239. */
  57240. moveBack(step?: number): PathCursor;
  57241. /**
  57242. * Moves the cursor by the step amount
  57243. * If the step amount is greater than one, an exception is thrown
  57244. * @param step The amount to move the cursor
  57245. * @returns This path cursor
  57246. */
  57247. move(step: number): PathCursor;
  57248. /**
  57249. * Ensures that the value is limited between zero and one
  57250. * @returns This path cursor
  57251. */
  57252. private ensureLimits;
  57253. /**
  57254. * Runs onchange callbacks on change (used by the animation engine)
  57255. * @returns This path cursor
  57256. */
  57257. private raiseOnChange;
  57258. /**
  57259. * Executes a function on change
  57260. * @param f A path cursor onchange callback
  57261. * @returns This path cursor
  57262. */
  57263. onchange(f: (cursor: PathCursor) => void): PathCursor;
  57264. }
  57265. }
  57266. declare module "babylonjs/Legacy/legacy" {
  57267. import * as Babylon from "babylonjs/index";
  57268. export * from "babylonjs/index";
  57269. }
  57270. declare module "babylonjs/Shaders/blur.fragment" {
  57271. /** @hidden */
  57272. export var blurPixelShader: {
  57273. name: string;
  57274. shader: string;
  57275. };
  57276. }
  57277. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  57278. /** @hidden */
  57279. export var bones300Declaration: {
  57280. name: string;
  57281. shader: string;
  57282. };
  57283. }
  57284. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  57285. /** @hidden */
  57286. export var instances300Declaration: {
  57287. name: string;
  57288. shader: string;
  57289. };
  57290. }
  57291. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  57292. /** @hidden */
  57293. export var pointCloudVertexDeclaration: {
  57294. name: string;
  57295. shader: string;
  57296. };
  57297. }
  57298. // Mixins
  57299. interface Window {
  57300. mozIndexedDB: IDBFactory;
  57301. webkitIndexedDB: IDBFactory;
  57302. msIndexedDB: IDBFactory;
  57303. webkitURL: typeof URL;
  57304. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  57305. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  57306. WebGLRenderingContext: WebGLRenderingContext;
  57307. MSGesture: MSGesture;
  57308. CANNON: any;
  57309. AudioContext: AudioContext;
  57310. webkitAudioContext: AudioContext;
  57311. PointerEvent: any;
  57312. Math: Math;
  57313. Uint8Array: Uint8ArrayConstructor;
  57314. Float32Array: Float32ArrayConstructor;
  57315. mozURL: typeof URL;
  57316. msURL: typeof URL;
  57317. VRFrameData: any; // WebVR, from specs 1.1
  57318. DracoDecoderModule: any;
  57319. setImmediate(handler: (...args: any[]) => void): number;
  57320. }
  57321. interface HTMLCanvasElement {
  57322. requestPointerLock(): void;
  57323. msRequestPointerLock?(): void;
  57324. mozRequestPointerLock?(): void;
  57325. webkitRequestPointerLock?(): void;
  57326. /** Track wether a record is in progress */
  57327. isRecording: boolean;
  57328. /** Capture Stream method defined by some browsers */
  57329. captureStream(fps?: number): MediaStream;
  57330. }
  57331. interface CanvasRenderingContext2D {
  57332. msImageSmoothingEnabled: boolean;
  57333. }
  57334. interface MouseEvent {
  57335. mozMovementX: number;
  57336. mozMovementY: number;
  57337. webkitMovementX: number;
  57338. webkitMovementY: number;
  57339. msMovementX: number;
  57340. msMovementY: number;
  57341. }
  57342. interface Navigator {
  57343. mozGetVRDevices: (any: any) => any;
  57344. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  57345. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  57346. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  57347. webkitGetGamepads(): Gamepad[];
  57348. msGetGamepads(): Gamepad[];
  57349. webkitGamepads(): Gamepad[];
  57350. }
  57351. interface HTMLVideoElement {
  57352. mozSrcObject: any;
  57353. }
  57354. interface Math {
  57355. fround(x: number): number;
  57356. imul(a: number, b: number): number;
  57357. }
  57358. interface WebGLProgram {
  57359. context?: WebGLRenderingContext;
  57360. vertexShader?: WebGLShader;
  57361. fragmentShader?: WebGLShader;
  57362. isParallelCompiled: boolean;
  57363. onCompiled?: () => void;
  57364. }
  57365. interface WebGLRenderingContext {
  57366. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  57367. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  57368. vertexAttribDivisor(index: number, divisor: number): void;
  57369. createVertexArray(): any;
  57370. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  57371. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  57372. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  57373. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  57374. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  57375. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  57376. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  57377. // Queries
  57378. createQuery(): WebGLQuery;
  57379. deleteQuery(query: WebGLQuery): void;
  57380. beginQuery(target: number, query: WebGLQuery): void;
  57381. endQuery(target: number): void;
  57382. getQueryParameter(query: WebGLQuery, pname: number): any;
  57383. getQuery(target: number, pname: number): any;
  57384. MAX_SAMPLES: number;
  57385. RGBA8: number;
  57386. READ_FRAMEBUFFER: number;
  57387. DRAW_FRAMEBUFFER: number;
  57388. UNIFORM_BUFFER: number;
  57389. HALF_FLOAT_OES: number;
  57390. RGBA16F: number;
  57391. RGBA32F: number;
  57392. R32F: number;
  57393. RG32F: number;
  57394. RGB32F: number;
  57395. R16F: number;
  57396. RG16F: number;
  57397. RGB16F: number;
  57398. RED: number;
  57399. RG: number;
  57400. R8: number;
  57401. RG8: number;
  57402. UNSIGNED_INT_24_8: number;
  57403. DEPTH24_STENCIL8: number;
  57404. /* Multiple Render Targets */
  57405. drawBuffers(buffers: number[]): void;
  57406. readBuffer(src: number): void;
  57407. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  57408. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  57409. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  57410. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  57411. // Occlusion Query
  57412. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  57413. ANY_SAMPLES_PASSED: number;
  57414. QUERY_RESULT_AVAILABLE: number;
  57415. QUERY_RESULT: number;
  57416. }
  57417. interface WebGLBuffer {
  57418. references: number;
  57419. capacity: number;
  57420. is32Bits: boolean;
  57421. }
  57422. interface WebGLProgram {
  57423. transformFeedback?: WebGLTransformFeedback | null;
  57424. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  57425. }
  57426. interface EXT_disjoint_timer_query {
  57427. QUERY_COUNTER_BITS_EXT: number;
  57428. TIME_ELAPSED_EXT: number;
  57429. TIMESTAMP_EXT: number;
  57430. GPU_DISJOINT_EXT: number;
  57431. QUERY_RESULT_EXT: number;
  57432. QUERY_RESULT_AVAILABLE_EXT: number;
  57433. queryCounterEXT(query: WebGLQuery, target: number): void;
  57434. createQueryEXT(): WebGLQuery;
  57435. beginQueryEXT(target: number, query: WebGLQuery): void;
  57436. endQueryEXT(target: number): void;
  57437. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  57438. deleteQueryEXT(query: WebGLQuery): void;
  57439. }
  57440. interface WebGLUniformLocation {
  57441. _currentState: any;
  57442. }
  57443. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  57444. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  57445. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  57446. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  57447. interface WebGLRenderingContext {
  57448. readonly RASTERIZER_DISCARD: number;
  57449. readonly DEPTH_COMPONENT24: number;
  57450. readonly TEXTURE_3D: number;
  57451. readonly TEXTURE_2D_ARRAY: number;
  57452. readonly TEXTURE_COMPARE_FUNC: number;
  57453. readonly TEXTURE_COMPARE_MODE: number;
  57454. readonly COMPARE_REF_TO_TEXTURE: number;
  57455. readonly TEXTURE_WRAP_R: number;
  57456. readonly HALF_FLOAT: number;
  57457. readonly RGB8: number;
  57458. readonly RED_INTEGER: number;
  57459. readonly RG_INTEGER: number;
  57460. readonly RGB_INTEGER: number;
  57461. readonly RGBA_INTEGER: number;
  57462. readonly R8_SNORM: number;
  57463. readonly RG8_SNORM: number;
  57464. readonly RGB8_SNORM: number;
  57465. readonly RGBA8_SNORM: number;
  57466. readonly R8I: number;
  57467. readonly RG8I: number;
  57468. readonly RGB8I: number;
  57469. readonly RGBA8I: number;
  57470. readonly R8UI: number;
  57471. readonly RG8UI: number;
  57472. readonly RGB8UI: number;
  57473. readonly RGBA8UI: number;
  57474. readonly R16I: number;
  57475. readonly RG16I: number;
  57476. readonly RGB16I: number;
  57477. readonly RGBA16I: number;
  57478. readonly R16UI: number;
  57479. readonly RG16UI: number;
  57480. readonly RGB16UI: number;
  57481. readonly RGBA16UI: number;
  57482. readonly R32I: number;
  57483. readonly RG32I: number;
  57484. readonly RGB32I: number;
  57485. readonly RGBA32I: number;
  57486. readonly R32UI: number;
  57487. readonly RG32UI: number;
  57488. readonly RGB32UI: number;
  57489. readonly RGBA32UI: number;
  57490. readonly RGB10_A2UI: number;
  57491. readonly R11F_G11F_B10F: number;
  57492. readonly RGB9_E5: number;
  57493. readonly RGB10_A2: number;
  57494. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  57495. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  57496. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  57497. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  57498. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  57499. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  57500. 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;
  57501. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  57502. readonly TRANSFORM_FEEDBACK: number;
  57503. readonly INTERLEAVED_ATTRIBS: number;
  57504. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  57505. createTransformFeedback(): WebGLTransformFeedback;
  57506. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  57507. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  57508. beginTransformFeedback(primitiveMode: number): void;
  57509. endTransformFeedback(): void;
  57510. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  57511. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57512. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57513. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57514. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  57515. }
  57516. interface ImageBitmap {
  57517. readonly width: number;
  57518. readonly height: number;
  57519. close(): void;
  57520. }
  57521. interface WebGLQuery extends WebGLObject {
  57522. }
  57523. declare var WebGLQuery: {
  57524. prototype: WebGLQuery;
  57525. new(): WebGLQuery;
  57526. };
  57527. interface WebGLSampler extends WebGLObject {
  57528. }
  57529. declare var WebGLSampler: {
  57530. prototype: WebGLSampler;
  57531. new(): WebGLSampler;
  57532. };
  57533. interface WebGLSync extends WebGLObject {
  57534. }
  57535. declare var WebGLSync: {
  57536. prototype: WebGLSync;
  57537. new(): WebGLSync;
  57538. };
  57539. interface WebGLTransformFeedback extends WebGLObject {
  57540. }
  57541. declare var WebGLTransformFeedback: {
  57542. prototype: WebGLTransformFeedback;
  57543. new(): WebGLTransformFeedback;
  57544. };
  57545. interface WebGLVertexArrayObject extends WebGLObject {
  57546. }
  57547. declare var WebGLVertexArrayObject: {
  57548. prototype: WebGLVertexArrayObject;
  57549. new(): WebGLVertexArrayObject;
  57550. };
  57551. // Type definitions for WebVR API
  57552. // Project: https://w3c.github.io/webvr/
  57553. // Definitions by: six a <https://github.com/lostfictions>
  57554. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  57555. interface VRDisplay extends EventTarget {
  57556. /**
  57557. * Dictionary of capabilities describing the VRDisplay.
  57558. */
  57559. readonly capabilities: VRDisplayCapabilities;
  57560. /**
  57561. * z-depth defining the far plane of the eye view frustum
  57562. * enables mapping of values in the render target depth
  57563. * attachment to scene coordinates. Initially set to 10000.0.
  57564. */
  57565. depthFar: number;
  57566. /**
  57567. * z-depth defining the near plane of the eye view frustum
  57568. * enables mapping of values in the render target depth
  57569. * attachment to scene coordinates. Initially set to 0.01.
  57570. */
  57571. depthNear: number;
  57572. /**
  57573. * An identifier for this distinct VRDisplay. Used as an
  57574. * association point in the Gamepad API.
  57575. */
  57576. readonly displayId: number;
  57577. /**
  57578. * A display name, a user-readable name identifying it.
  57579. */
  57580. readonly displayName: string;
  57581. readonly isConnected: boolean;
  57582. readonly isPresenting: boolean;
  57583. /**
  57584. * If this VRDisplay supports room-scale experiences, the optional
  57585. * stage attribute contains details on the room-scale parameters.
  57586. */
  57587. readonly stageParameters: VRStageParameters | null;
  57588. /**
  57589. * Passing the value returned by `requestAnimationFrame` to
  57590. * `cancelAnimationFrame` will unregister the callback.
  57591. * @param handle Define the hanle of the request to cancel
  57592. */
  57593. cancelAnimationFrame(handle: number): void;
  57594. /**
  57595. * Stops presenting to the VRDisplay.
  57596. * @returns a promise to know when it stopped
  57597. */
  57598. exitPresent(): Promise<void>;
  57599. /**
  57600. * Return the current VREyeParameters for the given eye.
  57601. * @param whichEye Define the eye we want the parameter for
  57602. * @returns the eye parameters
  57603. */
  57604. getEyeParameters(whichEye: string): VREyeParameters;
  57605. /**
  57606. * Populates the passed VRFrameData with the information required to render
  57607. * the current frame.
  57608. * @param frameData Define the data structure to populate
  57609. * @returns true if ok otherwise false
  57610. */
  57611. getFrameData(frameData: VRFrameData): boolean;
  57612. /**
  57613. * Get the layers currently being presented.
  57614. * @returns the list of VR layers
  57615. */
  57616. getLayers(): VRLayer[];
  57617. /**
  57618. * Return a VRPose containing the future predicted pose of the VRDisplay
  57619. * when the current frame will be presented. The value returned will not
  57620. * change until JavaScript has returned control to the browser.
  57621. *
  57622. * The VRPose will contain the position, orientation, velocity,
  57623. * and acceleration of each of these properties.
  57624. * @returns the pose object
  57625. */
  57626. getPose(): VRPose;
  57627. /**
  57628. * Return the current instantaneous pose of the VRDisplay, with no
  57629. * prediction applied.
  57630. * @returns the current instantaneous pose
  57631. */
  57632. getImmediatePose(): VRPose;
  57633. /**
  57634. * The callback passed to `requestAnimationFrame` will be called
  57635. * any time a new frame should be rendered. When the VRDisplay is
  57636. * presenting the callback will be called at the native refresh
  57637. * rate of the HMD. When not presenting this function acts
  57638. * identically to how window.requestAnimationFrame acts. Content should
  57639. * make no assumptions of frame rate or vsync behavior as the HMD runs
  57640. * asynchronously from other displays and at differing refresh rates.
  57641. * @param callback Define the eaction to run next frame
  57642. * @returns the request handle it
  57643. */
  57644. requestAnimationFrame(callback: FrameRequestCallback): number;
  57645. /**
  57646. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  57647. * Repeat calls while already presenting will update the VRLayers being displayed.
  57648. * @param layers Define the list of layer to present
  57649. * @returns a promise to know when the request has been fulfilled
  57650. */
  57651. requestPresent(layers: VRLayer[]): Promise<void>;
  57652. /**
  57653. * Reset the pose for this display, treating its current position and
  57654. * orientation as the "origin/zero" values. VRPose.position,
  57655. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  57656. * updated when calling resetPose(). This should be called in only
  57657. * sitting-space experiences.
  57658. */
  57659. resetPose(): void;
  57660. /**
  57661. * The VRLayer provided to the VRDisplay will be captured and presented
  57662. * in the HMD. Calling this function has the same effect on the source
  57663. * canvas as any other operation that uses its source image, and canvases
  57664. * created without preserveDrawingBuffer set to true will be cleared.
  57665. * @param pose Define the pose to submit
  57666. */
  57667. submitFrame(pose?: VRPose): void;
  57668. }
  57669. declare var VRDisplay: {
  57670. prototype: VRDisplay;
  57671. new(): VRDisplay;
  57672. };
  57673. interface VRLayer {
  57674. leftBounds?: number[] | Float32Array | null;
  57675. rightBounds?: number[] | Float32Array | null;
  57676. source?: HTMLCanvasElement | null;
  57677. }
  57678. interface VRDisplayCapabilities {
  57679. readonly canPresent: boolean;
  57680. readonly hasExternalDisplay: boolean;
  57681. readonly hasOrientation: boolean;
  57682. readonly hasPosition: boolean;
  57683. readonly maxLayers: number;
  57684. }
  57685. interface VREyeParameters {
  57686. /** @deprecated */
  57687. readonly fieldOfView: VRFieldOfView;
  57688. readonly offset: Float32Array;
  57689. readonly renderHeight: number;
  57690. readonly renderWidth: number;
  57691. }
  57692. interface VRFieldOfView {
  57693. readonly downDegrees: number;
  57694. readonly leftDegrees: number;
  57695. readonly rightDegrees: number;
  57696. readonly upDegrees: number;
  57697. }
  57698. interface VRFrameData {
  57699. readonly leftProjectionMatrix: Float32Array;
  57700. readonly leftViewMatrix: Float32Array;
  57701. readonly pose: VRPose;
  57702. readonly rightProjectionMatrix: Float32Array;
  57703. readonly rightViewMatrix: Float32Array;
  57704. readonly timestamp: number;
  57705. }
  57706. interface VRPose {
  57707. readonly angularAcceleration: Float32Array | null;
  57708. readonly angularVelocity: Float32Array | null;
  57709. readonly linearAcceleration: Float32Array | null;
  57710. readonly linearVelocity: Float32Array | null;
  57711. readonly orientation: Float32Array | null;
  57712. readonly position: Float32Array | null;
  57713. readonly timestamp: number;
  57714. }
  57715. interface VRStageParameters {
  57716. sittingToStandingTransform?: Float32Array;
  57717. sizeX?: number;
  57718. sizeY?: number;
  57719. }
  57720. interface Navigator {
  57721. getVRDisplays(): Promise<VRDisplay[]>;
  57722. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  57723. }
  57724. interface Window {
  57725. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  57726. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  57727. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  57728. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  57729. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  57730. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  57731. }
  57732. interface Gamepad {
  57733. readonly displayId: number;
  57734. }
  57735. interface XRDevice {
  57736. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  57737. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  57738. }
  57739. interface XRSession {
  57740. getInputSources(): Array<any>;
  57741. baseLayer: XRWebGLLayer;
  57742. requestFrameOfReference(type: string): Promise<void>;
  57743. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  57744. end(): Promise<void>;
  57745. requestAnimationFrame: Function;
  57746. addEventListener: Function;
  57747. }
  57748. interface XRSessionCreationOptions {
  57749. outputContext?: WebGLRenderingContext | null;
  57750. immersive?: boolean;
  57751. environmentIntegration?: boolean;
  57752. }
  57753. interface XRLayer {
  57754. getViewport: Function;
  57755. framebufferWidth: number;
  57756. framebufferHeight: number;
  57757. }
  57758. interface XRView {
  57759. projectionMatrix: Float32Array;
  57760. }
  57761. interface XRFrame {
  57762. getDevicePose: Function;
  57763. getInputPose: Function;
  57764. views: Array<XRView>;
  57765. baseLayer: XRLayer;
  57766. }
  57767. interface XRFrameOfReference {
  57768. }
  57769. interface XRWebGLLayer extends XRLayer {
  57770. framebuffer: WebGLFramebuffer;
  57771. }
  57772. declare var XRWebGLLayer: {
  57773. prototype: XRWebGLLayer;
  57774. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  57775. };
  57776. declare module "babylonjs" {
  57777. export * from "babylonjs/Legacy/legacy";
  57778. }
  57779. declare module BABYLON {
  57780. /** Alias type for value that can be null */
  57781. export type Nullable<T> = T | null;
  57782. /**
  57783. * Alias type for number that are floats
  57784. * @ignorenaming
  57785. */
  57786. export type float = number;
  57787. /**
  57788. * Alias type for number that are doubles.
  57789. * @ignorenaming
  57790. */
  57791. export type double = number;
  57792. /**
  57793. * Alias type for number that are integer
  57794. * @ignorenaming
  57795. */
  57796. export type int = number;
  57797. /** Alias type for number array or Float32Array */
  57798. export type FloatArray = number[] | Float32Array;
  57799. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  57800. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  57801. /**
  57802. * Alias for types that can be used by a Buffer or VertexBuffer.
  57803. */
  57804. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  57805. /**
  57806. * Alias type for primitive types
  57807. * @ignorenaming
  57808. */
  57809. type Primitive = undefined | null | boolean | string | number | Function;
  57810. /**
  57811. * Type modifier to make all the properties of an object Readonly
  57812. */
  57813. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  57814. /**
  57815. * Type modifier to make all the properties of an object Readonly recursively
  57816. */
  57817. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  57818. /** @hidden */
  57819. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  57820. }
  57821. /** @hidden */
  57822. /** @hidden */
  57823. type DeepImmutableObject<T> = {
  57824. readonly [K in keyof T]: DeepImmutable<T[K]>;
  57825. };
  57826. }
  57827. declare module BABYLON {
  57828. /**
  57829. * Class containing a set of static utilities functions for arrays.
  57830. */
  57831. export class ArrayTools {
  57832. /**
  57833. * Returns an array of the given size filled with element built from the given constructor and the paramters
  57834. * @param size the number of element to construct and put in the array
  57835. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  57836. * @returns a new array filled with new objects
  57837. */
  57838. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  57839. }
  57840. }
  57841. declare module BABYLON {
  57842. /**
  57843. * Scalar computation library
  57844. */
  57845. export class Scalar {
  57846. /**
  57847. * Two pi constants convenient for computation.
  57848. */
  57849. static TwoPi: number;
  57850. /**
  57851. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  57852. * @param a number
  57853. * @param b number
  57854. * @param epsilon (default = 1.401298E-45)
  57855. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  57856. */
  57857. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  57858. /**
  57859. * Returns a string : the upper case translation of the number i to hexadecimal.
  57860. * @param i number
  57861. * @returns the upper case translation of the number i to hexadecimal.
  57862. */
  57863. static ToHex(i: number): string;
  57864. /**
  57865. * Returns -1 if value is negative and +1 is value is positive.
  57866. * @param value the value
  57867. * @returns the value itself if it's equal to zero.
  57868. */
  57869. static Sign(value: number): number;
  57870. /**
  57871. * Returns the value itself if it's between min and max.
  57872. * Returns min if the value is lower than min.
  57873. * Returns max if the value is greater than max.
  57874. * @param value the value to clmap
  57875. * @param min the min value to clamp to (default: 0)
  57876. * @param max the max value to clamp to (default: 1)
  57877. * @returns the clamped value
  57878. */
  57879. static Clamp(value: number, min?: number, max?: number): number;
  57880. /**
  57881. * the log2 of value.
  57882. * @param value the value to compute log2 of
  57883. * @returns the log2 of value.
  57884. */
  57885. static Log2(value: number): number;
  57886. /**
  57887. * Loops the value, so that it is never larger than length and never smaller than 0.
  57888. *
  57889. * This is similar to the modulo operator but it works with floating point numbers.
  57890. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  57891. * With t = 5 and length = 2.5, the result would be 0.0.
  57892. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  57893. * @param value the value
  57894. * @param length the length
  57895. * @returns the looped value
  57896. */
  57897. static Repeat(value: number, length: number): number;
  57898. /**
  57899. * Normalize the value between 0.0 and 1.0 using min and max values
  57900. * @param value value to normalize
  57901. * @param min max to normalize between
  57902. * @param max min to normalize between
  57903. * @returns the normalized value
  57904. */
  57905. static Normalize(value: number, min: number, max: number): number;
  57906. /**
  57907. * Denormalize the value from 0.0 and 1.0 using min and max values
  57908. * @param normalized value to denormalize
  57909. * @param min max to denormalize between
  57910. * @param max min to denormalize between
  57911. * @returns the denormalized value
  57912. */
  57913. static Denormalize(normalized: number, min: number, max: number): number;
  57914. /**
  57915. * Calculates the shortest difference between two given angles given in degrees.
  57916. * @param current current angle in degrees
  57917. * @param target target angle in degrees
  57918. * @returns the delta
  57919. */
  57920. static DeltaAngle(current: number, target: number): number;
  57921. /**
  57922. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  57923. * @param tx value
  57924. * @param length length
  57925. * @returns The returned value will move back and forth between 0 and length
  57926. */
  57927. static PingPong(tx: number, length: number): number;
  57928. /**
  57929. * Interpolates between min and max with smoothing at the limits.
  57930. *
  57931. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  57932. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  57933. * @param from from
  57934. * @param to to
  57935. * @param tx value
  57936. * @returns the smooth stepped value
  57937. */
  57938. static SmoothStep(from: number, to: number, tx: number): number;
  57939. /**
  57940. * Moves a value current towards target.
  57941. *
  57942. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  57943. * Negative values of maxDelta pushes the value away from target.
  57944. * @param current current value
  57945. * @param target target value
  57946. * @param maxDelta max distance to move
  57947. * @returns resulting value
  57948. */
  57949. static MoveTowards(current: number, target: number, maxDelta: number): number;
  57950. /**
  57951. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  57952. *
  57953. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  57954. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  57955. * @param current current value
  57956. * @param target target value
  57957. * @param maxDelta max distance to move
  57958. * @returns resulting angle
  57959. */
  57960. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  57961. /**
  57962. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  57963. * @param start start value
  57964. * @param end target value
  57965. * @param amount amount to lerp between
  57966. * @returns the lerped value
  57967. */
  57968. static Lerp(start: number, end: number, amount: number): number;
  57969. /**
  57970. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  57971. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  57972. * @param start start value
  57973. * @param end target value
  57974. * @param amount amount to lerp between
  57975. * @returns the lerped value
  57976. */
  57977. static LerpAngle(start: number, end: number, amount: number): number;
  57978. /**
  57979. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  57980. * @param a start value
  57981. * @param b target value
  57982. * @param value value between a and b
  57983. * @returns the inverseLerp value
  57984. */
  57985. static InverseLerp(a: number, b: number, value: number): number;
  57986. /**
  57987. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  57988. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  57989. * @param value1 spline value
  57990. * @param tangent1 spline value
  57991. * @param value2 spline value
  57992. * @param tangent2 spline value
  57993. * @param amount input value
  57994. * @returns hermite result
  57995. */
  57996. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  57997. /**
  57998. * Returns a random float number between and min and max values
  57999. * @param min min value of random
  58000. * @param max max value of random
  58001. * @returns random value
  58002. */
  58003. static RandomRange(min: number, max: number): number;
  58004. /**
  58005. * This function returns percentage of a number in a given range.
  58006. *
  58007. * RangeToPercent(40,20,60) will return 0.5 (50%)
  58008. * RangeToPercent(34,0,100) will return 0.34 (34%)
  58009. * @param number to convert to percentage
  58010. * @param min min range
  58011. * @param max max range
  58012. * @returns the percentage
  58013. */
  58014. static RangeToPercent(number: number, min: number, max: number): number;
  58015. /**
  58016. * This function returns number that corresponds to the percentage in a given range.
  58017. *
  58018. * PercentToRange(0.34,0,100) will return 34.
  58019. * @param percent to convert to number
  58020. * @param min min range
  58021. * @param max max range
  58022. * @returns the number
  58023. */
  58024. static PercentToRange(percent: number, min: number, max: number): number;
  58025. /**
  58026. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  58027. * @param angle The angle to normalize in radian.
  58028. * @return The converted angle.
  58029. */
  58030. static NormalizeRadians(angle: number): number;
  58031. }
  58032. }
  58033. declare module BABYLON {
  58034. /**
  58035. * Constant used to convert a value to gamma space
  58036. * @ignorenaming
  58037. */
  58038. export const ToGammaSpace: number;
  58039. /**
  58040. * Constant used to convert a value to linear space
  58041. * @ignorenaming
  58042. */
  58043. export const ToLinearSpace = 2.2;
  58044. /**
  58045. * Constant used to define the minimal number value in Babylon.js
  58046. * @ignorenaming
  58047. */
  58048. export const Epsilon = 0.001;
  58049. /**
  58050. * Class used to hold a RBG color
  58051. */
  58052. export class Color3 {
  58053. /**
  58054. * Defines the red component (between 0 and 1, default is 0)
  58055. */
  58056. r: number;
  58057. /**
  58058. * Defines the green component (between 0 and 1, default is 0)
  58059. */
  58060. g: number;
  58061. /**
  58062. * Defines the blue component (between 0 and 1, default is 0)
  58063. */
  58064. b: number;
  58065. /**
  58066. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  58067. * @param r defines the red component (between 0 and 1, default is 0)
  58068. * @param g defines the green component (between 0 and 1, default is 0)
  58069. * @param b defines the blue component (between 0 and 1, default is 0)
  58070. */
  58071. constructor(
  58072. /**
  58073. * Defines the red component (between 0 and 1, default is 0)
  58074. */
  58075. r?: number,
  58076. /**
  58077. * Defines the green component (between 0 and 1, default is 0)
  58078. */
  58079. g?: number,
  58080. /**
  58081. * Defines the blue component (between 0 and 1, default is 0)
  58082. */
  58083. b?: number);
  58084. /**
  58085. * Creates a string with the Color3 current values
  58086. * @returns the string representation of the Color3 object
  58087. */
  58088. toString(): string;
  58089. /**
  58090. * Returns the string "Color3"
  58091. * @returns "Color3"
  58092. */
  58093. getClassName(): string;
  58094. /**
  58095. * Compute the Color3 hash code
  58096. * @returns an unique number that can be used to hash Color3 objects
  58097. */
  58098. getHashCode(): number;
  58099. /**
  58100. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  58101. * @param array defines the array where to store the r,g,b components
  58102. * @param index defines an optional index in the target array to define where to start storing values
  58103. * @returns the current Color3 object
  58104. */
  58105. toArray(array: FloatArray, index?: number): Color3;
  58106. /**
  58107. * Returns a new Color4 object from the current Color3 and the given alpha
  58108. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  58109. * @returns a new Color4 object
  58110. */
  58111. toColor4(alpha?: number): Color4;
  58112. /**
  58113. * Returns a new array populated with 3 numeric elements : red, green and blue values
  58114. * @returns the new array
  58115. */
  58116. asArray(): number[];
  58117. /**
  58118. * Returns the luminance value
  58119. * @returns a float value
  58120. */
  58121. toLuminance(): number;
  58122. /**
  58123. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  58124. * @param otherColor defines the second operand
  58125. * @returns the new Color3 object
  58126. */
  58127. multiply(otherColor: DeepImmutable<Color3>): Color3;
  58128. /**
  58129. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  58130. * @param otherColor defines the second operand
  58131. * @param result defines the Color3 object where to store the result
  58132. * @returns the current Color3
  58133. */
  58134. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  58135. /**
  58136. * Determines equality between Color3 objects
  58137. * @param otherColor defines the second operand
  58138. * @returns true if the rgb values are equal to the given ones
  58139. */
  58140. equals(otherColor: DeepImmutable<Color3>): boolean;
  58141. /**
  58142. * Determines equality between the current Color3 object and a set of r,b,g values
  58143. * @param r defines the red component to check
  58144. * @param g defines the green component to check
  58145. * @param b defines the blue component to check
  58146. * @returns true if the rgb values are equal to the given ones
  58147. */
  58148. equalsFloats(r: number, g: number, b: number): boolean;
  58149. /**
  58150. * Multiplies in place each rgb value by scale
  58151. * @param scale defines the scaling factor
  58152. * @returns the updated Color3
  58153. */
  58154. scale(scale: number): Color3;
  58155. /**
  58156. * Multiplies the rgb values by scale and stores the result into "result"
  58157. * @param scale defines the scaling factor
  58158. * @param result defines the Color3 object where to store the result
  58159. * @returns the unmodified current Color3
  58160. */
  58161. scaleToRef(scale: number, result: Color3): Color3;
  58162. /**
  58163. * Scale the current Color3 values by a factor and add the result to a given Color3
  58164. * @param scale defines the scale factor
  58165. * @param result defines color to store the result into
  58166. * @returns the unmodified current Color3
  58167. */
  58168. scaleAndAddToRef(scale: number, result: Color3): Color3;
  58169. /**
  58170. * Clamps the rgb values by the min and max values and stores the result into "result"
  58171. * @param min defines minimum clamping value (default is 0)
  58172. * @param max defines maximum clamping value (default is 1)
  58173. * @param result defines color to store the result into
  58174. * @returns the original Color3
  58175. */
  58176. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  58177. /**
  58178. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  58179. * @param otherColor defines the second operand
  58180. * @returns the new Color3
  58181. */
  58182. add(otherColor: DeepImmutable<Color3>): Color3;
  58183. /**
  58184. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  58185. * @param otherColor defines the second operand
  58186. * @param result defines Color3 object to store the result into
  58187. * @returns the unmodified current Color3
  58188. */
  58189. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  58190. /**
  58191. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  58192. * @param otherColor defines the second operand
  58193. * @returns the new Color3
  58194. */
  58195. subtract(otherColor: DeepImmutable<Color3>): Color3;
  58196. /**
  58197. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  58198. * @param otherColor defines the second operand
  58199. * @param result defines Color3 object to store the result into
  58200. * @returns the unmodified current Color3
  58201. */
  58202. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  58203. /**
  58204. * Copy the current object
  58205. * @returns a new Color3 copied the current one
  58206. */
  58207. clone(): Color3;
  58208. /**
  58209. * Copies the rgb values from the source in the current Color3
  58210. * @param source defines the source Color3 object
  58211. * @returns the updated Color3 object
  58212. */
  58213. copyFrom(source: DeepImmutable<Color3>): Color3;
  58214. /**
  58215. * Updates the Color3 rgb values from the given floats
  58216. * @param r defines the red component to read from
  58217. * @param g defines the green component to read from
  58218. * @param b defines the blue component to read from
  58219. * @returns the current Color3 object
  58220. */
  58221. copyFromFloats(r: number, g: number, b: number): Color3;
  58222. /**
  58223. * Updates the Color3 rgb values from the given floats
  58224. * @param r defines the red component to read from
  58225. * @param g defines the green component to read from
  58226. * @param b defines the blue component to read from
  58227. * @returns the current Color3 object
  58228. */
  58229. set(r: number, g: number, b: number): Color3;
  58230. /**
  58231. * Compute the Color3 hexadecimal code as a string
  58232. * @returns a string containing the hexadecimal representation of the Color3 object
  58233. */
  58234. toHexString(): string;
  58235. /**
  58236. * Computes a new Color3 converted from the current one to linear space
  58237. * @returns a new Color3 object
  58238. */
  58239. toLinearSpace(): Color3;
  58240. /**
  58241. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  58242. * @param convertedColor defines the Color3 object where to store the linear space version
  58243. * @returns the unmodified Color3
  58244. */
  58245. toLinearSpaceToRef(convertedColor: Color3): Color3;
  58246. /**
  58247. * Computes a new Color3 converted from the current one to gamma space
  58248. * @returns a new Color3 object
  58249. */
  58250. toGammaSpace(): Color3;
  58251. /**
  58252. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  58253. * @param convertedColor defines the Color3 object where to store the gamma space version
  58254. * @returns the unmodified Color3
  58255. */
  58256. toGammaSpaceToRef(convertedColor: Color3): Color3;
  58257. private static _BlackReadOnly;
  58258. /**
  58259. * Creates a new Color3 from the string containing valid hexadecimal values
  58260. * @param hex defines a string containing valid hexadecimal values
  58261. * @returns a new Color3 object
  58262. */
  58263. static FromHexString(hex: string): Color3;
  58264. /**
  58265. * Creates a new Vector3 from the starting index of the given array
  58266. * @param array defines the source array
  58267. * @param offset defines an offset in the source array
  58268. * @returns a new Color3 object
  58269. */
  58270. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  58271. /**
  58272. * Creates a new Color3 from integer values (< 256)
  58273. * @param r defines the red component to read from (value between 0 and 255)
  58274. * @param g defines the green component to read from (value between 0 and 255)
  58275. * @param b defines the blue component to read from (value between 0 and 255)
  58276. * @returns a new Color3 object
  58277. */
  58278. static FromInts(r: number, g: number, b: number): Color3;
  58279. /**
  58280. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  58281. * @param start defines the start Color3 value
  58282. * @param end defines the end Color3 value
  58283. * @param amount defines the gradient value between start and end
  58284. * @returns a new Color3 object
  58285. */
  58286. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  58287. /**
  58288. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  58289. * @param left defines the start value
  58290. * @param right defines the end value
  58291. * @param amount defines the gradient factor
  58292. * @param result defines the Color3 object where to store the result
  58293. */
  58294. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  58295. /**
  58296. * Returns a Color3 value containing a red color
  58297. * @returns a new Color3 object
  58298. */
  58299. static Red(): Color3;
  58300. /**
  58301. * Returns a Color3 value containing a green color
  58302. * @returns a new Color3 object
  58303. */
  58304. static Green(): Color3;
  58305. /**
  58306. * Returns a Color3 value containing a blue color
  58307. * @returns a new Color3 object
  58308. */
  58309. static Blue(): Color3;
  58310. /**
  58311. * Returns a Color3 value containing a black color
  58312. * @returns a new Color3 object
  58313. */
  58314. static Black(): Color3;
  58315. /**
  58316. * Gets a Color3 value containing a black color that must not be updated
  58317. */
  58318. static readonly BlackReadOnly: DeepImmutable<Color3>;
  58319. /**
  58320. * Returns a Color3 value containing a white color
  58321. * @returns a new Color3 object
  58322. */
  58323. static White(): Color3;
  58324. /**
  58325. * Returns a Color3 value containing a purple color
  58326. * @returns a new Color3 object
  58327. */
  58328. static Purple(): Color3;
  58329. /**
  58330. * Returns a Color3 value containing a magenta color
  58331. * @returns a new Color3 object
  58332. */
  58333. static Magenta(): Color3;
  58334. /**
  58335. * Returns a Color3 value containing a yellow color
  58336. * @returns a new Color3 object
  58337. */
  58338. static Yellow(): Color3;
  58339. /**
  58340. * Returns a Color3 value containing a gray color
  58341. * @returns a new Color3 object
  58342. */
  58343. static Gray(): Color3;
  58344. /**
  58345. * Returns a Color3 value containing a teal color
  58346. * @returns a new Color3 object
  58347. */
  58348. static Teal(): Color3;
  58349. /**
  58350. * Returns a Color3 value containing a random color
  58351. * @returns a new Color3 object
  58352. */
  58353. static Random(): Color3;
  58354. }
  58355. /**
  58356. * Class used to hold a RBGA color
  58357. */
  58358. export class Color4 {
  58359. /**
  58360. * Defines the red component (between 0 and 1, default is 0)
  58361. */
  58362. r: number;
  58363. /**
  58364. * Defines the green component (between 0 and 1, default is 0)
  58365. */
  58366. g: number;
  58367. /**
  58368. * Defines the blue component (between 0 and 1, default is 0)
  58369. */
  58370. b: number;
  58371. /**
  58372. * Defines the alpha component (between 0 and 1, default is 1)
  58373. */
  58374. a: number;
  58375. /**
  58376. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  58377. * @param r defines the red component (between 0 and 1, default is 0)
  58378. * @param g defines the green component (between 0 and 1, default is 0)
  58379. * @param b defines the blue component (between 0 and 1, default is 0)
  58380. * @param a defines the alpha component (between 0 and 1, default is 1)
  58381. */
  58382. constructor(
  58383. /**
  58384. * Defines the red component (between 0 and 1, default is 0)
  58385. */
  58386. r?: number,
  58387. /**
  58388. * Defines the green component (between 0 and 1, default is 0)
  58389. */
  58390. g?: number,
  58391. /**
  58392. * Defines the blue component (between 0 and 1, default is 0)
  58393. */
  58394. b?: number,
  58395. /**
  58396. * Defines the alpha component (between 0 and 1, default is 1)
  58397. */
  58398. a?: number);
  58399. /**
  58400. * Adds in place the given Color4 values to the current Color4 object
  58401. * @param right defines the second operand
  58402. * @returns the current updated Color4 object
  58403. */
  58404. addInPlace(right: DeepImmutable<Color4>): Color4;
  58405. /**
  58406. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  58407. * @returns the new array
  58408. */
  58409. asArray(): number[];
  58410. /**
  58411. * Stores from the starting index in the given array the Color4 successive values
  58412. * @param array defines the array where to store the r,g,b components
  58413. * @param index defines an optional index in the target array to define where to start storing values
  58414. * @returns the current Color4 object
  58415. */
  58416. toArray(array: number[], index?: number): Color4;
  58417. /**
  58418. * Determines equality between Color4 objects
  58419. * @param otherColor defines the second operand
  58420. * @returns true if the rgba values are equal to the given ones
  58421. */
  58422. equals(otherColor: DeepImmutable<Color4>): boolean;
  58423. /**
  58424. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  58425. * @param right defines the second operand
  58426. * @returns a new Color4 object
  58427. */
  58428. add(right: DeepImmutable<Color4>): Color4;
  58429. /**
  58430. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  58431. * @param right defines the second operand
  58432. * @returns a new Color4 object
  58433. */
  58434. subtract(right: DeepImmutable<Color4>): Color4;
  58435. /**
  58436. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  58437. * @param right defines the second operand
  58438. * @param result defines the Color4 object where to store the result
  58439. * @returns the current Color4 object
  58440. */
  58441. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  58442. /**
  58443. * Creates a new Color4 with the current Color4 values multiplied by scale
  58444. * @param scale defines the scaling factor to apply
  58445. * @returns a new Color4 object
  58446. */
  58447. scale(scale: number): Color4;
  58448. /**
  58449. * Multiplies the current Color4 values by scale and stores the result in "result"
  58450. * @param scale defines the scaling factor to apply
  58451. * @param result defines the Color4 object where to store the result
  58452. * @returns the current unmodified Color4
  58453. */
  58454. scaleToRef(scale: number, result: Color4): Color4;
  58455. /**
  58456. * Scale the current Color4 values by a factor and add the result to a given Color4
  58457. * @param scale defines the scale factor
  58458. * @param result defines the Color4 object where to store the result
  58459. * @returns the unmodified current Color4
  58460. */
  58461. scaleAndAddToRef(scale: number, result: Color4): Color4;
  58462. /**
  58463. * Clamps the rgb values by the min and max values and stores the result into "result"
  58464. * @param min defines minimum clamping value (default is 0)
  58465. * @param max defines maximum clamping value (default is 1)
  58466. * @param result defines color to store the result into.
  58467. * @returns the cuurent Color4
  58468. */
  58469. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  58470. /**
  58471. * Multipy an Color4 value by another and return a new Color4 object
  58472. * @param color defines the Color4 value to multiply by
  58473. * @returns a new Color4 object
  58474. */
  58475. multiply(color: Color4): Color4;
  58476. /**
  58477. * Multipy a Color4 value by another and push the result in a reference value
  58478. * @param color defines the Color4 value to multiply by
  58479. * @param result defines the Color4 to fill the result in
  58480. * @returns the result Color4
  58481. */
  58482. multiplyToRef(color: Color4, result: Color4): Color4;
  58483. /**
  58484. * Creates a string with the Color4 current values
  58485. * @returns the string representation of the Color4 object
  58486. */
  58487. toString(): string;
  58488. /**
  58489. * Returns the string "Color4"
  58490. * @returns "Color4"
  58491. */
  58492. getClassName(): string;
  58493. /**
  58494. * Compute the Color4 hash code
  58495. * @returns an unique number that can be used to hash Color4 objects
  58496. */
  58497. getHashCode(): number;
  58498. /**
  58499. * Creates a new Color4 copied from the current one
  58500. * @returns a new Color4 object
  58501. */
  58502. clone(): Color4;
  58503. /**
  58504. * Copies the given Color4 values into the current one
  58505. * @param source defines the source Color4 object
  58506. * @returns the current updated Color4 object
  58507. */
  58508. copyFrom(source: Color4): Color4;
  58509. /**
  58510. * Copies the given float values into the current one
  58511. * @param r defines the red component to read from
  58512. * @param g defines the green component to read from
  58513. * @param b defines the blue component to read from
  58514. * @param a defines the alpha component to read from
  58515. * @returns the current updated Color4 object
  58516. */
  58517. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  58518. /**
  58519. * Copies the given float values into the current one
  58520. * @param r defines the red component to read from
  58521. * @param g defines the green component to read from
  58522. * @param b defines the blue component to read from
  58523. * @param a defines the alpha component to read from
  58524. * @returns the current updated Color4 object
  58525. */
  58526. set(r: number, g: number, b: number, a: number): Color4;
  58527. /**
  58528. * Compute the Color4 hexadecimal code as a string
  58529. * @returns a string containing the hexadecimal representation of the Color4 object
  58530. */
  58531. toHexString(): string;
  58532. /**
  58533. * Computes a new Color4 converted from the current one to linear space
  58534. * @returns a new Color4 object
  58535. */
  58536. toLinearSpace(): Color4;
  58537. /**
  58538. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  58539. * @param convertedColor defines the Color4 object where to store the linear space version
  58540. * @returns the unmodified Color4
  58541. */
  58542. toLinearSpaceToRef(convertedColor: Color4): Color4;
  58543. /**
  58544. * Computes a new Color4 converted from the current one to gamma space
  58545. * @returns a new Color4 object
  58546. */
  58547. toGammaSpace(): Color4;
  58548. /**
  58549. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  58550. * @param convertedColor defines the Color4 object where to store the gamma space version
  58551. * @returns the unmodified Color4
  58552. */
  58553. toGammaSpaceToRef(convertedColor: Color4): Color4;
  58554. /**
  58555. * Creates a new Color4 from the string containing valid hexadecimal values
  58556. * @param hex defines a string containing valid hexadecimal values
  58557. * @returns a new Color4 object
  58558. */
  58559. static FromHexString(hex: string): Color4;
  58560. /**
  58561. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  58562. * @param left defines the start value
  58563. * @param right defines the end value
  58564. * @param amount defines the gradient factor
  58565. * @returns a new Color4 object
  58566. */
  58567. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  58568. /**
  58569. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  58570. * @param left defines the start value
  58571. * @param right defines the end value
  58572. * @param amount defines the gradient factor
  58573. * @param result defines the Color4 object where to store data
  58574. */
  58575. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  58576. /**
  58577. * Creates a new Color4 from a Color3 and an alpha value
  58578. * @param color3 defines the source Color3 to read from
  58579. * @param alpha defines the alpha component (1.0 by default)
  58580. * @returns a new Color4 object
  58581. */
  58582. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  58583. /**
  58584. * Creates a new Color4 from the starting index element of the given array
  58585. * @param array defines the source array to read from
  58586. * @param offset defines the offset in the source array
  58587. * @returns a new Color4 object
  58588. */
  58589. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  58590. /**
  58591. * Creates a new Color3 from integer values (< 256)
  58592. * @param r defines the red component to read from (value between 0 and 255)
  58593. * @param g defines the green component to read from (value between 0 and 255)
  58594. * @param b defines the blue component to read from (value between 0 and 255)
  58595. * @param a defines the alpha component to read from (value between 0 and 255)
  58596. * @returns a new Color3 object
  58597. */
  58598. static FromInts(r: number, g: number, b: number, a: number): Color4;
  58599. /**
  58600. * Check the content of a given array and convert it to an array containing RGBA data
  58601. * If the original array was already containing count * 4 values then it is returned directly
  58602. * @param colors defines the array to check
  58603. * @param count defines the number of RGBA data to expect
  58604. * @returns an array containing count * 4 values (RGBA)
  58605. */
  58606. static CheckColors4(colors: number[], count: number): number[];
  58607. }
  58608. /**
  58609. * Class representing a vector containing 2 coordinates
  58610. */
  58611. export class Vector2 {
  58612. /** defines the first coordinate */
  58613. x: number;
  58614. /** defines the second coordinate */
  58615. y: number;
  58616. /**
  58617. * Creates a new Vector2 from the given x and y coordinates
  58618. * @param x defines the first coordinate
  58619. * @param y defines the second coordinate
  58620. */
  58621. constructor(
  58622. /** defines the first coordinate */
  58623. x?: number,
  58624. /** defines the second coordinate */
  58625. y?: number);
  58626. /**
  58627. * Gets a string with the Vector2 coordinates
  58628. * @returns a string with the Vector2 coordinates
  58629. */
  58630. toString(): string;
  58631. /**
  58632. * Gets class name
  58633. * @returns the string "Vector2"
  58634. */
  58635. getClassName(): string;
  58636. /**
  58637. * Gets current vector hash code
  58638. * @returns the Vector2 hash code as a number
  58639. */
  58640. getHashCode(): number;
  58641. /**
  58642. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  58643. * @param array defines the source array
  58644. * @param index defines the offset in source array
  58645. * @returns the current Vector2
  58646. */
  58647. toArray(array: FloatArray, index?: number): Vector2;
  58648. /**
  58649. * Copy the current vector to an array
  58650. * @returns a new array with 2 elements: the Vector2 coordinates.
  58651. */
  58652. asArray(): number[];
  58653. /**
  58654. * Sets the Vector2 coordinates with the given Vector2 coordinates
  58655. * @param source defines the source Vector2
  58656. * @returns the current updated Vector2
  58657. */
  58658. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  58659. /**
  58660. * Sets the Vector2 coordinates with the given floats
  58661. * @param x defines the first coordinate
  58662. * @param y defines the second coordinate
  58663. * @returns the current updated Vector2
  58664. */
  58665. copyFromFloats(x: number, y: number): Vector2;
  58666. /**
  58667. * Sets the Vector2 coordinates with the given floats
  58668. * @param x defines the first coordinate
  58669. * @param y defines the second coordinate
  58670. * @returns the current updated Vector2
  58671. */
  58672. set(x: number, y: number): Vector2;
  58673. /**
  58674. * Add another vector with the current one
  58675. * @param otherVector defines the other vector
  58676. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  58677. */
  58678. add(otherVector: DeepImmutable<Vector2>): Vector2;
  58679. /**
  58680. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  58681. * @param otherVector defines the other vector
  58682. * @param result defines the target vector
  58683. * @returns the unmodified current Vector2
  58684. */
  58685. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58686. /**
  58687. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  58688. * @param otherVector defines the other vector
  58689. * @returns the current updated Vector2
  58690. */
  58691. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58692. /**
  58693. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  58694. * @param otherVector defines the other vector
  58695. * @returns a new Vector2
  58696. */
  58697. addVector3(otherVector: Vector3): Vector2;
  58698. /**
  58699. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  58700. * @param otherVector defines the other vector
  58701. * @returns a new Vector2
  58702. */
  58703. subtract(otherVector: Vector2): Vector2;
  58704. /**
  58705. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  58706. * @param otherVector defines the other vector
  58707. * @param result defines the target vector
  58708. * @returns the unmodified current Vector2
  58709. */
  58710. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58711. /**
  58712. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  58713. * @param otherVector defines the other vector
  58714. * @returns the current updated Vector2
  58715. */
  58716. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58717. /**
  58718. * Multiplies in place the current Vector2 coordinates by the given ones
  58719. * @param otherVector defines the other vector
  58720. * @returns the current updated Vector2
  58721. */
  58722. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58723. /**
  58724. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  58725. * @param otherVector defines the other vector
  58726. * @returns a new Vector2
  58727. */
  58728. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  58729. /**
  58730. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  58731. * @param otherVector defines the other vector
  58732. * @param result defines the target vector
  58733. * @returns the unmodified current Vector2
  58734. */
  58735. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58736. /**
  58737. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  58738. * @param x defines the first coordinate
  58739. * @param y defines the second coordinate
  58740. * @returns a new Vector2
  58741. */
  58742. multiplyByFloats(x: number, y: number): Vector2;
  58743. /**
  58744. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  58745. * @param otherVector defines the other vector
  58746. * @returns a new Vector2
  58747. */
  58748. divide(otherVector: Vector2): Vector2;
  58749. /**
  58750. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  58751. * @param otherVector defines the other vector
  58752. * @param result defines the target vector
  58753. * @returns the unmodified current Vector2
  58754. */
  58755. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58756. /**
  58757. * Divides the current Vector2 coordinates by the given ones
  58758. * @param otherVector defines the other vector
  58759. * @returns the current updated Vector2
  58760. */
  58761. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58762. /**
  58763. * Gets a new Vector2 with current Vector2 negated coordinates
  58764. * @returns a new Vector2
  58765. */
  58766. negate(): Vector2;
  58767. /**
  58768. * Multiply the Vector2 coordinates by scale
  58769. * @param scale defines the scaling factor
  58770. * @returns the current updated Vector2
  58771. */
  58772. scaleInPlace(scale: number): Vector2;
  58773. /**
  58774. * Returns a new Vector2 scaled by "scale" from the current Vector2
  58775. * @param scale defines the scaling factor
  58776. * @returns a new Vector2
  58777. */
  58778. scale(scale: number): Vector2;
  58779. /**
  58780. * Scale the current Vector2 values by a factor to a given Vector2
  58781. * @param scale defines the scale factor
  58782. * @param result defines the Vector2 object where to store the result
  58783. * @returns the unmodified current Vector2
  58784. */
  58785. scaleToRef(scale: number, result: Vector2): Vector2;
  58786. /**
  58787. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  58788. * @param scale defines the scale factor
  58789. * @param result defines the Vector2 object where to store the result
  58790. * @returns the unmodified current Vector2
  58791. */
  58792. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  58793. /**
  58794. * Gets a boolean if two vectors are equals
  58795. * @param otherVector defines the other vector
  58796. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  58797. */
  58798. equals(otherVector: DeepImmutable<Vector2>): boolean;
  58799. /**
  58800. * Gets a boolean if two vectors are equals (using an epsilon value)
  58801. * @param otherVector defines the other vector
  58802. * @param epsilon defines the minimal distance to consider equality
  58803. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  58804. */
  58805. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  58806. /**
  58807. * Gets a new Vector2 from current Vector2 floored values
  58808. * @returns a new Vector2
  58809. */
  58810. floor(): Vector2;
  58811. /**
  58812. * Gets a new Vector2 from current Vector2 floored values
  58813. * @returns a new Vector2
  58814. */
  58815. fract(): Vector2;
  58816. /**
  58817. * Gets the length of the vector
  58818. * @returns the vector length (float)
  58819. */
  58820. length(): number;
  58821. /**
  58822. * Gets the vector squared length
  58823. * @returns the vector squared length (float)
  58824. */
  58825. lengthSquared(): number;
  58826. /**
  58827. * Normalize the vector
  58828. * @returns the current updated Vector2
  58829. */
  58830. normalize(): Vector2;
  58831. /**
  58832. * Gets a new Vector2 copied from the Vector2
  58833. * @returns a new Vector2
  58834. */
  58835. clone(): Vector2;
  58836. /**
  58837. * Gets a new Vector2(0, 0)
  58838. * @returns a new Vector2
  58839. */
  58840. static Zero(): Vector2;
  58841. /**
  58842. * Gets a new Vector2(1, 1)
  58843. * @returns a new Vector2
  58844. */
  58845. static One(): Vector2;
  58846. /**
  58847. * Gets a new Vector2 set from the given index element of the given array
  58848. * @param array defines the data source
  58849. * @param offset defines the offset in the data source
  58850. * @returns a new Vector2
  58851. */
  58852. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  58853. /**
  58854. * Sets "result" from the given index element of the given array
  58855. * @param array defines the data source
  58856. * @param offset defines the offset in the data source
  58857. * @param result defines the target vector
  58858. */
  58859. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  58860. /**
  58861. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  58862. * @param value1 defines 1st point of control
  58863. * @param value2 defines 2nd point of control
  58864. * @param value3 defines 3rd point of control
  58865. * @param value4 defines 4th point of control
  58866. * @param amount defines the interpolation factor
  58867. * @returns a new Vector2
  58868. */
  58869. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  58870. /**
  58871. * 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".
  58872. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  58873. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  58874. * @param value defines the value to clamp
  58875. * @param min defines the lower limit
  58876. * @param max defines the upper limit
  58877. * @returns a new Vector2
  58878. */
  58879. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  58880. /**
  58881. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  58882. * @param value1 defines the 1st control point
  58883. * @param tangent1 defines the outgoing tangent
  58884. * @param value2 defines the 2nd control point
  58885. * @param tangent2 defines the incoming tangent
  58886. * @param amount defines the interpolation factor
  58887. * @returns a new Vector2
  58888. */
  58889. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  58890. /**
  58891. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  58892. * @param start defines the start vector
  58893. * @param end defines the end vector
  58894. * @param amount defines the interpolation factor
  58895. * @returns a new Vector2
  58896. */
  58897. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  58898. /**
  58899. * Gets the dot product of the vector "left" and the vector "right"
  58900. * @param left defines first vector
  58901. * @param right defines second vector
  58902. * @returns the dot product (float)
  58903. */
  58904. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  58905. /**
  58906. * Returns a new Vector2 equal to the normalized given vector
  58907. * @param vector defines the vector to normalize
  58908. * @returns a new Vector2
  58909. */
  58910. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  58911. /**
  58912. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  58913. * @param left defines 1st vector
  58914. * @param right defines 2nd vector
  58915. * @returns a new Vector2
  58916. */
  58917. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  58918. /**
  58919. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  58920. * @param left defines 1st vector
  58921. * @param right defines 2nd vector
  58922. * @returns a new Vector2
  58923. */
  58924. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  58925. /**
  58926. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  58927. * @param vector defines the vector to transform
  58928. * @param transformation defines the matrix to apply
  58929. * @returns a new Vector2
  58930. */
  58931. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  58932. /**
  58933. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  58934. * @param vector defines the vector to transform
  58935. * @param transformation defines the matrix to apply
  58936. * @param result defines the target vector
  58937. */
  58938. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  58939. /**
  58940. * Determines if a given vector is included in a triangle
  58941. * @param p defines the vector to test
  58942. * @param p0 defines 1st triangle point
  58943. * @param p1 defines 2nd triangle point
  58944. * @param p2 defines 3rd triangle point
  58945. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  58946. */
  58947. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  58948. /**
  58949. * Gets the distance between the vectors "value1" and "value2"
  58950. * @param value1 defines first vector
  58951. * @param value2 defines second vector
  58952. * @returns the distance between vectors
  58953. */
  58954. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  58955. /**
  58956. * Returns the squared distance between the vectors "value1" and "value2"
  58957. * @param value1 defines first vector
  58958. * @param value2 defines second vector
  58959. * @returns the squared distance between vectors
  58960. */
  58961. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  58962. /**
  58963. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  58964. * @param value1 defines first vector
  58965. * @param value2 defines second vector
  58966. * @returns a new Vector2
  58967. */
  58968. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  58969. /**
  58970. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  58971. * @param p defines the middle point
  58972. * @param segA defines one point of the segment
  58973. * @param segB defines the other point of the segment
  58974. * @returns the shortest distance
  58975. */
  58976. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  58977. }
  58978. /**
  58979. * Classed used to store (x,y,z) vector representation
  58980. * A Vector3 is the main object used in 3D geometry
  58981. * It can represent etiher the coordinates of a point the space, either a direction
  58982. * Reminder: js uses a left handed forward facing system
  58983. */
  58984. export class Vector3 {
  58985. /**
  58986. * Defines the first coordinates (on X axis)
  58987. */
  58988. x: number;
  58989. /**
  58990. * Defines the second coordinates (on Y axis)
  58991. */
  58992. y: number;
  58993. /**
  58994. * Defines the third coordinates (on Z axis)
  58995. */
  58996. z: number;
  58997. private static _UpReadOnly;
  58998. /**
  58999. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  59000. * @param x defines the first coordinates (on X axis)
  59001. * @param y defines the second coordinates (on Y axis)
  59002. * @param z defines the third coordinates (on Z axis)
  59003. */
  59004. constructor(
  59005. /**
  59006. * Defines the first coordinates (on X axis)
  59007. */
  59008. x?: number,
  59009. /**
  59010. * Defines the second coordinates (on Y axis)
  59011. */
  59012. y?: number,
  59013. /**
  59014. * Defines the third coordinates (on Z axis)
  59015. */
  59016. z?: number);
  59017. /**
  59018. * Creates a string representation of the Vector3
  59019. * @returns a string with the Vector3 coordinates.
  59020. */
  59021. toString(): string;
  59022. /**
  59023. * Gets the class name
  59024. * @returns the string "Vector3"
  59025. */
  59026. getClassName(): string;
  59027. /**
  59028. * Creates the Vector3 hash code
  59029. * @returns a number which tends to be unique between Vector3 instances
  59030. */
  59031. getHashCode(): number;
  59032. /**
  59033. * Creates an array containing three elements : the coordinates of the Vector3
  59034. * @returns a new array of numbers
  59035. */
  59036. asArray(): number[];
  59037. /**
  59038. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  59039. * @param array defines the destination array
  59040. * @param index defines the offset in the destination array
  59041. * @returns the current Vector3
  59042. */
  59043. toArray(array: FloatArray, index?: number): Vector3;
  59044. /**
  59045. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  59046. * @returns a new Quaternion object, computed from the Vector3 coordinates
  59047. */
  59048. toQuaternion(): Quaternion;
  59049. /**
  59050. * Adds the given vector to the current Vector3
  59051. * @param otherVector defines the second operand
  59052. * @returns the current updated Vector3
  59053. */
  59054. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  59055. /**
  59056. * Adds the given coordinates to the current Vector3
  59057. * @param x defines the x coordinate of the operand
  59058. * @param y defines the y coordinate of the operand
  59059. * @param z defines the z coordinate of the operand
  59060. * @returns the current updated Vector3
  59061. */
  59062. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  59063. /**
  59064. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  59065. * @param otherVector defines the second operand
  59066. * @returns the resulting Vector3
  59067. */
  59068. add(otherVector: DeepImmutable<Vector3>): Vector3;
  59069. /**
  59070. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  59071. * @param otherVector defines the second operand
  59072. * @param result defines the Vector3 object where to store the result
  59073. * @returns the current Vector3
  59074. */
  59075. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59076. /**
  59077. * Subtract the given vector from the current Vector3
  59078. * @param otherVector defines the second operand
  59079. * @returns the current updated Vector3
  59080. */
  59081. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  59082. /**
  59083. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  59084. * @param otherVector defines the second operand
  59085. * @returns the resulting Vector3
  59086. */
  59087. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  59088. /**
  59089. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  59090. * @param otherVector defines the second operand
  59091. * @param result defines the Vector3 object where to store the result
  59092. * @returns the current Vector3
  59093. */
  59094. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59095. /**
  59096. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 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 resulting Vector3
  59101. */
  59102. subtractFromFloats(x: number, y: number, z: number): Vector3;
  59103. /**
  59104. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  59105. * @param x defines the x coordinate of the operand
  59106. * @param y defines the y coordinate of the operand
  59107. * @param z defines the z coordinate of the operand
  59108. * @param result defines the Vector3 object where to store the result
  59109. * @returns the current Vector3
  59110. */
  59111. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  59112. /**
  59113. * Gets a new Vector3 set with the current Vector3 negated coordinates
  59114. * @returns a new Vector3
  59115. */
  59116. negate(): Vector3;
  59117. /**
  59118. * Multiplies the Vector3 coordinates by the float "scale"
  59119. * @param scale defines the multiplier factor
  59120. * @returns the current updated Vector3
  59121. */
  59122. scaleInPlace(scale: number): Vector3;
  59123. /**
  59124. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  59125. * @param scale defines the multiplier factor
  59126. * @returns a new Vector3
  59127. */
  59128. scale(scale: number): Vector3;
  59129. /**
  59130. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  59131. * @param scale defines the multiplier factor
  59132. * @param result defines the Vector3 object where to store the result
  59133. * @returns the current Vector3
  59134. */
  59135. scaleToRef(scale: number, result: Vector3): Vector3;
  59136. /**
  59137. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  59138. * @param scale defines the scale factor
  59139. * @param result defines the Vector3 object where to store the result
  59140. * @returns the unmodified current Vector3
  59141. */
  59142. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  59143. /**
  59144. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  59145. * @param otherVector defines the second operand
  59146. * @returns true if both vectors are equals
  59147. */
  59148. equals(otherVector: DeepImmutable<Vector3>): boolean;
  59149. /**
  59150. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  59151. * @param otherVector defines the second operand
  59152. * @param epsilon defines the minimal distance to define values as equals
  59153. * @returns true if both vectors are distant less than epsilon
  59154. */
  59155. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  59156. /**
  59157. * Returns true if the current Vector3 coordinates equals the given floats
  59158. * @param x defines the x coordinate of the operand
  59159. * @param y defines the y coordinate of the operand
  59160. * @param z defines the z coordinate of the operand
  59161. * @returns true if both vectors are equals
  59162. */
  59163. equalsToFloats(x: number, y: number, z: number): boolean;
  59164. /**
  59165. * Multiplies the current Vector3 coordinates by the given ones
  59166. * @param otherVector defines the second operand
  59167. * @returns the current updated Vector3
  59168. */
  59169. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  59170. /**
  59171. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  59172. * @param otherVector defines the second operand
  59173. * @returns the new Vector3
  59174. */
  59175. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  59176. /**
  59177. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  59178. * @param otherVector defines the second operand
  59179. * @param result defines the Vector3 object where to store the result
  59180. * @returns the current Vector3
  59181. */
  59182. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59183. /**
  59184. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  59185. * @param x defines the x coordinate of the operand
  59186. * @param y defines the y coordinate of the operand
  59187. * @param z defines the z coordinate of the operand
  59188. * @returns the new Vector3
  59189. */
  59190. multiplyByFloats(x: number, y: number, z: number): Vector3;
  59191. /**
  59192. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  59193. * @param otherVector defines the second operand
  59194. * @returns the new Vector3
  59195. */
  59196. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  59197. /**
  59198. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  59199. * @param otherVector defines the second operand
  59200. * @param result defines the Vector3 object where to store the result
  59201. * @returns the current Vector3
  59202. */
  59203. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59204. /**
  59205. * Divides the current Vector3 coordinates by the given ones.
  59206. * @param otherVector defines the second operand
  59207. * @returns the current updated Vector3
  59208. */
  59209. divideInPlace(otherVector: Vector3): Vector3;
  59210. /**
  59211. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  59212. * @param other defines the second operand
  59213. * @returns the current updated Vector3
  59214. */
  59215. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  59216. /**
  59217. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  59218. * @param other defines the second operand
  59219. * @returns the current updated Vector3
  59220. */
  59221. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  59222. /**
  59223. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  59224. * @param x defines the x coordinate of the operand
  59225. * @param y defines the y coordinate of the operand
  59226. * @param z defines the z coordinate of the operand
  59227. * @returns the current updated Vector3
  59228. */
  59229. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  59230. /**
  59231. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  59232. * @param x defines the x coordinate of the operand
  59233. * @param y defines the y coordinate of the operand
  59234. * @param z defines the z coordinate of the operand
  59235. * @returns the current updated Vector3
  59236. */
  59237. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  59238. /**
  59239. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  59240. * Check if is non uniform within a certain amount of decimal places to account for this
  59241. * @param epsilon the amount the values can differ
  59242. * @returns if the the vector is non uniform to a certain number of decimal places
  59243. */
  59244. isNonUniformWithinEpsilon(epsilon: number): boolean;
  59245. /**
  59246. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  59247. */
  59248. readonly isNonUniform: boolean;
  59249. /**
  59250. * Gets a new Vector3 from current Vector3 floored values
  59251. * @returns a new Vector3
  59252. */
  59253. floor(): Vector3;
  59254. /**
  59255. * Gets a new Vector3 from current Vector3 floored values
  59256. * @returns a new Vector3
  59257. */
  59258. fract(): Vector3;
  59259. /**
  59260. * Gets the length of the Vector3
  59261. * @returns the length of the Vecto3
  59262. */
  59263. length(): number;
  59264. /**
  59265. * Gets the squared length of the Vector3
  59266. * @returns squared length of the Vector3
  59267. */
  59268. lengthSquared(): number;
  59269. /**
  59270. * Normalize the current Vector3.
  59271. * Please note that this is an in place operation.
  59272. * @returns the current updated Vector3
  59273. */
  59274. normalize(): Vector3;
  59275. /**
  59276. * Reorders the x y z properties of the vector in place
  59277. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  59278. * @returns the current updated vector
  59279. */
  59280. reorderInPlace(order: string): this;
  59281. /**
  59282. * Rotates the vector around 0,0,0 by a quaternion
  59283. * @param quaternion the rotation quaternion
  59284. * @param result vector to store the result
  59285. * @returns the resulting vector
  59286. */
  59287. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  59288. /**
  59289. * Rotates a vector around a given point
  59290. * @param quaternion the rotation quaternion
  59291. * @param point the point to rotate around
  59292. * @param result vector to store the result
  59293. * @returns the resulting vector
  59294. */
  59295. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  59296. /**
  59297. * Normalize the current Vector3 with the given input length.
  59298. * Please note that this is an in place operation.
  59299. * @param len the length of the vector
  59300. * @returns the current updated Vector3
  59301. */
  59302. normalizeFromLength(len: number): Vector3;
  59303. /**
  59304. * Normalize the current Vector3 to a new vector
  59305. * @returns the new Vector3
  59306. */
  59307. normalizeToNew(): Vector3;
  59308. /**
  59309. * Normalize the current Vector3 to the reference
  59310. * @param reference define the Vector3 to update
  59311. * @returns the updated Vector3
  59312. */
  59313. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  59314. /**
  59315. * Creates a new Vector3 copied from the current Vector3
  59316. * @returns the new Vector3
  59317. */
  59318. clone(): Vector3;
  59319. /**
  59320. * Copies the given vector coordinates to the current Vector3 ones
  59321. * @param source defines the source Vector3
  59322. * @returns the current updated Vector3
  59323. */
  59324. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  59325. /**
  59326. * Copies the given floats to the current Vector3 coordinates
  59327. * @param x defines the x coordinate of the operand
  59328. * @param y defines the y coordinate of the operand
  59329. * @param z defines the z coordinate of the operand
  59330. * @returns the current updated Vector3
  59331. */
  59332. copyFromFloats(x: number, y: number, z: number): Vector3;
  59333. /**
  59334. * Copies the given floats to the current Vector3 coordinates
  59335. * @param x defines the x coordinate of the operand
  59336. * @param y defines the y coordinate of the operand
  59337. * @param z defines the z coordinate of the operand
  59338. * @returns the current updated Vector3
  59339. */
  59340. set(x: number, y: number, z: number): Vector3;
  59341. /**
  59342. * Copies the given float to the current Vector3 coordinates
  59343. * @param v defines the x, y and z coordinates of the operand
  59344. * @returns the current updated Vector3
  59345. */
  59346. setAll(v: number): Vector3;
  59347. /**
  59348. * Get the clip factor between two vectors
  59349. * @param vector0 defines the first operand
  59350. * @param vector1 defines the second operand
  59351. * @param axis defines the axis to use
  59352. * @param size defines the size along the axis
  59353. * @returns the clip factor
  59354. */
  59355. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  59356. /**
  59357. * Get angle between two vectors
  59358. * @param vector0 angle between vector0 and vector1
  59359. * @param vector1 angle between vector0 and vector1
  59360. * @param normal direction of the normal
  59361. * @return the angle between vector0 and vector1
  59362. */
  59363. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  59364. /**
  59365. * Returns a new Vector3 set from the index "offset" of the given array
  59366. * @param array defines the source array
  59367. * @param offset defines the offset in the source array
  59368. * @returns the new Vector3
  59369. */
  59370. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  59371. /**
  59372. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  59373. * This function is deprecated. Use FromArray instead
  59374. * @param array defines the source array
  59375. * @param offset defines the offset in the source array
  59376. * @returns the new Vector3
  59377. */
  59378. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  59379. /**
  59380. * Sets the given vector "result" with the element values from the index "offset" of the given array
  59381. * @param array defines the source array
  59382. * @param offset defines the offset in the source array
  59383. * @param result defines the Vector3 where to store the result
  59384. */
  59385. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  59386. /**
  59387. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  59388. * This function is deprecated. Use FromArrayToRef instead.
  59389. * @param array defines the source array
  59390. * @param offset defines the offset in the source array
  59391. * @param result defines the Vector3 where to store the result
  59392. */
  59393. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  59394. /**
  59395. * Sets the given vector "result" with the given floats.
  59396. * @param x defines the x coordinate of the source
  59397. * @param y defines the y coordinate of the source
  59398. * @param z defines the z coordinate of the source
  59399. * @param result defines the Vector3 where to store the result
  59400. */
  59401. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  59402. /**
  59403. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  59404. * @returns a new empty Vector3
  59405. */
  59406. static Zero(): Vector3;
  59407. /**
  59408. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  59409. * @returns a new unit Vector3
  59410. */
  59411. static One(): Vector3;
  59412. /**
  59413. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  59414. * @returns a new up Vector3
  59415. */
  59416. static Up(): Vector3;
  59417. /**
  59418. * Gets a up Vector3 that must not be updated
  59419. */
  59420. static readonly UpReadOnly: DeepImmutable<Vector3>;
  59421. /**
  59422. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  59423. * @returns a new down Vector3
  59424. */
  59425. static Down(): Vector3;
  59426. /**
  59427. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  59428. * @returns a new forward Vector3
  59429. */
  59430. static Forward(): Vector3;
  59431. /**
  59432. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  59433. * @returns a new forward Vector3
  59434. */
  59435. static Backward(): Vector3;
  59436. /**
  59437. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  59438. * @returns a new right Vector3
  59439. */
  59440. static Right(): Vector3;
  59441. /**
  59442. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  59443. * @returns a new left Vector3
  59444. */
  59445. static Left(): Vector3;
  59446. /**
  59447. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  59448. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  59449. * @param vector defines the Vector3 to transform
  59450. * @param transformation defines the transformation matrix
  59451. * @returns the transformed Vector3
  59452. */
  59453. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  59454. /**
  59455. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  59456. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  59457. * @param vector defines the Vector3 to transform
  59458. * @param transformation defines the transformation matrix
  59459. * @param result defines the Vector3 where to store the result
  59460. */
  59461. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59462. /**
  59463. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  59464. * This method computes tranformed coordinates only, not transformed direction vectors
  59465. * @param x define the x coordinate of the source vector
  59466. * @param y define the y coordinate of the source vector
  59467. * @param z define the z coordinate of the source vector
  59468. * @param transformation defines the transformation matrix
  59469. * @param result defines the Vector3 where to store the result
  59470. */
  59471. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59472. /**
  59473. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  59474. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  59475. * @param vector defines the Vector3 to transform
  59476. * @param transformation defines the transformation matrix
  59477. * @returns the new Vector3
  59478. */
  59479. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  59480. /**
  59481. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  59482. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  59483. * @param vector defines the Vector3 to transform
  59484. * @param transformation defines the transformation matrix
  59485. * @param result defines the Vector3 where to store the result
  59486. */
  59487. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59488. /**
  59489. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  59490. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  59491. * @param x define the x coordinate of the source vector
  59492. * @param y define the y coordinate of the source vector
  59493. * @param z define the z coordinate of the source vector
  59494. * @param transformation defines the transformation matrix
  59495. * @param result defines the Vector3 where to store the result
  59496. */
  59497. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59498. /**
  59499. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  59500. * @param value1 defines the first control point
  59501. * @param value2 defines the second control point
  59502. * @param value3 defines the third control point
  59503. * @param value4 defines the fourth control point
  59504. * @param amount defines the amount on the spline to use
  59505. * @returns the new Vector3
  59506. */
  59507. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  59508. /**
  59509. * 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"
  59510. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  59511. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  59512. * @param value defines the current value
  59513. * @param min defines the lower range value
  59514. * @param max defines the upper range value
  59515. * @returns the new Vector3
  59516. */
  59517. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  59518. /**
  59519. * 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"
  59520. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  59521. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  59522. * @param value defines the current value
  59523. * @param min defines the lower range value
  59524. * @param max defines the upper range value
  59525. * @param result defines the Vector3 where to store the result
  59526. */
  59527. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  59528. /**
  59529. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  59530. * @param value1 defines the first control point
  59531. * @param tangent1 defines the first tangent vector
  59532. * @param value2 defines the second control point
  59533. * @param tangent2 defines the second tangent vector
  59534. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  59535. * @returns the new Vector3
  59536. */
  59537. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  59538. /**
  59539. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  59540. * @param start defines the start value
  59541. * @param end defines the end value
  59542. * @param amount max defines amount between both (between 0 and 1)
  59543. * @returns the new Vector3
  59544. */
  59545. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  59546. /**
  59547. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  59548. * @param start defines the start value
  59549. * @param end defines the end value
  59550. * @param amount max defines amount between both (between 0 and 1)
  59551. * @param result defines the Vector3 where to store the result
  59552. */
  59553. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  59554. /**
  59555. * Returns the dot product (float) between the vectors "left" and "right"
  59556. * @param left defines the left operand
  59557. * @param right defines the right operand
  59558. * @returns the dot product
  59559. */
  59560. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  59561. /**
  59562. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  59563. * The cross product is then orthogonal to both "left" and "right"
  59564. * @param left defines the left operand
  59565. * @param right defines the right operand
  59566. * @returns the cross product
  59567. */
  59568. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  59569. /**
  59570. * Sets the given vector "result" with the cross product of "left" and "right"
  59571. * The cross product is then orthogonal to both "left" and "right"
  59572. * @param left defines the left operand
  59573. * @param right defines the right operand
  59574. * @param result defines the Vector3 where to store the result
  59575. */
  59576. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  59577. /**
  59578. * Returns a new Vector3 as the normalization of the given vector
  59579. * @param vector defines the Vector3 to normalize
  59580. * @returns the new Vector3
  59581. */
  59582. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  59583. /**
  59584. * Sets the given vector "result" with the normalization of the given first vector
  59585. * @param vector defines the Vector3 to normalize
  59586. * @param result defines the Vector3 where to store the result
  59587. */
  59588. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  59589. /**
  59590. * Project a Vector3 onto screen space
  59591. * @param vector defines the Vector3 to project
  59592. * @param world defines the world matrix to use
  59593. * @param transform defines the transform (view x projection) matrix to use
  59594. * @param viewport defines the screen viewport to use
  59595. * @returns the new Vector3
  59596. */
  59597. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  59598. /** @hidden */
  59599. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  59600. /**
  59601. * Unproject from screen space to object space
  59602. * @param source defines the screen space Vector3 to use
  59603. * @param viewportWidth defines the current width of the viewport
  59604. * @param viewportHeight defines the current height of the viewport
  59605. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59606. * @param transform defines the transform (view x projection) matrix to use
  59607. * @returns the new Vector3
  59608. */
  59609. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  59610. /**
  59611. * Unproject from screen space to object space
  59612. * @param source defines the screen space Vector3 to use
  59613. * @param viewportWidth defines the current width of the viewport
  59614. * @param viewportHeight defines the current height of the viewport
  59615. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59616. * @param view defines the view matrix to use
  59617. * @param projection defines the projection matrix to use
  59618. * @returns the new Vector3
  59619. */
  59620. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  59621. /**
  59622. * Unproject from screen space to object space
  59623. * @param source defines the screen space Vector3 to use
  59624. * @param viewportWidth defines the current width of the viewport
  59625. * @param viewportHeight defines the current height of the viewport
  59626. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59627. * @param view defines the view matrix to use
  59628. * @param projection defines the projection matrix to use
  59629. * @param result defines the Vector3 where to store the result
  59630. */
  59631. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  59632. /**
  59633. * Unproject from screen space to object space
  59634. * @param sourceX defines the screen space x coordinate to use
  59635. * @param sourceY defines the screen space y coordinate to use
  59636. * @param sourceZ defines the screen space z coordinate to use
  59637. * @param viewportWidth defines the current width of the viewport
  59638. * @param viewportHeight defines the current height of the viewport
  59639. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59640. * @param view defines the view matrix to use
  59641. * @param projection defines the projection matrix to use
  59642. * @param result defines the Vector3 where to store the result
  59643. */
  59644. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  59645. /**
  59646. * Gets the minimal coordinate values between two Vector3
  59647. * @param left defines the first operand
  59648. * @param right defines the second operand
  59649. * @returns the new Vector3
  59650. */
  59651. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  59652. /**
  59653. * Gets the maximal coordinate values between two Vector3
  59654. * @param left defines the first operand
  59655. * @param right defines the second operand
  59656. * @returns the new Vector3
  59657. */
  59658. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  59659. /**
  59660. * Returns the distance between the vectors "value1" and "value2"
  59661. * @param value1 defines the first operand
  59662. * @param value2 defines the second operand
  59663. * @returns the distance
  59664. */
  59665. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  59666. /**
  59667. * Returns the squared distance between the vectors "value1" and "value2"
  59668. * @param value1 defines the first operand
  59669. * @param value2 defines the second operand
  59670. * @returns the squared distance
  59671. */
  59672. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  59673. /**
  59674. * Returns a new Vector3 located at the center between "value1" and "value2"
  59675. * @param value1 defines the first operand
  59676. * @param value2 defines the second operand
  59677. * @returns the new Vector3
  59678. */
  59679. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  59680. /**
  59681. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  59682. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  59683. * to something in order to rotate it from its local system to the given target system
  59684. * Note: axis1, axis2 and axis3 are normalized during this operation
  59685. * @param axis1 defines the first axis
  59686. * @param axis2 defines the second axis
  59687. * @param axis3 defines the third axis
  59688. * @returns a new Vector3
  59689. */
  59690. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  59691. /**
  59692. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  59693. * @param axis1 defines the first axis
  59694. * @param axis2 defines the second axis
  59695. * @param axis3 defines the third axis
  59696. * @param ref defines the Vector3 where to store the result
  59697. */
  59698. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  59699. }
  59700. /**
  59701. * Vector4 class created for EulerAngle class conversion to Quaternion
  59702. */
  59703. export class Vector4 {
  59704. /** x value of the vector */
  59705. x: number;
  59706. /** y value of the vector */
  59707. y: number;
  59708. /** z value of the vector */
  59709. z: number;
  59710. /** w value of the vector */
  59711. w: number;
  59712. /**
  59713. * Creates a Vector4 object from the given floats.
  59714. * @param x x value of the vector
  59715. * @param y y value of the vector
  59716. * @param z z value of the vector
  59717. * @param w w value of the vector
  59718. */
  59719. constructor(
  59720. /** x value of the vector */
  59721. x: number,
  59722. /** y value of the vector */
  59723. y: number,
  59724. /** z value of the vector */
  59725. z: number,
  59726. /** w value of the vector */
  59727. w: number);
  59728. /**
  59729. * Returns the string with the Vector4 coordinates.
  59730. * @returns a string containing all the vector values
  59731. */
  59732. toString(): string;
  59733. /**
  59734. * Returns the string "Vector4".
  59735. * @returns "Vector4"
  59736. */
  59737. getClassName(): string;
  59738. /**
  59739. * Returns the Vector4 hash code.
  59740. * @returns a unique hash code
  59741. */
  59742. getHashCode(): number;
  59743. /**
  59744. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  59745. * @returns the resulting array
  59746. */
  59747. asArray(): number[];
  59748. /**
  59749. * Populates the given array from the given index with the Vector4 coordinates.
  59750. * @param array array to populate
  59751. * @param index index of the array to start at (default: 0)
  59752. * @returns the Vector4.
  59753. */
  59754. toArray(array: FloatArray, index?: number): Vector4;
  59755. /**
  59756. * Adds the given vector to the current Vector4.
  59757. * @param otherVector the vector to add
  59758. * @returns the updated Vector4.
  59759. */
  59760. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  59761. /**
  59762. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  59763. * @param otherVector the vector to add
  59764. * @returns the resulting vector
  59765. */
  59766. add(otherVector: DeepImmutable<Vector4>): Vector4;
  59767. /**
  59768. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  59769. * @param otherVector the vector to add
  59770. * @param result the vector to store the result
  59771. * @returns the current Vector4.
  59772. */
  59773. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59774. /**
  59775. * Subtract in place the given vector from the current Vector4.
  59776. * @param otherVector the vector to subtract
  59777. * @returns the updated Vector4.
  59778. */
  59779. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  59780. /**
  59781. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  59782. * @param otherVector the vector to add
  59783. * @returns the new vector with the result
  59784. */
  59785. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  59786. /**
  59787. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  59788. * @param otherVector the vector to subtract
  59789. * @param result the vector to store the result
  59790. * @returns the current Vector4.
  59791. */
  59792. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59793. /**
  59794. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  59795. */
  59796. /**
  59797. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  59798. * @param x value to subtract
  59799. * @param y value to subtract
  59800. * @param z value to subtract
  59801. * @param w value to subtract
  59802. * @returns new vector containing the result
  59803. */
  59804. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  59805. /**
  59806. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  59807. * @param x value to subtract
  59808. * @param y value to subtract
  59809. * @param z value to subtract
  59810. * @param w value to subtract
  59811. * @param result the vector to store the result in
  59812. * @returns the current Vector4.
  59813. */
  59814. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  59815. /**
  59816. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  59817. * @returns a new vector with the negated values
  59818. */
  59819. negate(): Vector4;
  59820. /**
  59821. * Multiplies the current Vector4 coordinates by scale (float).
  59822. * @param scale the number to scale with
  59823. * @returns the updated Vector4.
  59824. */
  59825. scaleInPlace(scale: number): Vector4;
  59826. /**
  59827. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  59828. * @param scale the number to scale with
  59829. * @returns a new vector with the result
  59830. */
  59831. scale(scale: number): Vector4;
  59832. /**
  59833. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  59834. * @param scale the number to scale with
  59835. * @param result a vector to store the result in
  59836. * @returns the current Vector4.
  59837. */
  59838. scaleToRef(scale: number, result: Vector4): Vector4;
  59839. /**
  59840. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  59841. * @param scale defines the scale factor
  59842. * @param result defines the Vector4 object where to store the result
  59843. * @returns the unmodified current Vector4
  59844. */
  59845. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  59846. /**
  59847. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  59848. * @param otherVector the vector to compare against
  59849. * @returns true if they are equal
  59850. */
  59851. equals(otherVector: DeepImmutable<Vector4>): boolean;
  59852. /**
  59853. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  59854. * @param otherVector vector to compare against
  59855. * @param epsilon (Default: very small number)
  59856. * @returns true if they are equal
  59857. */
  59858. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  59859. /**
  59860. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  59861. * @param x x value to compare against
  59862. * @param y y value to compare against
  59863. * @param z z value to compare against
  59864. * @param w w value to compare against
  59865. * @returns true if equal
  59866. */
  59867. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  59868. /**
  59869. * Multiplies in place the current Vector4 by the given one.
  59870. * @param otherVector vector to multiple with
  59871. * @returns the updated Vector4.
  59872. */
  59873. multiplyInPlace(otherVector: Vector4): Vector4;
  59874. /**
  59875. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  59876. * @param otherVector vector to multiple with
  59877. * @returns resulting new vector
  59878. */
  59879. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  59880. /**
  59881. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  59882. * @param otherVector vector to multiple with
  59883. * @param result vector to store the result
  59884. * @returns the current Vector4.
  59885. */
  59886. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59887. /**
  59888. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  59889. * @param x x value multiply with
  59890. * @param y y value multiply with
  59891. * @param z z value multiply with
  59892. * @param w w value multiply with
  59893. * @returns resulting new vector
  59894. */
  59895. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  59896. /**
  59897. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  59898. * @param otherVector vector to devide with
  59899. * @returns resulting new vector
  59900. */
  59901. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  59902. /**
  59903. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  59904. * @param otherVector vector to devide with
  59905. * @param result vector to store the result
  59906. * @returns the current Vector4.
  59907. */
  59908. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59909. /**
  59910. * Divides the current Vector3 coordinates by the given ones.
  59911. * @param otherVector vector to devide with
  59912. * @returns the updated Vector3.
  59913. */
  59914. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  59915. /**
  59916. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  59917. * @param other defines the second operand
  59918. * @returns the current updated Vector4
  59919. */
  59920. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  59921. /**
  59922. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  59923. * @param other defines the second operand
  59924. * @returns the current updated Vector4
  59925. */
  59926. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  59927. /**
  59928. * Gets a new Vector4 from current Vector4 floored values
  59929. * @returns a new Vector4
  59930. */
  59931. floor(): Vector4;
  59932. /**
  59933. * Gets a new Vector4 from current Vector3 floored values
  59934. * @returns a new Vector4
  59935. */
  59936. fract(): Vector4;
  59937. /**
  59938. * Returns the Vector4 length (float).
  59939. * @returns the length
  59940. */
  59941. length(): number;
  59942. /**
  59943. * Returns the Vector4 squared length (float).
  59944. * @returns the length squared
  59945. */
  59946. lengthSquared(): number;
  59947. /**
  59948. * Normalizes in place the Vector4.
  59949. * @returns the updated Vector4.
  59950. */
  59951. normalize(): Vector4;
  59952. /**
  59953. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  59954. * @returns this converted to a new vector3
  59955. */
  59956. toVector3(): Vector3;
  59957. /**
  59958. * Returns a new Vector4 copied from the current one.
  59959. * @returns the new cloned vector
  59960. */
  59961. clone(): Vector4;
  59962. /**
  59963. * Updates the current Vector4 with the given one coordinates.
  59964. * @param source the source vector to copy from
  59965. * @returns the updated Vector4.
  59966. */
  59967. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  59968. /**
  59969. * Updates the current Vector4 coordinates with the given floats.
  59970. * @param x float to copy from
  59971. * @param y float to copy from
  59972. * @param z float to copy from
  59973. * @param w float to copy from
  59974. * @returns the updated Vector4.
  59975. */
  59976. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  59977. /**
  59978. * Updates the current Vector4 coordinates with the given floats.
  59979. * @param x float to set from
  59980. * @param y float to set from
  59981. * @param z float to set from
  59982. * @param w float to set from
  59983. * @returns the updated Vector4.
  59984. */
  59985. set(x: number, y: number, z: number, w: number): Vector4;
  59986. /**
  59987. * Copies the given float to the current Vector3 coordinates
  59988. * @param v defines the x, y, z and w coordinates of the operand
  59989. * @returns the current updated Vector3
  59990. */
  59991. setAll(v: number): Vector4;
  59992. /**
  59993. * Returns a new Vector4 set from the starting index of the given array.
  59994. * @param array the array to pull values from
  59995. * @param offset the offset into the array to start at
  59996. * @returns the new vector
  59997. */
  59998. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  59999. /**
  60000. * Updates the given vector "result" from the starting index of the given array.
  60001. * @param array the array to pull values from
  60002. * @param offset the offset into the array to start at
  60003. * @param result the vector to store the result in
  60004. */
  60005. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  60006. /**
  60007. * Updates the given vector "result" from the starting index of the given Float32Array.
  60008. * @param array the array to pull values from
  60009. * @param offset the offset into the array to start at
  60010. * @param result the vector to store the result in
  60011. */
  60012. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  60013. /**
  60014. * Updates the given vector "result" coordinates from the given floats.
  60015. * @param x float to set from
  60016. * @param y float to set from
  60017. * @param z float to set from
  60018. * @param w float to set from
  60019. * @param result the vector to the floats in
  60020. */
  60021. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  60022. /**
  60023. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  60024. * @returns the new vector
  60025. */
  60026. static Zero(): Vector4;
  60027. /**
  60028. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  60029. * @returns the new vector
  60030. */
  60031. static One(): Vector4;
  60032. /**
  60033. * Returns a new normalized Vector4 from the given one.
  60034. * @param vector the vector to normalize
  60035. * @returns the vector
  60036. */
  60037. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  60038. /**
  60039. * Updates the given vector "result" from the normalization of the given one.
  60040. * @param vector the vector to normalize
  60041. * @param result the vector to store the result in
  60042. */
  60043. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  60044. /**
  60045. * Returns a vector with the minimum values from the left and right vectors
  60046. * @param left left vector to minimize
  60047. * @param right right vector to minimize
  60048. * @returns a new vector with the minimum of the left and right vector values
  60049. */
  60050. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  60051. /**
  60052. * Returns a vector with the maximum values from the left and right vectors
  60053. * @param left left vector to maximize
  60054. * @param right right vector to maximize
  60055. * @returns a new vector with the maximum of the left and right vector values
  60056. */
  60057. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  60058. /**
  60059. * Returns the distance (float) between the vectors "value1" and "value2".
  60060. * @param value1 value to calulate the distance between
  60061. * @param value2 value to calulate the distance between
  60062. * @return the distance between the two vectors
  60063. */
  60064. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  60065. /**
  60066. * Returns the squared distance (float) between the vectors "value1" and "value2".
  60067. * @param value1 value to calulate the distance between
  60068. * @param value2 value to calulate the distance between
  60069. * @return the distance between the two vectors squared
  60070. */
  60071. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  60072. /**
  60073. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  60074. * @param value1 value to calulate the center between
  60075. * @param value2 value to calulate the center between
  60076. * @return the center between the two vectors
  60077. */
  60078. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  60079. /**
  60080. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  60081. * This methods computes transformed normalized direction vectors only.
  60082. * @param vector the vector to transform
  60083. * @param transformation the transformation matrix to apply
  60084. * @returns the new vector
  60085. */
  60086. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  60087. /**
  60088. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  60089. * This methods computes transformed normalized direction vectors only.
  60090. * @param vector the vector to transform
  60091. * @param transformation the transformation matrix to apply
  60092. * @param result the vector to store the result in
  60093. */
  60094. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  60095. /**
  60096. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  60097. * This methods computes transformed normalized direction vectors only.
  60098. * @param x value to transform
  60099. * @param y value to transform
  60100. * @param z value to transform
  60101. * @param w value to transform
  60102. * @param transformation the transformation matrix to apply
  60103. * @param result the vector to store the results in
  60104. */
  60105. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  60106. /**
  60107. * Creates a new Vector4 from a Vector3
  60108. * @param source defines the source data
  60109. * @param w defines the 4th component (default is 0)
  60110. * @returns a new Vector4
  60111. */
  60112. static FromVector3(source: Vector3, w?: number): Vector4;
  60113. }
  60114. /**
  60115. * Interface for the size containing width and height
  60116. */
  60117. export interface ISize {
  60118. /**
  60119. * Width
  60120. */
  60121. width: number;
  60122. /**
  60123. * Heighht
  60124. */
  60125. height: number;
  60126. }
  60127. /**
  60128. * Size containing widht and height
  60129. */
  60130. export class Size implements ISize {
  60131. /**
  60132. * Width
  60133. */
  60134. width: number;
  60135. /**
  60136. * Height
  60137. */
  60138. height: number;
  60139. /**
  60140. * Creates a Size object from the given width and height (floats).
  60141. * @param width width of the new size
  60142. * @param height height of the new size
  60143. */
  60144. constructor(width: number, height: number);
  60145. /**
  60146. * Returns a string with the Size width and height
  60147. * @returns a string with the Size width and height
  60148. */
  60149. toString(): string;
  60150. /**
  60151. * "Size"
  60152. * @returns the string "Size"
  60153. */
  60154. getClassName(): string;
  60155. /**
  60156. * Returns the Size hash code.
  60157. * @returns a hash code for a unique width and height
  60158. */
  60159. getHashCode(): number;
  60160. /**
  60161. * Updates the current size from the given one.
  60162. * @param src the given size
  60163. */
  60164. copyFrom(src: Size): void;
  60165. /**
  60166. * Updates in place the current Size from the given floats.
  60167. * @param width width of the new size
  60168. * @param height height of the new size
  60169. * @returns the updated Size.
  60170. */
  60171. copyFromFloats(width: number, height: number): Size;
  60172. /**
  60173. * Updates in place the current Size from the given floats.
  60174. * @param width width to set
  60175. * @param height height to set
  60176. * @returns the updated Size.
  60177. */
  60178. set(width: number, height: number): Size;
  60179. /**
  60180. * Multiplies the width and height by numbers
  60181. * @param w factor to multiple the width by
  60182. * @param h factor to multiple the height by
  60183. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  60184. */
  60185. multiplyByFloats(w: number, h: number): Size;
  60186. /**
  60187. * Clones the size
  60188. * @returns a new Size copied from the given one.
  60189. */
  60190. clone(): Size;
  60191. /**
  60192. * True if the current Size and the given one width and height are strictly equal.
  60193. * @param other the other size to compare against
  60194. * @returns True if the current Size and the given one width and height are strictly equal.
  60195. */
  60196. equals(other: Size): boolean;
  60197. /**
  60198. * The surface of the Size : width * height (float).
  60199. */
  60200. readonly surface: number;
  60201. /**
  60202. * Create a new size of zero
  60203. * @returns a new Size set to (0.0, 0.0)
  60204. */
  60205. static Zero(): Size;
  60206. /**
  60207. * Sums the width and height of two sizes
  60208. * @param otherSize size to add to this size
  60209. * @returns a new Size set as the addition result of the current Size and the given one.
  60210. */
  60211. add(otherSize: Size): Size;
  60212. /**
  60213. * Subtracts the width and height of two
  60214. * @param otherSize size to subtract to this size
  60215. * @returns a new Size set as the subtraction result of the given one from the current Size.
  60216. */
  60217. subtract(otherSize: Size): Size;
  60218. /**
  60219. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  60220. * @param start starting size to lerp between
  60221. * @param end end size to lerp between
  60222. * @param amount amount to lerp between the start and end values
  60223. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  60224. */
  60225. static Lerp(start: Size, end: Size, amount: number): Size;
  60226. }
  60227. /**
  60228. * Class used to store quaternion data
  60229. * @see https://en.wikipedia.org/wiki/Quaternion
  60230. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  60231. */
  60232. export class Quaternion {
  60233. /** defines the first component (0 by default) */
  60234. x: number;
  60235. /** defines the second component (0 by default) */
  60236. y: number;
  60237. /** defines the third component (0 by default) */
  60238. z: number;
  60239. /** defines the fourth component (1.0 by default) */
  60240. w: number;
  60241. /**
  60242. * Creates a new Quaternion from the given floats
  60243. * @param x defines the first component (0 by default)
  60244. * @param y defines the second component (0 by default)
  60245. * @param z defines the third component (0 by default)
  60246. * @param w defines the fourth component (1.0 by default)
  60247. */
  60248. constructor(
  60249. /** defines the first component (0 by default) */
  60250. x?: number,
  60251. /** defines the second component (0 by default) */
  60252. y?: number,
  60253. /** defines the third component (0 by default) */
  60254. z?: number,
  60255. /** defines the fourth component (1.0 by default) */
  60256. w?: number);
  60257. /**
  60258. * Gets a string representation for the current quaternion
  60259. * @returns a string with the Quaternion coordinates
  60260. */
  60261. toString(): string;
  60262. /**
  60263. * Gets the class name of the quaternion
  60264. * @returns the string "Quaternion"
  60265. */
  60266. getClassName(): string;
  60267. /**
  60268. * Gets a hash code for this quaternion
  60269. * @returns the quaternion hash code
  60270. */
  60271. getHashCode(): number;
  60272. /**
  60273. * Copy the quaternion to an array
  60274. * @returns a new array populated with 4 elements from the quaternion coordinates
  60275. */
  60276. asArray(): number[];
  60277. /**
  60278. * Check if two quaternions are equals
  60279. * @param otherQuaternion defines the second operand
  60280. * @return true if the current quaternion and the given one coordinates are strictly equals
  60281. */
  60282. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  60283. /**
  60284. * Clone the current quaternion
  60285. * @returns a new quaternion copied from the current one
  60286. */
  60287. clone(): Quaternion;
  60288. /**
  60289. * Copy a quaternion to the current one
  60290. * @param other defines the other quaternion
  60291. * @returns the updated current quaternion
  60292. */
  60293. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  60294. /**
  60295. * Updates the current quaternion with the given float coordinates
  60296. * @param x defines the x coordinate
  60297. * @param y defines the y coordinate
  60298. * @param z defines the z coordinate
  60299. * @param w defines the w coordinate
  60300. * @returns the updated current quaternion
  60301. */
  60302. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  60303. /**
  60304. * Updates the current quaternion from the given float coordinates
  60305. * @param x defines the x coordinate
  60306. * @param y defines the y coordinate
  60307. * @param z defines the z coordinate
  60308. * @param w defines the w coordinate
  60309. * @returns the updated current quaternion
  60310. */
  60311. set(x: number, y: number, z: number, w: number): Quaternion;
  60312. /**
  60313. * Adds two quaternions
  60314. * @param other defines the second operand
  60315. * @returns a new quaternion as the addition result of the given one and the current quaternion
  60316. */
  60317. add(other: DeepImmutable<Quaternion>): Quaternion;
  60318. /**
  60319. * Add a quaternion to the current one
  60320. * @param other defines the quaternion to add
  60321. * @returns the current quaternion
  60322. */
  60323. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  60324. /**
  60325. * Subtract two quaternions
  60326. * @param other defines the second operand
  60327. * @returns a new quaternion as the subtraction result of the given one from the current one
  60328. */
  60329. subtract(other: Quaternion): Quaternion;
  60330. /**
  60331. * Multiplies the current quaternion by a scale factor
  60332. * @param value defines the scale factor
  60333. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  60334. */
  60335. scale(value: number): Quaternion;
  60336. /**
  60337. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  60338. * @param scale defines the scale factor
  60339. * @param result defines the Quaternion object where to store the result
  60340. * @returns the unmodified current quaternion
  60341. */
  60342. scaleToRef(scale: number, result: Quaternion): Quaternion;
  60343. /**
  60344. * Multiplies in place the current quaternion by a scale factor
  60345. * @param value defines the scale factor
  60346. * @returns the current modified quaternion
  60347. */
  60348. scaleInPlace(value: number): Quaternion;
  60349. /**
  60350. * Scale the current quaternion values by a factor and add the result to a given quaternion
  60351. * @param scale defines the scale factor
  60352. * @param result defines the Quaternion object where to store the result
  60353. * @returns the unmodified current quaternion
  60354. */
  60355. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  60356. /**
  60357. * Multiplies two quaternions
  60358. * @param q1 defines the second operand
  60359. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  60360. */
  60361. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  60362. /**
  60363. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  60364. * @param q1 defines the second operand
  60365. * @param result defines the target quaternion
  60366. * @returns the current quaternion
  60367. */
  60368. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  60369. /**
  60370. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  60371. * @param q1 defines the second operand
  60372. * @returns the currentupdated quaternion
  60373. */
  60374. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  60375. /**
  60376. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  60377. * @param ref defines the target quaternion
  60378. * @returns the current quaternion
  60379. */
  60380. conjugateToRef(ref: Quaternion): Quaternion;
  60381. /**
  60382. * Conjugates in place (1-q) the current quaternion
  60383. * @returns the current updated quaternion
  60384. */
  60385. conjugateInPlace(): Quaternion;
  60386. /**
  60387. * Conjugates in place (1-q) the current quaternion
  60388. * @returns a new quaternion
  60389. */
  60390. conjugate(): Quaternion;
  60391. /**
  60392. * Gets length of current quaternion
  60393. * @returns the quaternion length (float)
  60394. */
  60395. length(): number;
  60396. /**
  60397. * Normalize in place the current quaternion
  60398. * @returns the current updated quaternion
  60399. */
  60400. normalize(): Quaternion;
  60401. /**
  60402. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  60403. * @param order is a reserved parameter and is ignore for now
  60404. * @returns a new Vector3 containing the Euler angles
  60405. */
  60406. toEulerAngles(order?: string): Vector3;
  60407. /**
  60408. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  60409. * @param result defines the vector which will be filled with the Euler angles
  60410. * @param order is a reserved parameter and is ignore for now
  60411. * @returns the current unchanged quaternion
  60412. */
  60413. toEulerAnglesToRef(result: Vector3): Quaternion;
  60414. /**
  60415. * Updates the given rotation matrix with the current quaternion values
  60416. * @param result defines the target matrix
  60417. * @returns the current unchanged quaternion
  60418. */
  60419. toRotationMatrix(result: Matrix): Quaternion;
  60420. /**
  60421. * Updates the current quaternion from the given rotation matrix values
  60422. * @param matrix defines the source matrix
  60423. * @returns the current updated quaternion
  60424. */
  60425. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  60426. /**
  60427. * Creates a new quaternion from a rotation matrix
  60428. * @param matrix defines the source matrix
  60429. * @returns a new quaternion created from the given rotation matrix values
  60430. */
  60431. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  60432. /**
  60433. * Updates the given quaternion with the given rotation matrix values
  60434. * @param matrix defines the source matrix
  60435. * @param result defines the target quaternion
  60436. */
  60437. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  60438. /**
  60439. * Returns the dot product (float) between the quaternions "left" and "right"
  60440. * @param left defines the left operand
  60441. * @param right defines the right operand
  60442. * @returns the dot product
  60443. */
  60444. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  60445. /**
  60446. * Checks if the two quaternions are close to each other
  60447. * @param quat0 defines the first quaternion to check
  60448. * @param quat1 defines the second quaternion to check
  60449. * @returns true if the two quaternions are close to each other
  60450. */
  60451. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  60452. /**
  60453. * Creates an empty quaternion
  60454. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  60455. */
  60456. static Zero(): Quaternion;
  60457. /**
  60458. * Inverse a given quaternion
  60459. * @param q defines the source quaternion
  60460. * @returns a new quaternion as the inverted current quaternion
  60461. */
  60462. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  60463. /**
  60464. * Inverse a given quaternion
  60465. * @param q defines the source quaternion
  60466. * @param result the quaternion the result will be stored in
  60467. * @returns the result quaternion
  60468. */
  60469. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  60470. /**
  60471. * Creates an identity quaternion
  60472. * @returns the identity quaternion
  60473. */
  60474. static Identity(): Quaternion;
  60475. /**
  60476. * Gets a boolean indicating if the given quaternion is identity
  60477. * @param quaternion defines the quaternion to check
  60478. * @returns true if the quaternion is identity
  60479. */
  60480. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  60481. /**
  60482. * Creates a quaternion from a rotation around an axis
  60483. * @param axis defines the axis to use
  60484. * @param angle defines the angle to use
  60485. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  60486. */
  60487. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  60488. /**
  60489. * Creates a rotation around an axis and stores it into the given quaternion
  60490. * @param axis defines the axis to use
  60491. * @param angle defines the angle to use
  60492. * @param result defines the target quaternion
  60493. * @returns the target quaternion
  60494. */
  60495. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  60496. /**
  60497. * Creates a new quaternion from data stored into an array
  60498. * @param array defines the data source
  60499. * @param offset defines the offset in the source array where the data starts
  60500. * @returns a new quaternion
  60501. */
  60502. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  60503. /**
  60504. * Create a quaternion from Euler rotation angles
  60505. * @param x Pitch
  60506. * @param y Yaw
  60507. * @param z Roll
  60508. * @returns the new Quaternion
  60509. */
  60510. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  60511. /**
  60512. * Updates a quaternion from Euler rotation angles
  60513. * @param x Pitch
  60514. * @param y Yaw
  60515. * @param z Roll
  60516. * @param result the quaternion to store the result
  60517. * @returns the updated quaternion
  60518. */
  60519. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  60520. /**
  60521. * Create a quaternion from Euler rotation vector
  60522. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  60523. * @returns the new Quaternion
  60524. */
  60525. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  60526. /**
  60527. * Updates a quaternion from Euler rotation vector
  60528. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  60529. * @param result the quaternion to store the result
  60530. * @returns the updated quaternion
  60531. */
  60532. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  60533. /**
  60534. * Creates a new quaternion from the given Euler float angles (y, x, z)
  60535. * @param yaw defines the rotation around Y axis
  60536. * @param pitch defines the rotation around X axis
  60537. * @param roll defines the rotation around Z axis
  60538. * @returns the new quaternion
  60539. */
  60540. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  60541. /**
  60542. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  60543. * @param yaw defines the rotation around Y axis
  60544. * @param pitch defines the rotation around X axis
  60545. * @param roll defines the rotation around Z axis
  60546. * @param result defines the target quaternion
  60547. */
  60548. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  60549. /**
  60550. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  60551. * @param alpha defines the rotation around first axis
  60552. * @param beta defines the rotation around second axis
  60553. * @param gamma defines the rotation around third axis
  60554. * @returns the new quaternion
  60555. */
  60556. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  60557. /**
  60558. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  60559. * @param alpha defines the rotation around first axis
  60560. * @param beta defines the rotation around second axis
  60561. * @param gamma defines the rotation around third axis
  60562. * @param result defines the target quaternion
  60563. */
  60564. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  60565. /**
  60566. * 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)
  60567. * @param axis1 defines the first axis
  60568. * @param axis2 defines the second axis
  60569. * @param axis3 defines the third axis
  60570. * @returns the new quaternion
  60571. */
  60572. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  60573. /**
  60574. * 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
  60575. * @param axis1 defines the first axis
  60576. * @param axis2 defines the second axis
  60577. * @param axis3 defines the third axis
  60578. * @param ref defines the target quaternion
  60579. */
  60580. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  60581. /**
  60582. * Interpolates between two quaternions
  60583. * @param left defines first quaternion
  60584. * @param right defines second quaternion
  60585. * @param amount defines the gradient to use
  60586. * @returns the new interpolated quaternion
  60587. */
  60588. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  60589. /**
  60590. * Interpolates between two quaternions and stores it into a target quaternion
  60591. * @param left defines first quaternion
  60592. * @param right defines second quaternion
  60593. * @param amount defines the gradient to use
  60594. * @param result defines the target quaternion
  60595. */
  60596. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  60597. /**
  60598. * Interpolate between two quaternions using Hermite interpolation
  60599. * @param value1 defines first quaternion
  60600. * @param tangent1 defines the incoming tangent
  60601. * @param value2 defines second quaternion
  60602. * @param tangent2 defines the outgoing tangent
  60603. * @param amount defines the target quaternion
  60604. * @returns the new interpolated quaternion
  60605. */
  60606. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  60607. }
  60608. /**
  60609. * Class used to store matrix data (4x4)
  60610. */
  60611. export class Matrix {
  60612. private static _updateFlagSeed;
  60613. private static _identityReadOnly;
  60614. private _isIdentity;
  60615. private _isIdentityDirty;
  60616. private _isIdentity3x2;
  60617. private _isIdentity3x2Dirty;
  60618. /**
  60619. * Gets the update flag of the matrix which is an unique number for the matrix.
  60620. * It will be incremented every time the matrix data change.
  60621. * You can use it to speed the comparison between two versions of the same matrix.
  60622. */
  60623. updateFlag: number;
  60624. private readonly _m;
  60625. /**
  60626. * Gets the internal data of the matrix
  60627. */
  60628. readonly m: DeepImmutable<Float32Array>;
  60629. /** @hidden */
  60630. _markAsUpdated(): void;
  60631. /** @hidden */
  60632. private _updateIdentityStatus;
  60633. /**
  60634. * Creates an empty matrix (filled with zeros)
  60635. */
  60636. constructor();
  60637. /**
  60638. * Check if the current matrix is identity
  60639. * @returns true is the matrix is the identity matrix
  60640. */
  60641. isIdentity(): boolean;
  60642. /**
  60643. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  60644. * @returns true is the matrix is the identity matrix
  60645. */
  60646. isIdentityAs3x2(): boolean;
  60647. /**
  60648. * Gets the determinant of the matrix
  60649. * @returns the matrix determinant
  60650. */
  60651. determinant(): number;
  60652. /**
  60653. * Returns the matrix as a Float32Array
  60654. * @returns the matrix underlying array
  60655. */
  60656. toArray(): DeepImmutable<Float32Array>;
  60657. /**
  60658. * Returns the matrix as a Float32Array
  60659. * @returns the matrix underlying array.
  60660. */
  60661. asArray(): DeepImmutable<Float32Array>;
  60662. /**
  60663. * Inverts the current matrix in place
  60664. * @returns the current inverted matrix
  60665. */
  60666. invert(): Matrix;
  60667. /**
  60668. * Sets all the matrix elements to zero
  60669. * @returns the current matrix
  60670. */
  60671. reset(): Matrix;
  60672. /**
  60673. * Adds the current matrix with a second one
  60674. * @param other defines the matrix to add
  60675. * @returns a new matrix as the addition of the current matrix and the given one
  60676. */
  60677. add(other: DeepImmutable<Matrix>): Matrix;
  60678. /**
  60679. * Sets the given matrix "result" to the addition of the current matrix and the given one
  60680. * @param other defines the matrix to add
  60681. * @param result defines the target matrix
  60682. * @returns the current matrix
  60683. */
  60684. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  60685. /**
  60686. * Adds in place the given matrix to the current matrix
  60687. * @param other defines the second operand
  60688. * @returns the current updated matrix
  60689. */
  60690. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  60691. /**
  60692. * Sets the given matrix to the current inverted Matrix
  60693. * @param other defines the target matrix
  60694. * @returns the unmodified current matrix
  60695. */
  60696. invertToRef(other: Matrix): Matrix;
  60697. /**
  60698. * add a value at the specified position in the current Matrix
  60699. * @param index the index of the value within the matrix. between 0 and 15.
  60700. * @param value the value to be added
  60701. * @returns the current updated matrix
  60702. */
  60703. addAtIndex(index: number, value: number): Matrix;
  60704. /**
  60705. * mutiply the specified position in the current Matrix by a value
  60706. * @param index the index of the value within the matrix. between 0 and 15.
  60707. * @param value the value to be added
  60708. * @returns the current updated matrix
  60709. */
  60710. multiplyAtIndex(index: number, value: number): Matrix;
  60711. /**
  60712. * Inserts the translation vector (using 3 floats) in the current matrix
  60713. * @param x defines the 1st component of the translation
  60714. * @param y defines the 2nd component of the translation
  60715. * @param z defines the 3rd component of the translation
  60716. * @returns the current updated matrix
  60717. */
  60718. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  60719. /**
  60720. * Inserts the translation vector in the current matrix
  60721. * @param vector3 defines the translation to insert
  60722. * @returns the current updated matrix
  60723. */
  60724. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  60725. /**
  60726. * Gets the translation value of the current matrix
  60727. * @returns a new Vector3 as the extracted translation from the matrix
  60728. */
  60729. getTranslation(): Vector3;
  60730. /**
  60731. * Fill a Vector3 with the extracted translation from the matrix
  60732. * @param result defines the Vector3 where to store the translation
  60733. * @returns the current matrix
  60734. */
  60735. getTranslationToRef(result: Vector3): Matrix;
  60736. /**
  60737. * Remove rotation and scaling part from the matrix
  60738. * @returns the updated matrix
  60739. */
  60740. removeRotationAndScaling(): Matrix;
  60741. /**
  60742. * Multiply two matrices
  60743. * @param other defines the second operand
  60744. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  60745. */
  60746. multiply(other: DeepImmutable<Matrix>): Matrix;
  60747. /**
  60748. * Copy the current matrix from the given one
  60749. * @param other defines the source matrix
  60750. * @returns the current updated matrix
  60751. */
  60752. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  60753. /**
  60754. * Populates the given array from the starting index with the current matrix values
  60755. * @param array defines the target array
  60756. * @param offset defines the offset in the target array where to start storing values
  60757. * @returns the current matrix
  60758. */
  60759. copyToArray(array: Float32Array, offset?: number): Matrix;
  60760. /**
  60761. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  60762. * @param other defines the second operand
  60763. * @param result defines the matrix where to store the multiplication
  60764. * @returns the current matrix
  60765. */
  60766. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  60767. /**
  60768. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  60769. * @param other defines the second operand
  60770. * @param result defines the array where to store the multiplication
  60771. * @param offset defines the offset in the target array where to start storing values
  60772. * @returns the current matrix
  60773. */
  60774. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  60775. /**
  60776. * Check equality between this matrix and a second one
  60777. * @param value defines the second matrix to compare
  60778. * @returns true is the current matrix and the given one values are strictly equal
  60779. */
  60780. equals(value: DeepImmutable<Matrix>): boolean;
  60781. /**
  60782. * Clone the current matrix
  60783. * @returns a new matrix from the current matrix
  60784. */
  60785. clone(): Matrix;
  60786. /**
  60787. * Returns the name of the current matrix class
  60788. * @returns the string "Matrix"
  60789. */
  60790. getClassName(): string;
  60791. /**
  60792. * Gets the hash code of the current matrix
  60793. * @returns the hash code
  60794. */
  60795. getHashCode(): number;
  60796. /**
  60797. * Decomposes the current Matrix into a translation, rotation and scaling components
  60798. * @param scale defines the scale vector3 given as a reference to update
  60799. * @param rotation defines the rotation quaternion given as a reference to update
  60800. * @param translation defines the translation vector3 given as a reference to update
  60801. * @returns true if operation was successful
  60802. */
  60803. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  60804. /**
  60805. * Gets specific row of the matrix
  60806. * @param index defines the number of the row to get
  60807. * @returns the index-th row of the current matrix as a new Vector4
  60808. */
  60809. getRow(index: number): Nullable<Vector4>;
  60810. /**
  60811. * Sets the index-th row of the current matrix to the vector4 values
  60812. * @param index defines the number of the row to set
  60813. * @param row defines the target vector4
  60814. * @returns the updated current matrix
  60815. */
  60816. setRow(index: number, row: Vector4): Matrix;
  60817. /**
  60818. * Compute the transpose of the matrix
  60819. * @returns the new transposed matrix
  60820. */
  60821. transpose(): Matrix;
  60822. /**
  60823. * Compute the transpose of the matrix and store it in a given matrix
  60824. * @param result defines the target matrix
  60825. * @returns the current matrix
  60826. */
  60827. transposeToRef(result: Matrix): Matrix;
  60828. /**
  60829. * Sets the index-th row of the current matrix with the given 4 x float values
  60830. * @param index defines the row index
  60831. * @param x defines the x component to set
  60832. * @param y defines the y component to set
  60833. * @param z defines the z component to set
  60834. * @param w defines the w component to set
  60835. * @returns the updated current matrix
  60836. */
  60837. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  60838. /**
  60839. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  60840. * @param scale defines the scale factor
  60841. * @returns a new matrix
  60842. */
  60843. scale(scale: number): Matrix;
  60844. /**
  60845. * Scale the current matrix values by a factor to a given result matrix
  60846. * @param scale defines the scale factor
  60847. * @param result defines the matrix to store the result
  60848. * @returns the current matrix
  60849. */
  60850. scaleToRef(scale: number, result: Matrix): Matrix;
  60851. /**
  60852. * Scale the current matrix values by a factor and add the result to a given matrix
  60853. * @param scale defines the scale factor
  60854. * @param result defines the Matrix to store the result
  60855. * @returns the current matrix
  60856. */
  60857. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  60858. /**
  60859. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  60860. * @param ref matrix to store the result
  60861. */
  60862. toNormalMatrix(ref: Matrix): void;
  60863. /**
  60864. * Gets only rotation part of the current matrix
  60865. * @returns a new matrix sets to the extracted rotation matrix from the current one
  60866. */
  60867. getRotationMatrix(): Matrix;
  60868. /**
  60869. * Extracts the rotation matrix from the current one and sets it as the given "result"
  60870. * @param result defines the target matrix to store data to
  60871. * @returns the current matrix
  60872. */
  60873. getRotationMatrixToRef(result: Matrix): Matrix;
  60874. /**
  60875. * Toggles model matrix from being right handed to left handed in place and vice versa
  60876. */
  60877. toggleModelMatrixHandInPlace(): void;
  60878. /**
  60879. * Toggles projection matrix from being right handed to left handed in place and vice versa
  60880. */
  60881. toggleProjectionMatrixHandInPlace(): void;
  60882. /**
  60883. * Creates a matrix from an array
  60884. * @param array defines the source array
  60885. * @param offset defines an offset in the source array
  60886. * @returns a new Matrix set from the starting index of the given array
  60887. */
  60888. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  60889. /**
  60890. * Copy the content of an array into a given matrix
  60891. * @param array defines the source array
  60892. * @param offset defines an offset in the source array
  60893. * @param result defines the target matrix
  60894. */
  60895. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  60896. /**
  60897. * Stores an array into a matrix after having multiplied each component by a given factor
  60898. * @param array defines the source array
  60899. * @param offset defines the offset in the source array
  60900. * @param scale defines the scaling factor
  60901. * @param result defines the target matrix
  60902. */
  60903. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  60904. /**
  60905. * Gets an identity matrix that must not be updated
  60906. */
  60907. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  60908. /**
  60909. * Stores a list of values (16) inside a given matrix
  60910. * @param initialM11 defines 1st value of 1st row
  60911. * @param initialM12 defines 2nd value of 1st row
  60912. * @param initialM13 defines 3rd value of 1st row
  60913. * @param initialM14 defines 4th value of 1st row
  60914. * @param initialM21 defines 1st value of 2nd row
  60915. * @param initialM22 defines 2nd value of 2nd row
  60916. * @param initialM23 defines 3rd value of 2nd row
  60917. * @param initialM24 defines 4th value of 2nd row
  60918. * @param initialM31 defines 1st value of 3rd row
  60919. * @param initialM32 defines 2nd value of 3rd row
  60920. * @param initialM33 defines 3rd value of 3rd row
  60921. * @param initialM34 defines 4th value of 3rd row
  60922. * @param initialM41 defines 1st value of 4th row
  60923. * @param initialM42 defines 2nd value of 4th row
  60924. * @param initialM43 defines 3rd value of 4th row
  60925. * @param initialM44 defines 4th value of 4th row
  60926. * @param result defines the target matrix
  60927. */
  60928. 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;
  60929. /**
  60930. * Creates new matrix from a list of values (16)
  60931. * @param initialM11 defines 1st value of 1st row
  60932. * @param initialM12 defines 2nd value of 1st row
  60933. * @param initialM13 defines 3rd value of 1st row
  60934. * @param initialM14 defines 4th value of 1st row
  60935. * @param initialM21 defines 1st value of 2nd row
  60936. * @param initialM22 defines 2nd value of 2nd row
  60937. * @param initialM23 defines 3rd value of 2nd row
  60938. * @param initialM24 defines 4th value of 2nd row
  60939. * @param initialM31 defines 1st value of 3rd row
  60940. * @param initialM32 defines 2nd value of 3rd row
  60941. * @param initialM33 defines 3rd value of 3rd row
  60942. * @param initialM34 defines 4th value of 3rd row
  60943. * @param initialM41 defines 1st value of 4th row
  60944. * @param initialM42 defines 2nd value of 4th row
  60945. * @param initialM43 defines 3rd value of 4th row
  60946. * @param initialM44 defines 4th value of 4th row
  60947. * @returns the new matrix
  60948. */
  60949. 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;
  60950. /**
  60951. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  60952. * @param scale defines the scale vector3
  60953. * @param rotation defines the rotation quaternion
  60954. * @param translation defines the translation vector3
  60955. * @returns a new matrix
  60956. */
  60957. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  60958. /**
  60959. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  60960. * @param scale defines the scale vector3
  60961. * @param rotation defines the rotation quaternion
  60962. * @param translation defines the translation vector3
  60963. * @param result defines the target matrix
  60964. */
  60965. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  60966. /**
  60967. * Creates a new identity matrix
  60968. * @returns a new identity matrix
  60969. */
  60970. static Identity(): Matrix;
  60971. /**
  60972. * Creates a new identity matrix and stores the result in a given matrix
  60973. * @param result defines the target matrix
  60974. */
  60975. static IdentityToRef(result: Matrix): void;
  60976. /**
  60977. * Creates a new zero matrix
  60978. * @returns a new zero matrix
  60979. */
  60980. static Zero(): Matrix;
  60981. /**
  60982. * Creates a new rotation matrix for "angle" radians around the X axis
  60983. * @param angle defines the angle (in radians) to use
  60984. * @return the new matrix
  60985. */
  60986. static RotationX(angle: number): Matrix;
  60987. /**
  60988. * Creates a new matrix as the invert of a given matrix
  60989. * @param source defines the source matrix
  60990. * @returns the new matrix
  60991. */
  60992. static Invert(source: DeepImmutable<Matrix>): Matrix;
  60993. /**
  60994. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  60995. * @param angle defines the angle (in radians) to use
  60996. * @param result defines the target matrix
  60997. */
  60998. static RotationXToRef(angle: number, result: Matrix): void;
  60999. /**
  61000. * Creates a new rotation matrix for "angle" radians around the Y axis
  61001. * @param angle defines the angle (in radians) to use
  61002. * @return the new matrix
  61003. */
  61004. static RotationY(angle: number): Matrix;
  61005. /**
  61006. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  61007. * @param angle defines the angle (in radians) to use
  61008. * @param result defines the target matrix
  61009. */
  61010. static RotationYToRef(angle: number, result: Matrix): void;
  61011. /**
  61012. * Creates a new rotation matrix for "angle" radians around the Z axis
  61013. * @param angle defines the angle (in radians) to use
  61014. * @return the new matrix
  61015. */
  61016. static RotationZ(angle: number): Matrix;
  61017. /**
  61018. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  61019. * @param angle defines the angle (in radians) to use
  61020. * @param result defines the target matrix
  61021. */
  61022. static RotationZToRef(angle: number, result: Matrix): void;
  61023. /**
  61024. * Creates a new rotation matrix for "angle" radians around the given axis
  61025. * @param axis defines the axis to use
  61026. * @param angle defines the angle (in radians) to use
  61027. * @return the new matrix
  61028. */
  61029. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  61030. /**
  61031. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  61032. * @param axis defines the axis to use
  61033. * @param angle defines the angle (in radians) to use
  61034. * @param result defines the target matrix
  61035. */
  61036. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  61037. /**
  61038. * Creates a rotation matrix
  61039. * @param yaw defines the yaw angle in radians (Y axis)
  61040. * @param pitch defines the pitch angle in radians (X axis)
  61041. * @param roll defines the roll angle in radians (X axis)
  61042. * @returns the new rotation matrix
  61043. */
  61044. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  61045. /**
  61046. * Creates a rotation matrix and stores it in a given matrix
  61047. * @param yaw defines the yaw angle in radians (Y axis)
  61048. * @param pitch defines the pitch angle in radians (X axis)
  61049. * @param roll defines the roll angle in radians (X axis)
  61050. * @param result defines the target matrix
  61051. */
  61052. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  61053. /**
  61054. * Creates a scaling matrix
  61055. * @param x defines the scale factor on X axis
  61056. * @param y defines the scale factor on Y axis
  61057. * @param z defines the scale factor on Z axis
  61058. * @returns the new matrix
  61059. */
  61060. static Scaling(x: number, y: number, z: number): Matrix;
  61061. /**
  61062. * Creates a scaling matrix and stores it in a given matrix
  61063. * @param x defines the scale factor on X axis
  61064. * @param y defines the scale factor on Y axis
  61065. * @param z defines the scale factor on Z axis
  61066. * @param result defines the target matrix
  61067. */
  61068. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  61069. /**
  61070. * Creates a translation matrix
  61071. * @param x defines the translation on X axis
  61072. * @param y defines the translation on Y axis
  61073. * @param z defines the translationon Z axis
  61074. * @returns the new matrix
  61075. */
  61076. static Translation(x: number, y: number, z: number): Matrix;
  61077. /**
  61078. * Creates a translation matrix and stores it in a given matrix
  61079. * @param x defines the translation on X axis
  61080. * @param y defines the translation on Y axis
  61081. * @param z defines the translationon Z axis
  61082. * @param result defines the target matrix
  61083. */
  61084. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  61085. /**
  61086. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  61087. * @param startValue defines the start value
  61088. * @param endValue defines the end value
  61089. * @param gradient defines the gradient factor
  61090. * @returns the new matrix
  61091. */
  61092. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  61093. /**
  61094. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  61095. * @param startValue defines the start value
  61096. * @param endValue defines the end value
  61097. * @param gradient defines the gradient factor
  61098. * @param result defines the Matrix object where to store data
  61099. */
  61100. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  61101. /**
  61102. * Builds a new matrix whose values are computed by:
  61103. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  61104. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  61105. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  61106. * @param startValue defines the first matrix
  61107. * @param endValue defines the second matrix
  61108. * @param gradient defines the gradient between the two matrices
  61109. * @returns the new matrix
  61110. */
  61111. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  61112. /**
  61113. * Update a matrix to values which are computed by:
  61114. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  61115. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  61116. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  61117. * @param startValue defines the first matrix
  61118. * @param endValue defines the second matrix
  61119. * @param gradient defines the gradient between the two matrices
  61120. * @param result defines the target matrix
  61121. */
  61122. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  61123. /**
  61124. * 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"
  61125. * This function works in left handed mode
  61126. * @param eye defines the final position of the entity
  61127. * @param target defines where the entity should look at
  61128. * @param up defines the up vector for the entity
  61129. * @returns the new matrix
  61130. */
  61131. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  61132. /**
  61133. * 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".
  61134. * This function works in left handed mode
  61135. * @param eye defines the final position of the entity
  61136. * @param target defines where the entity should look at
  61137. * @param up defines the up vector for the entity
  61138. * @param result defines the target matrix
  61139. */
  61140. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  61141. /**
  61142. * 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"
  61143. * This function works in right handed mode
  61144. * @param eye defines the final position of the entity
  61145. * @param target defines where the entity should look at
  61146. * @param up defines the up vector for the entity
  61147. * @returns the new matrix
  61148. */
  61149. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  61150. /**
  61151. * 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".
  61152. * This function works in right handed mode
  61153. * @param eye defines the final position of the entity
  61154. * @param target defines where the entity should look at
  61155. * @param up defines the up vector for the entity
  61156. * @param result defines the target matrix
  61157. */
  61158. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  61159. /**
  61160. * Create a left-handed orthographic projection matrix
  61161. * @param width defines the viewport width
  61162. * @param height defines the viewport height
  61163. * @param znear defines the near clip plane
  61164. * @param zfar defines the far clip plane
  61165. * @returns a new matrix as a left-handed orthographic projection matrix
  61166. */
  61167. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  61168. /**
  61169. * Store a left-handed orthographic projection to a given matrix
  61170. * @param width defines the viewport width
  61171. * @param height defines the viewport height
  61172. * @param znear defines the near clip plane
  61173. * @param zfar defines the far clip plane
  61174. * @param result defines the target matrix
  61175. */
  61176. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  61177. /**
  61178. * Create a left-handed orthographic projection matrix
  61179. * @param left defines the viewport left coordinate
  61180. * @param right defines the viewport right coordinate
  61181. * @param bottom defines the viewport bottom coordinate
  61182. * @param top defines the viewport top coordinate
  61183. * @param znear defines the near clip plane
  61184. * @param zfar defines the far clip plane
  61185. * @returns a new matrix as a left-handed orthographic projection matrix
  61186. */
  61187. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  61188. /**
  61189. * Stores a left-handed orthographic projection into a given matrix
  61190. * @param left defines the viewport left coordinate
  61191. * @param right defines the viewport right coordinate
  61192. * @param bottom defines the viewport bottom coordinate
  61193. * @param top defines the viewport top coordinate
  61194. * @param znear defines the near clip plane
  61195. * @param zfar defines the far clip plane
  61196. * @param result defines the target matrix
  61197. */
  61198. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  61199. /**
  61200. * Creates a right-handed orthographic projection matrix
  61201. * @param left defines the viewport left coordinate
  61202. * @param right defines the viewport right coordinate
  61203. * @param bottom defines the viewport bottom coordinate
  61204. * @param top defines the viewport top coordinate
  61205. * @param znear defines the near clip plane
  61206. * @param zfar defines the far clip plane
  61207. * @returns a new matrix as a right-handed orthographic projection matrix
  61208. */
  61209. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  61210. /**
  61211. * Stores a right-handed orthographic projection into a given matrix
  61212. * @param left defines the viewport left coordinate
  61213. * @param right defines the viewport right coordinate
  61214. * @param bottom defines the viewport bottom coordinate
  61215. * @param top defines the viewport top coordinate
  61216. * @param znear defines the near clip plane
  61217. * @param zfar defines the far clip plane
  61218. * @param result defines the target matrix
  61219. */
  61220. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  61221. /**
  61222. * Creates a left-handed perspective projection matrix
  61223. * @param width defines the viewport width
  61224. * @param height defines the viewport height
  61225. * @param znear defines the near clip plane
  61226. * @param zfar defines the far clip plane
  61227. * @returns a new matrix as a left-handed perspective projection matrix
  61228. */
  61229. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  61230. /**
  61231. * Creates a left-handed perspective projection matrix
  61232. * @param fov defines the horizontal field of view
  61233. * @param aspect defines the aspect ratio
  61234. * @param znear defines the near clip plane
  61235. * @param zfar defines the far clip plane
  61236. * @returns a new matrix as a left-handed perspective projection matrix
  61237. */
  61238. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  61239. /**
  61240. * Stores a left-handed perspective projection into a given matrix
  61241. * @param fov defines the horizontal field of view
  61242. * @param aspect defines the aspect ratio
  61243. * @param znear defines the near clip plane
  61244. * @param zfar defines the far clip plane
  61245. * @param result defines the target matrix
  61246. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  61247. */
  61248. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  61249. /**
  61250. * Creates a right-handed perspective projection matrix
  61251. * @param fov defines the horizontal field of view
  61252. * @param aspect defines the aspect ratio
  61253. * @param znear defines the near clip plane
  61254. * @param zfar defines the far clip plane
  61255. * @returns a new matrix as a right-handed perspective projection matrix
  61256. */
  61257. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  61258. /**
  61259. * Stores a right-handed perspective projection into a given matrix
  61260. * @param fov defines the horizontal field of view
  61261. * @param aspect defines the aspect ratio
  61262. * @param znear defines the near clip plane
  61263. * @param zfar defines the far clip plane
  61264. * @param result defines the target matrix
  61265. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  61266. */
  61267. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  61268. /**
  61269. * Stores a perspective projection for WebVR info a given matrix
  61270. * @param fov defines the field of view
  61271. * @param znear defines the near clip plane
  61272. * @param zfar defines the far clip plane
  61273. * @param result defines the target matrix
  61274. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  61275. */
  61276. static PerspectiveFovWebVRToRef(fov: {
  61277. upDegrees: number;
  61278. downDegrees: number;
  61279. leftDegrees: number;
  61280. rightDegrees: number;
  61281. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  61282. /**
  61283. * Computes a complete transformation matrix
  61284. * @param viewport defines the viewport to use
  61285. * @param world defines the world matrix
  61286. * @param view defines the view matrix
  61287. * @param projection defines the projection matrix
  61288. * @param zmin defines the near clip plane
  61289. * @param zmax defines the far clip plane
  61290. * @returns the transformation matrix
  61291. */
  61292. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  61293. /**
  61294. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  61295. * @param matrix defines the matrix to use
  61296. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  61297. */
  61298. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  61299. /**
  61300. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  61301. * @param matrix defines the matrix to use
  61302. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  61303. */
  61304. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  61305. /**
  61306. * Compute the transpose of a given matrix
  61307. * @param matrix defines the matrix to transpose
  61308. * @returns the new matrix
  61309. */
  61310. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  61311. /**
  61312. * Compute the transpose of a matrix and store it in a target matrix
  61313. * @param matrix defines the matrix to transpose
  61314. * @param result defines the target matrix
  61315. */
  61316. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  61317. /**
  61318. * Computes a reflection matrix from a plane
  61319. * @param plane defines the reflection plane
  61320. * @returns a new matrix
  61321. */
  61322. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  61323. /**
  61324. * Computes a reflection matrix from a plane
  61325. * @param plane defines the reflection plane
  61326. * @param result defines the target matrix
  61327. */
  61328. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  61329. /**
  61330. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  61331. * @param xaxis defines the value of the 1st axis
  61332. * @param yaxis defines the value of the 2nd axis
  61333. * @param zaxis defines the value of the 3rd axis
  61334. * @param result defines the target matrix
  61335. */
  61336. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  61337. /**
  61338. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  61339. * @param quat defines the quaternion to use
  61340. * @param result defines the target matrix
  61341. */
  61342. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  61343. }
  61344. /**
  61345. * Represens a plane by the equation ax + by + cz + d = 0
  61346. */
  61347. export class Plane {
  61348. /**
  61349. * Normal of the plane (a,b,c)
  61350. */
  61351. normal: Vector3;
  61352. /**
  61353. * d component of the plane
  61354. */
  61355. d: number;
  61356. /**
  61357. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  61358. * @param a a component of the plane
  61359. * @param b b component of the plane
  61360. * @param c c component of the plane
  61361. * @param d d component of the plane
  61362. */
  61363. constructor(a: number, b: number, c: number, d: number);
  61364. /**
  61365. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  61366. */
  61367. asArray(): number[];
  61368. /**
  61369. * @returns a new plane copied from the current Plane.
  61370. */
  61371. clone(): Plane;
  61372. /**
  61373. * @returns the string "Plane".
  61374. */
  61375. getClassName(): string;
  61376. /**
  61377. * @returns the Plane hash code.
  61378. */
  61379. getHashCode(): number;
  61380. /**
  61381. * Normalize the current Plane in place.
  61382. * @returns the updated Plane.
  61383. */
  61384. normalize(): Plane;
  61385. /**
  61386. * Applies a transformation the plane and returns the result
  61387. * @param transformation the transformation matrix to be applied to the plane
  61388. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  61389. */
  61390. transform(transformation: DeepImmutable<Matrix>): Plane;
  61391. /**
  61392. * Calcualtte the dot product between the point and the plane normal
  61393. * @param point point to calculate the dot product with
  61394. * @returns the dot product (float) of the point coordinates and the plane normal.
  61395. */
  61396. dotCoordinate(point: DeepImmutable<Vector3>): number;
  61397. /**
  61398. * Updates the current Plane from the plane defined by the three given points.
  61399. * @param point1 one of the points used to contruct the plane
  61400. * @param point2 one of the points used to contruct the plane
  61401. * @param point3 one of the points used to contruct the plane
  61402. * @returns the updated Plane.
  61403. */
  61404. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  61405. /**
  61406. * Checks if the plane is facing a given direction
  61407. * @param direction the direction to check if the plane is facing
  61408. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  61409. * @returns True is the vector "direction" is the same side than the plane normal.
  61410. */
  61411. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  61412. /**
  61413. * Calculates the distance to a point
  61414. * @param point point to calculate distance to
  61415. * @returns the signed distance (float) from the given point to the Plane.
  61416. */
  61417. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  61418. /**
  61419. * Creates a plane from an array
  61420. * @param array the array to create a plane from
  61421. * @returns a new Plane from the given array.
  61422. */
  61423. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  61424. /**
  61425. * Creates a plane from three points
  61426. * @param point1 point used to create the plane
  61427. * @param point2 point used to create the plane
  61428. * @param point3 point used to create the plane
  61429. * @returns a new Plane defined by the three given points.
  61430. */
  61431. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  61432. /**
  61433. * Creates a plane from an origin point and a normal
  61434. * @param origin origin of the plane to be constructed
  61435. * @param normal normal of the plane to be constructed
  61436. * @returns a new Plane the normal vector to this plane at the given origin point.
  61437. * Note : the vector "normal" is updated because normalized.
  61438. */
  61439. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  61440. /**
  61441. * Calculates the distance from a plane and a point
  61442. * @param origin origin of the plane to be constructed
  61443. * @param normal normal of the plane to be constructed
  61444. * @param point point to calculate distance to
  61445. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  61446. */
  61447. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  61448. }
  61449. /**
  61450. * Class used to represent a viewport on screen
  61451. */
  61452. export class Viewport {
  61453. /** viewport left coordinate */
  61454. x: number;
  61455. /** viewport top coordinate */
  61456. y: number;
  61457. /**viewport width */
  61458. width: number;
  61459. /** viewport height */
  61460. height: number;
  61461. /**
  61462. * Creates a Viewport object located at (x, y) and sized (width, height)
  61463. * @param x defines viewport left coordinate
  61464. * @param y defines viewport top coordinate
  61465. * @param width defines the viewport width
  61466. * @param height defines the viewport height
  61467. */
  61468. constructor(
  61469. /** viewport left coordinate */
  61470. x: number,
  61471. /** viewport top coordinate */
  61472. y: number,
  61473. /**viewport width */
  61474. width: number,
  61475. /** viewport height */
  61476. height: number);
  61477. /**
  61478. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  61479. * @param renderWidth defines the rendering width
  61480. * @param renderHeight defines the rendering height
  61481. * @returns a new Viewport
  61482. */
  61483. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  61484. /**
  61485. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  61486. * @param renderWidth defines the rendering width
  61487. * @param renderHeight defines the rendering height
  61488. * @param ref defines the target viewport
  61489. * @returns the current viewport
  61490. */
  61491. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  61492. /**
  61493. * Returns a new Viewport copied from the current one
  61494. * @returns a new Viewport
  61495. */
  61496. clone(): Viewport;
  61497. }
  61498. /**
  61499. * Reprasents a camera frustum
  61500. */
  61501. export class Frustum {
  61502. /**
  61503. * Gets the planes representing the frustum
  61504. * @param transform matrix to be applied to the returned planes
  61505. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  61506. */
  61507. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  61508. /**
  61509. * Gets the near frustum plane transformed by the transform matrix
  61510. * @param transform transformation matrix to be applied to the resulting frustum plane
  61511. * @param frustumPlane the resuling frustum plane
  61512. */
  61513. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61514. /**
  61515. * Gets the far frustum plane transformed by the transform matrix
  61516. * @param transform transformation matrix to be applied to the resulting frustum plane
  61517. * @param frustumPlane the resuling frustum plane
  61518. */
  61519. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61520. /**
  61521. * Gets the left frustum plane transformed by the transform matrix
  61522. * @param transform transformation matrix to be applied to the resulting frustum plane
  61523. * @param frustumPlane the resuling frustum plane
  61524. */
  61525. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61526. /**
  61527. * Gets the right frustum plane transformed by the transform matrix
  61528. * @param transform transformation matrix to be applied to the resulting frustum plane
  61529. * @param frustumPlane the resuling frustum plane
  61530. */
  61531. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61532. /**
  61533. * Gets the top frustum plane transformed by the transform matrix
  61534. * @param transform transformation matrix to be applied to the resulting frustum plane
  61535. * @param frustumPlane the resuling frustum plane
  61536. */
  61537. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61538. /**
  61539. * Gets the bottom frustum plane transformed by the transform matrix
  61540. * @param transform transformation matrix to be applied to the resulting frustum plane
  61541. * @param frustumPlane the resuling frustum plane
  61542. */
  61543. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61544. /**
  61545. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  61546. * @param transform transformation matrix to be applied to the resulting frustum planes
  61547. * @param frustumPlanes the resuling frustum planes
  61548. */
  61549. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  61550. }
  61551. /** Defines supported spaces */
  61552. export enum Space {
  61553. /** Local (object) space */
  61554. LOCAL = 0,
  61555. /** World space */
  61556. WORLD = 1,
  61557. /** Bone space */
  61558. BONE = 2
  61559. }
  61560. /** Defines the 3 main axes */
  61561. export class Axis {
  61562. /** X axis */
  61563. static X: Vector3;
  61564. /** Y axis */
  61565. static Y: Vector3;
  61566. /** Z axis */
  61567. static Z: Vector3;
  61568. }
  61569. /** Class used to represent a Bezier curve */
  61570. export class BezierCurve {
  61571. /**
  61572. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  61573. * @param t defines the time
  61574. * @param x1 defines the left coordinate on X axis
  61575. * @param y1 defines the left coordinate on Y axis
  61576. * @param x2 defines the right coordinate on X axis
  61577. * @param y2 defines the right coordinate on Y axis
  61578. * @returns the interpolated value
  61579. */
  61580. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  61581. }
  61582. /**
  61583. * Defines potential orientation for back face culling
  61584. */
  61585. export enum Orientation {
  61586. /**
  61587. * Clockwise
  61588. */
  61589. CW = 0,
  61590. /** Counter clockwise */
  61591. CCW = 1
  61592. }
  61593. /**
  61594. * Defines angle representation
  61595. */
  61596. export class Angle {
  61597. private _radians;
  61598. /**
  61599. * Creates an Angle object of "radians" radians (float).
  61600. * @param radians the angle in radians
  61601. */
  61602. constructor(radians: number);
  61603. /**
  61604. * Get value in degrees
  61605. * @returns the Angle value in degrees (float)
  61606. */
  61607. degrees(): number;
  61608. /**
  61609. * Get value in radians
  61610. * @returns the Angle value in radians (float)
  61611. */
  61612. radians(): number;
  61613. /**
  61614. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  61615. * @param a defines first vector
  61616. * @param b defines second vector
  61617. * @returns a new Angle
  61618. */
  61619. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  61620. /**
  61621. * Gets a new Angle object from the given float in radians
  61622. * @param radians defines the angle value in radians
  61623. * @returns a new Angle
  61624. */
  61625. static FromRadians(radians: number): Angle;
  61626. /**
  61627. * Gets a new Angle object from the given float in degrees
  61628. * @param degrees defines the angle value in degrees
  61629. * @returns a new Angle
  61630. */
  61631. static FromDegrees(degrees: number): Angle;
  61632. }
  61633. /**
  61634. * This represents an arc in a 2d space.
  61635. */
  61636. export class Arc2 {
  61637. /** Defines the start point of the arc */
  61638. startPoint: Vector2;
  61639. /** Defines the mid point of the arc */
  61640. midPoint: Vector2;
  61641. /** Defines the end point of the arc */
  61642. endPoint: Vector2;
  61643. /**
  61644. * Defines the center point of the arc.
  61645. */
  61646. centerPoint: Vector2;
  61647. /**
  61648. * Defines the radius of the arc.
  61649. */
  61650. radius: number;
  61651. /**
  61652. * Defines the angle of the arc (from mid point to end point).
  61653. */
  61654. angle: Angle;
  61655. /**
  61656. * Defines the start angle of the arc (from start point to middle point).
  61657. */
  61658. startAngle: Angle;
  61659. /**
  61660. * Defines the orientation of the arc (clock wise/counter clock wise).
  61661. */
  61662. orientation: Orientation;
  61663. /**
  61664. * Creates an Arc object from the three given points : start, middle and end.
  61665. * @param startPoint Defines the start point of the arc
  61666. * @param midPoint Defines the midlle point of the arc
  61667. * @param endPoint Defines the end point of the arc
  61668. */
  61669. constructor(
  61670. /** Defines the start point of the arc */
  61671. startPoint: Vector2,
  61672. /** Defines the mid point of the arc */
  61673. midPoint: Vector2,
  61674. /** Defines the end point of the arc */
  61675. endPoint: Vector2);
  61676. }
  61677. /**
  61678. * Represents a 2D path made up of multiple 2D points
  61679. */
  61680. export class Path2 {
  61681. private _points;
  61682. private _length;
  61683. /**
  61684. * If the path start and end point are the same
  61685. */
  61686. closed: boolean;
  61687. /**
  61688. * Creates a Path2 object from the starting 2D coordinates x and y.
  61689. * @param x the starting points x value
  61690. * @param y the starting points y value
  61691. */
  61692. constructor(x: number, y: number);
  61693. /**
  61694. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  61695. * @param x the added points x value
  61696. * @param y the added points y value
  61697. * @returns the updated Path2.
  61698. */
  61699. addLineTo(x: number, y: number): Path2;
  61700. /**
  61701. * 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.
  61702. * @param midX middle point x value
  61703. * @param midY middle point y value
  61704. * @param endX end point x value
  61705. * @param endY end point y value
  61706. * @param numberOfSegments (default: 36)
  61707. * @returns the updated Path2.
  61708. */
  61709. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  61710. /**
  61711. * Closes the Path2.
  61712. * @returns the Path2.
  61713. */
  61714. close(): Path2;
  61715. /**
  61716. * Gets the sum of the distance between each sequential point in the path
  61717. * @returns the Path2 total length (float).
  61718. */
  61719. length(): number;
  61720. /**
  61721. * Gets the points which construct the path
  61722. * @returns the Path2 internal array of points.
  61723. */
  61724. getPoints(): Vector2[];
  61725. /**
  61726. * Retreives the point at the distance aways from the starting point
  61727. * @param normalizedLengthPosition the length along the path to retreive the point from
  61728. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  61729. */
  61730. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  61731. /**
  61732. * Creates a new path starting from an x and y position
  61733. * @param x starting x value
  61734. * @param y starting y value
  61735. * @returns a new Path2 starting at the coordinates (x, y).
  61736. */
  61737. static StartingAt(x: number, y: number): Path2;
  61738. }
  61739. /**
  61740. * Represents a 3D path made up of multiple 3D points
  61741. */
  61742. export class Path3D {
  61743. /**
  61744. * an array of Vector3, the curve axis of the Path3D
  61745. */
  61746. path: Vector3[];
  61747. private _curve;
  61748. private _distances;
  61749. private _tangents;
  61750. private _normals;
  61751. private _binormals;
  61752. private _raw;
  61753. /**
  61754. * new Path3D(path, normal, raw)
  61755. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  61756. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  61757. * @param path an array of Vector3, the curve axis of the Path3D
  61758. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  61759. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  61760. */
  61761. constructor(
  61762. /**
  61763. * an array of Vector3, the curve axis of the Path3D
  61764. */
  61765. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  61766. /**
  61767. * Returns the Path3D array of successive Vector3 designing its curve.
  61768. * @returns the Path3D array of successive Vector3 designing its curve.
  61769. */
  61770. getCurve(): Vector3[];
  61771. /**
  61772. * Returns an array populated with tangent vectors on each Path3D curve point.
  61773. * @returns an array populated with tangent vectors on each Path3D curve point.
  61774. */
  61775. getTangents(): Vector3[];
  61776. /**
  61777. * Returns an array populated with normal vectors on each Path3D curve point.
  61778. * @returns an array populated with normal vectors on each Path3D curve point.
  61779. */
  61780. getNormals(): Vector3[];
  61781. /**
  61782. * Returns an array populated with binormal vectors on each Path3D curve point.
  61783. * @returns an array populated with binormal vectors on each Path3D curve point.
  61784. */
  61785. getBinormals(): Vector3[];
  61786. /**
  61787. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  61788. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  61789. */
  61790. getDistances(): number[];
  61791. /**
  61792. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  61793. * @param path path which all values are copied into the curves points
  61794. * @param firstNormal which should be projected onto the curve
  61795. * @returns the same object updated.
  61796. */
  61797. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  61798. private _compute;
  61799. private _getFirstNonNullVector;
  61800. private _getLastNonNullVector;
  61801. private _normalVector;
  61802. }
  61803. /**
  61804. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  61805. * A Curve3 is designed from a series of successive Vector3.
  61806. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  61807. */
  61808. export class Curve3 {
  61809. private _points;
  61810. private _length;
  61811. /**
  61812. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  61813. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  61814. * @param v1 (Vector3) the control point
  61815. * @param v2 (Vector3) the end point of the Quadratic Bezier
  61816. * @param nbPoints (integer) the wanted number of points in the curve
  61817. * @returns the created Curve3
  61818. */
  61819. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  61820. /**
  61821. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  61822. * @param v0 (Vector3) the origin point of the Cubic Bezier
  61823. * @param v1 (Vector3) the first control point
  61824. * @param v2 (Vector3) the second control point
  61825. * @param v3 (Vector3) the end point of the Cubic Bezier
  61826. * @param nbPoints (integer) the wanted number of points in the curve
  61827. * @returns the created Curve3
  61828. */
  61829. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  61830. /**
  61831. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  61832. * @param p1 (Vector3) the origin point of the Hermite Spline
  61833. * @param t1 (Vector3) the tangent vector at the origin point
  61834. * @param p2 (Vector3) the end point of the Hermite Spline
  61835. * @param t2 (Vector3) the tangent vector at the end point
  61836. * @param nbPoints (integer) the wanted number of points in the curve
  61837. * @returns the created Curve3
  61838. */
  61839. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  61840. /**
  61841. * Returns a Curve3 object along a CatmullRom Spline curve :
  61842. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  61843. * @param nbPoints (integer) the wanted number of points between each curve control points
  61844. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  61845. * @returns the created Curve3
  61846. */
  61847. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  61848. /**
  61849. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  61850. * A Curve3 is designed from a series of successive Vector3.
  61851. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  61852. * @param points points which make up the curve
  61853. */
  61854. constructor(points: Vector3[]);
  61855. /**
  61856. * @returns the Curve3 stored array of successive Vector3
  61857. */
  61858. getPoints(): Vector3[];
  61859. /**
  61860. * @returns the computed length (float) of the curve.
  61861. */
  61862. length(): number;
  61863. /**
  61864. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  61865. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  61866. * curveA and curveB keep unchanged.
  61867. * @param curve the curve to continue from this curve
  61868. * @returns the newly constructed curve
  61869. */
  61870. continue(curve: DeepImmutable<Curve3>): Curve3;
  61871. private _computeLength;
  61872. }
  61873. /**
  61874. * Contains position and normal vectors for a vertex
  61875. */
  61876. export class PositionNormalVertex {
  61877. /** the position of the vertex (defaut: 0,0,0) */
  61878. position: Vector3;
  61879. /** the normal of the vertex (defaut: 0,1,0) */
  61880. normal: Vector3;
  61881. /**
  61882. * Creates a PositionNormalVertex
  61883. * @param position the position of the vertex (defaut: 0,0,0)
  61884. * @param normal the normal of the vertex (defaut: 0,1,0)
  61885. */
  61886. constructor(
  61887. /** the position of the vertex (defaut: 0,0,0) */
  61888. position?: Vector3,
  61889. /** the normal of the vertex (defaut: 0,1,0) */
  61890. normal?: Vector3);
  61891. /**
  61892. * Clones the PositionNormalVertex
  61893. * @returns the cloned PositionNormalVertex
  61894. */
  61895. clone(): PositionNormalVertex;
  61896. }
  61897. /**
  61898. * Contains position, normal and uv vectors for a vertex
  61899. */
  61900. export class PositionNormalTextureVertex {
  61901. /** the position of the vertex (defaut: 0,0,0) */
  61902. position: Vector3;
  61903. /** the normal of the vertex (defaut: 0,1,0) */
  61904. normal: Vector3;
  61905. /** the uv of the vertex (default: 0,0) */
  61906. uv: Vector2;
  61907. /**
  61908. * Creates a PositionNormalTextureVertex
  61909. * @param position the position of the vertex (defaut: 0,0,0)
  61910. * @param normal the normal of the vertex (defaut: 0,1,0)
  61911. * @param uv the uv of the vertex (default: 0,0)
  61912. */
  61913. constructor(
  61914. /** the position of the vertex (defaut: 0,0,0) */
  61915. position?: Vector3,
  61916. /** the normal of the vertex (defaut: 0,1,0) */
  61917. normal?: Vector3,
  61918. /** the uv of the vertex (default: 0,0) */
  61919. uv?: Vector2);
  61920. /**
  61921. * Clones the PositionNormalTextureVertex
  61922. * @returns the cloned PositionNormalTextureVertex
  61923. */
  61924. clone(): PositionNormalTextureVertex;
  61925. }
  61926. /**
  61927. * @hidden
  61928. */
  61929. export class Tmp {
  61930. static Color3: Color3[];
  61931. static Color4: Color4[];
  61932. static Vector2: Vector2[];
  61933. static Vector3: Vector3[];
  61934. static Vector4: Vector4[];
  61935. static Quaternion: Quaternion[];
  61936. static Matrix: Matrix[];
  61937. }
  61938. }
  61939. declare module BABYLON {
  61940. /**
  61941. * Class used to enable access to offline support
  61942. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  61943. */
  61944. export interface IOfflineProvider {
  61945. /**
  61946. * Gets a boolean indicating if scene must be saved in the database
  61947. */
  61948. enableSceneOffline: boolean;
  61949. /**
  61950. * Gets a boolean indicating if textures must be saved in the database
  61951. */
  61952. enableTexturesOffline: boolean;
  61953. /**
  61954. * Open the offline support and make it available
  61955. * @param successCallback defines the callback to call on success
  61956. * @param errorCallback defines the callback to call on error
  61957. */
  61958. open(successCallback: () => void, errorCallback: () => void): void;
  61959. /**
  61960. * Loads an image from the offline support
  61961. * @param url defines the url to load from
  61962. * @param image defines the target DOM image
  61963. */
  61964. loadImage(url: string, image: HTMLImageElement): void;
  61965. /**
  61966. * Loads a file from offline support
  61967. * @param url defines the URL to load from
  61968. * @param sceneLoaded defines a callback to call on success
  61969. * @param progressCallBack defines a callback to call when progress changed
  61970. * @param errorCallback defines a callback to call on error
  61971. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  61972. */
  61973. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  61974. }
  61975. }
  61976. declare module BABYLON {
  61977. /**
  61978. * A class serves as a medium between the observable and its observers
  61979. */
  61980. export class EventState {
  61981. /**
  61982. * Create a new EventState
  61983. * @param mask defines the mask associated with this state
  61984. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  61985. * @param target defines the original target of the state
  61986. * @param currentTarget defines the current target of the state
  61987. */
  61988. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  61989. /**
  61990. * Initialize the current event state
  61991. * @param mask defines the mask associated with this state
  61992. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  61993. * @param target defines the original target of the state
  61994. * @param currentTarget defines the current target of the state
  61995. * @returns the current event state
  61996. */
  61997. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  61998. /**
  61999. * An Observer can set this property to true to prevent subsequent observers of being notified
  62000. */
  62001. skipNextObservers: boolean;
  62002. /**
  62003. * Get the mask value that were used to trigger the event corresponding to this EventState object
  62004. */
  62005. mask: number;
  62006. /**
  62007. * The object that originally notified the event
  62008. */
  62009. target?: any;
  62010. /**
  62011. * The current object in the bubbling phase
  62012. */
  62013. currentTarget?: any;
  62014. /**
  62015. * This will be populated with the return value of the last function that was executed.
  62016. * If it is the first function in the callback chain it will be the event data.
  62017. */
  62018. lastReturnValue?: any;
  62019. }
  62020. /**
  62021. * Represent an Observer registered to a given Observable object.
  62022. */
  62023. export class Observer<T> {
  62024. /**
  62025. * Defines the callback to call when the observer is notified
  62026. */
  62027. callback: (eventData: T, eventState: EventState) => void;
  62028. /**
  62029. * Defines the mask of the observer (used to filter notifications)
  62030. */
  62031. mask: number;
  62032. /**
  62033. * Defines the current scope used to restore the JS context
  62034. */
  62035. scope: any;
  62036. /** @hidden */
  62037. _willBeUnregistered: boolean;
  62038. /**
  62039. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  62040. */
  62041. unregisterOnNextCall: boolean;
  62042. /**
  62043. * Creates a new observer
  62044. * @param callback defines the callback to call when the observer is notified
  62045. * @param mask defines the mask of the observer (used to filter notifications)
  62046. * @param scope defines the current scope used to restore the JS context
  62047. */
  62048. constructor(
  62049. /**
  62050. * Defines the callback to call when the observer is notified
  62051. */
  62052. callback: (eventData: T, eventState: EventState) => void,
  62053. /**
  62054. * Defines the mask of the observer (used to filter notifications)
  62055. */
  62056. mask: number,
  62057. /**
  62058. * Defines the current scope used to restore the JS context
  62059. */
  62060. scope?: any);
  62061. }
  62062. /**
  62063. * Represent a list of observers registered to multiple Observables object.
  62064. */
  62065. export class MultiObserver<T> {
  62066. private _observers;
  62067. private _observables;
  62068. /**
  62069. * Release associated resources
  62070. */
  62071. dispose(): void;
  62072. /**
  62073. * Raise a callback when one of the observable will notify
  62074. * @param observables defines a list of observables to watch
  62075. * @param callback defines the callback to call on notification
  62076. * @param mask defines the mask used to filter notifications
  62077. * @param scope defines the current scope used to restore the JS context
  62078. * @returns the new MultiObserver
  62079. */
  62080. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  62081. }
  62082. /**
  62083. * The Observable class is a simple implementation of the Observable pattern.
  62084. *
  62085. * 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.
  62086. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  62087. * 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).
  62088. * 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.
  62089. */
  62090. export class Observable<T> {
  62091. private _observers;
  62092. private _eventState;
  62093. private _onObserverAdded;
  62094. /**
  62095. * Creates a new observable
  62096. * @param onObserverAdded defines a callback to call when a new observer is added
  62097. */
  62098. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  62099. /**
  62100. * Create a new Observer with the specified callback
  62101. * @param callback the callback that will be executed for that Observer
  62102. * @param mask the mask used to filter observers
  62103. * @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.
  62104. * @param scope optional scope for the callback to be called from
  62105. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  62106. * @returns the new observer created for the callback
  62107. */
  62108. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  62109. /**
  62110. * Create a new Observer with the specified callback and unregisters after the next notification
  62111. * @param callback the callback that will be executed for that Observer
  62112. * @returns the new observer created for the callback
  62113. */
  62114. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  62115. /**
  62116. * Remove an Observer from the Observable object
  62117. * @param observer the instance of the Observer to remove
  62118. * @returns false if it doesn't belong to this Observable
  62119. */
  62120. remove(observer: Nullable<Observer<T>>): boolean;
  62121. /**
  62122. * Remove a callback from the Observable object
  62123. * @param callback the callback to remove
  62124. * @param scope optional scope. If used only the callbacks with this scope will be removed
  62125. * @returns false if it doesn't belong to this Observable
  62126. */
  62127. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  62128. private _deferUnregister;
  62129. private _remove;
  62130. /**
  62131. * Notify all Observers by calling their respective callback with the given data
  62132. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  62133. * @param eventData defines the data to send to all observers
  62134. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  62135. * @param target defines the original target of the state
  62136. * @param currentTarget defines the current target of the state
  62137. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  62138. */
  62139. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  62140. /**
  62141. * Calling this will execute each callback, expecting it to be a promise or return a value.
  62142. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  62143. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  62144. * and it is crucial that all callbacks will be executed.
  62145. * The order of the callbacks is kept, callbacks are not executed parallel.
  62146. *
  62147. * @param eventData The data to be sent to each callback
  62148. * @param mask is used to filter observers defaults to -1
  62149. * @param target defines the callback target (see EventState)
  62150. * @param currentTarget defines he current object in the bubbling phase
  62151. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  62152. */
  62153. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  62154. /**
  62155. * Notify a specific observer
  62156. * @param observer defines the observer to notify
  62157. * @param eventData defines the data to be sent to each callback
  62158. * @param mask is used to filter observers defaults to -1
  62159. */
  62160. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  62161. /**
  62162. * Gets a boolean indicating if the observable has at least one observer
  62163. * @returns true is the Observable has at least one Observer registered
  62164. */
  62165. hasObservers(): boolean;
  62166. /**
  62167. * Clear the list of observers
  62168. */
  62169. clear(): void;
  62170. /**
  62171. * Clone the current observable
  62172. * @returns a new observable
  62173. */
  62174. clone(): Observable<T>;
  62175. /**
  62176. * Does this observable handles observer registered with a given mask
  62177. * @param mask defines the mask to be tested
  62178. * @return whether or not one observer registered with the given mask is handeled
  62179. **/
  62180. hasSpecificMask(mask?: number): boolean;
  62181. }
  62182. }
  62183. declare module BABYLON {
  62184. /**
  62185. * Class used to help managing file picking and drag'n'drop
  62186. * File Storage
  62187. */
  62188. export class FilesInputStore {
  62189. /**
  62190. * List of files ready to be loaded
  62191. */
  62192. static FilesToLoad: {
  62193. [key: string]: File;
  62194. };
  62195. }
  62196. }
  62197. declare module BABYLON {
  62198. /** Defines the cross module used constants to avoid circular dependncies */
  62199. export class Constants {
  62200. /** Defines that alpha blending is disabled */
  62201. static readonly ALPHA_DISABLE: number;
  62202. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  62203. static readonly ALPHA_ADD: number;
  62204. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  62205. static readonly ALPHA_COMBINE: number;
  62206. /** Defines that alpha blending to DEST - SRC * DEST */
  62207. static readonly ALPHA_SUBTRACT: number;
  62208. /** Defines that alpha blending to SRC * DEST */
  62209. static readonly ALPHA_MULTIPLY: number;
  62210. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  62211. static readonly ALPHA_MAXIMIZED: number;
  62212. /** Defines that alpha blending to SRC + DEST */
  62213. static readonly ALPHA_ONEONE: number;
  62214. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  62215. static readonly ALPHA_PREMULTIPLIED: number;
  62216. /**
  62217. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  62218. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  62219. */
  62220. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  62221. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  62222. static readonly ALPHA_INTERPOLATE: number;
  62223. /**
  62224. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  62225. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  62226. */
  62227. static readonly ALPHA_SCREENMODE: number;
  62228. /** Defines that the ressource is not delayed*/
  62229. static readonly DELAYLOADSTATE_NONE: number;
  62230. /** Defines that the ressource was successfully delay loaded */
  62231. static readonly DELAYLOADSTATE_LOADED: number;
  62232. /** Defines that the ressource is currently delay loading */
  62233. static readonly DELAYLOADSTATE_LOADING: number;
  62234. /** Defines that the ressource is delayed and has not started loading */
  62235. static readonly DELAYLOADSTATE_NOTLOADED: number;
  62236. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  62237. static readonly NEVER: number;
  62238. /** 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 */
  62239. static readonly ALWAYS: number;
  62240. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  62241. static readonly LESS: number;
  62242. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  62243. static readonly EQUAL: number;
  62244. /** 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 */
  62245. static readonly LEQUAL: number;
  62246. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  62247. static readonly GREATER: number;
  62248. /** 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 */
  62249. static readonly GEQUAL: number;
  62250. /** 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 */
  62251. static readonly NOTEQUAL: number;
  62252. /** Passed to stencilOperation to specify that stencil value must be kept */
  62253. static readonly KEEP: number;
  62254. /** Passed to stencilOperation to specify that stencil value must be replaced */
  62255. static readonly REPLACE: number;
  62256. /** Passed to stencilOperation to specify that stencil value must be incremented */
  62257. static readonly INCR: number;
  62258. /** Passed to stencilOperation to specify that stencil value must be decremented */
  62259. static readonly DECR: number;
  62260. /** Passed to stencilOperation to specify that stencil value must be inverted */
  62261. static readonly INVERT: number;
  62262. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  62263. static readonly INCR_WRAP: number;
  62264. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  62265. static readonly DECR_WRAP: number;
  62266. /** Texture is not repeating outside of 0..1 UVs */
  62267. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  62268. /** Texture is repeating outside of 0..1 UVs */
  62269. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  62270. /** Texture is repeating and mirrored */
  62271. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  62272. /** ALPHA */
  62273. static readonly TEXTUREFORMAT_ALPHA: number;
  62274. /** LUMINANCE */
  62275. static readonly TEXTUREFORMAT_LUMINANCE: number;
  62276. /** LUMINANCE_ALPHA */
  62277. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  62278. /** RGB */
  62279. static readonly TEXTUREFORMAT_RGB: number;
  62280. /** RGBA */
  62281. static readonly TEXTUREFORMAT_RGBA: number;
  62282. /** RED */
  62283. static readonly TEXTUREFORMAT_RED: number;
  62284. /** RED (2nd reference) */
  62285. static readonly TEXTUREFORMAT_R: number;
  62286. /** RG */
  62287. static readonly TEXTUREFORMAT_RG: number;
  62288. /** RED_INTEGER */
  62289. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  62290. /** RED_INTEGER (2nd reference) */
  62291. static readonly TEXTUREFORMAT_R_INTEGER: number;
  62292. /** RG_INTEGER */
  62293. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  62294. /** RGB_INTEGER */
  62295. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  62296. /** RGBA_INTEGER */
  62297. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  62298. /** UNSIGNED_BYTE */
  62299. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  62300. /** UNSIGNED_BYTE (2nd reference) */
  62301. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  62302. /** FLOAT */
  62303. static readonly TEXTURETYPE_FLOAT: number;
  62304. /** HALF_FLOAT */
  62305. static readonly TEXTURETYPE_HALF_FLOAT: number;
  62306. /** BYTE */
  62307. static readonly TEXTURETYPE_BYTE: number;
  62308. /** SHORT */
  62309. static readonly TEXTURETYPE_SHORT: number;
  62310. /** UNSIGNED_SHORT */
  62311. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  62312. /** INT */
  62313. static readonly TEXTURETYPE_INT: number;
  62314. /** UNSIGNED_INT */
  62315. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  62316. /** UNSIGNED_SHORT_4_4_4_4 */
  62317. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  62318. /** UNSIGNED_SHORT_5_5_5_1 */
  62319. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  62320. /** UNSIGNED_SHORT_5_6_5 */
  62321. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  62322. /** UNSIGNED_INT_2_10_10_10_REV */
  62323. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  62324. /** UNSIGNED_INT_24_8 */
  62325. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  62326. /** UNSIGNED_INT_10F_11F_11F_REV */
  62327. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  62328. /** UNSIGNED_INT_5_9_9_9_REV */
  62329. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  62330. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  62331. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  62332. /** nearest is mag = nearest and min = nearest and mip = linear */
  62333. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  62334. /** Bilinear is mag = linear and min = linear and mip = nearest */
  62335. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  62336. /** Trilinear is mag = linear and min = linear and mip = linear */
  62337. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  62338. /** nearest is mag = nearest and min = nearest and mip = linear */
  62339. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  62340. /** Bilinear is mag = linear and min = linear and mip = nearest */
  62341. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  62342. /** Trilinear is mag = linear and min = linear and mip = linear */
  62343. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  62344. /** mag = nearest and min = nearest and mip = nearest */
  62345. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  62346. /** mag = nearest and min = linear and mip = nearest */
  62347. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  62348. /** mag = nearest and min = linear and mip = linear */
  62349. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  62350. /** mag = nearest and min = linear and mip = none */
  62351. static readonly TEXTURE_NEAREST_LINEAR: number;
  62352. /** mag = nearest and min = nearest and mip = none */
  62353. static readonly TEXTURE_NEAREST_NEAREST: number;
  62354. /** mag = linear and min = nearest and mip = nearest */
  62355. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  62356. /** mag = linear and min = nearest and mip = linear */
  62357. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  62358. /** mag = linear and min = linear and mip = none */
  62359. static readonly TEXTURE_LINEAR_LINEAR: number;
  62360. /** mag = linear and min = nearest and mip = none */
  62361. static readonly TEXTURE_LINEAR_NEAREST: number;
  62362. /** Explicit coordinates mode */
  62363. static readonly TEXTURE_EXPLICIT_MODE: number;
  62364. /** Spherical coordinates mode */
  62365. static readonly TEXTURE_SPHERICAL_MODE: number;
  62366. /** Planar coordinates mode */
  62367. static readonly TEXTURE_PLANAR_MODE: number;
  62368. /** Cubic coordinates mode */
  62369. static readonly TEXTURE_CUBIC_MODE: number;
  62370. /** Projection coordinates mode */
  62371. static readonly TEXTURE_PROJECTION_MODE: number;
  62372. /** Skybox coordinates mode */
  62373. static readonly TEXTURE_SKYBOX_MODE: number;
  62374. /** Inverse Cubic coordinates mode */
  62375. static readonly TEXTURE_INVCUBIC_MODE: number;
  62376. /** Equirectangular coordinates mode */
  62377. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  62378. /** Equirectangular Fixed coordinates mode */
  62379. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  62380. /** Equirectangular Fixed Mirrored coordinates mode */
  62381. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  62382. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  62383. static readonly SCALEMODE_FLOOR: number;
  62384. /** Defines that texture rescaling will look for the nearest power of 2 size */
  62385. static readonly SCALEMODE_NEAREST: number;
  62386. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  62387. static readonly SCALEMODE_CEILING: number;
  62388. /**
  62389. * The dirty texture flag value
  62390. */
  62391. static readonly MATERIAL_TextureDirtyFlag: number;
  62392. /**
  62393. * The dirty light flag value
  62394. */
  62395. static readonly MATERIAL_LightDirtyFlag: number;
  62396. /**
  62397. * The dirty fresnel flag value
  62398. */
  62399. static readonly MATERIAL_FresnelDirtyFlag: number;
  62400. /**
  62401. * The dirty attribute flag value
  62402. */
  62403. static readonly MATERIAL_AttributesDirtyFlag: number;
  62404. /**
  62405. * The dirty misc flag value
  62406. */
  62407. static readonly MATERIAL_MiscDirtyFlag: number;
  62408. /**
  62409. * The all dirty flag value
  62410. */
  62411. static readonly MATERIAL_AllDirtyFlag: number;
  62412. /**
  62413. * Returns the triangle fill mode
  62414. */
  62415. static readonly MATERIAL_TriangleFillMode: number;
  62416. /**
  62417. * Returns the wireframe mode
  62418. */
  62419. static readonly MATERIAL_WireFrameFillMode: number;
  62420. /**
  62421. * Returns the point fill mode
  62422. */
  62423. static readonly MATERIAL_PointFillMode: number;
  62424. /**
  62425. * Returns the point list draw mode
  62426. */
  62427. static readonly MATERIAL_PointListDrawMode: number;
  62428. /**
  62429. * Returns the line list draw mode
  62430. */
  62431. static readonly MATERIAL_LineListDrawMode: number;
  62432. /**
  62433. * Returns the line loop draw mode
  62434. */
  62435. static readonly MATERIAL_LineLoopDrawMode: number;
  62436. /**
  62437. * Returns the line strip draw mode
  62438. */
  62439. static readonly MATERIAL_LineStripDrawMode: number;
  62440. /**
  62441. * Returns the triangle strip draw mode
  62442. */
  62443. static readonly MATERIAL_TriangleStripDrawMode: number;
  62444. /**
  62445. * Returns the triangle fan draw mode
  62446. */
  62447. static readonly MATERIAL_TriangleFanDrawMode: number;
  62448. /**
  62449. * Stores the clock-wise side orientation
  62450. */
  62451. static readonly MATERIAL_ClockWiseSideOrientation: number;
  62452. /**
  62453. * Stores the counter clock-wise side orientation
  62454. */
  62455. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  62456. /**
  62457. * Nothing
  62458. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62459. */
  62460. static readonly ACTION_NothingTrigger: number;
  62461. /**
  62462. * On pick
  62463. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62464. */
  62465. static readonly ACTION_OnPickTrigger: number;
  62466. /**
  62467. * On left pick
  62468. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62469. */
  62470. static readonly ACTION_OnLeftPickTrigger: number;
  62471. /**
  62472. * On right pick
  62473. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62474. */
  62475. static readonly ACTION_OnRightPickTrigger: number;
  62476. /**
  62477. * On center pick
  62478. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62479. */
  62480. static readonly ACTION_OnCenterPickTrigger: number;
  62481. /**
  62482. * On pick down
  62483. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62484. */
  62485. static readonly ACTION_OnPickDownTrigger: number;
  62486. /**
  62487. * On double pick
  62488. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62489. */
  62490. static readonly ACTION_OnDoublePickTrigger: number;
  62491. /**
  62492. * On pick up
  62493. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62494. */
  62495. static readonly ACTION_OnPickUpTrigger: number;
  62496. /**
  62497. * On pick out.
  62498. * This trigger will only be raised if you also declared a OnPickDown
  62499. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62500. */
  62501. static readonly ACTION_OnPickOutTrigger: number;
  62502. /**
  62503. * On long press
  62504. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62505. */
  62506. static readonly ACTION_OnLongPressTrigger: number;
  62507. /**
  62508. * On pointer over
  62509. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62510. */
  62511. static readonly ACTION_OnPointerOverTrigger: number;
  62512. /**
  62513. * On pointer out
  62514. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62515. */
  62516. static readonly ACTION_OnPointerOutTrigger: number;
  62517. /**
  62518. * On every frame
  62519. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62520. */
  62521. static readonly ACTION_OnEveryFrameTrigger: number;
  62522. /**
  62523. * On intersection enter
  62524. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62525. */
  62526. static readonly ACTION_OnIntersectionEnterTrigger: number;
  62527. /**
  62528. * On intersection exit
  62529. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62530. */
  62531. static readonly ACTION_OnIntersectionExitTrigger: number;
  62532. /**
  62533. * On key down
  62534. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62535. */
  62536. static readonly ACTION_OnKeyDownTrigger: number;
  62537. /**
  62538. * On key up
  62539. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62540. */
  62541. static readonly ACTION_OnKeyUpTrigger: number;
  62542. /**
  62543. * Billboard mode will only apply to Y axis
  62544. */
  62545. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  62546. /**
  62547. * Billboard mode will apply to all axes
  62548. */
  62549. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  62550. /**
  62551. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  62552. */
  62553. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  62554. /**
  62555. * Gets or sets base Assets URL
  62556. */
  62557. static readonly PARTICLES_BaseAssetsUrl: string;
  62558. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  62559. * Test order :
  62560. * Is the bounding sphere outside the frustum ?
  62561. * If not, are the bounding box vertices outside the frustum ?
  62562. * It not, then the cullable object is in the frustum.
  62563. */
  62564. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  62565. /** Culling strategy : Bounding Sphere Only.
  62566. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  62567. * It's also less accurate than the standard because some not visible objects can still be selected.
  62568. * Test : is the bounding sphere outside the frustum ?
  62569. * If not, then the cullable object is in the frustum.
  62570. */
  62571. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  62572. /** Culling strategy : Optimistic Inclusion.
  62573. * This in an inclusion test first, then the standard exclusion test.
  62574. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  62575. * 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.
  62576. * Anyway, it's as accurate as the standard strategy.
  62577. * Test :
  62578. * Is the cullable object bounding sphere center in the frustum ?
  62579. * If not, apply the default culling strategy.
  62580. */
  62581. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  62582. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  62583. * This in an inclusion test first, then the bounding sphere only exclusion test.
  62584. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  62585. * 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.
  62586. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  62587. * Test :
  62588. * Is the cullable object bounding sphere center in the frustum ?
  62589. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  62590. */
  62591. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  62592. /**
  62593. * No logging while loading
  62594. */
  62595. static readonly SCENELOADER_NO_LOGGING: number;
  62596. /**
  62597. * Minimal logging while loading
  62598. */
  62599. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  62600. /**
  62601. * Summary logging while loading
  62602. */
  62603. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  62604. /**
  62605. * Detailled logging while loading
  62606. */
  62607. static readonly SCENELOADER_DETAILED_LOGGING: number;
  62608. }
  62609. }
  62610. declare module BABYLON {
  62611. /**
  62612. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  62613. * Babylon.js
  62614. */
  62615. export class DomManagement {
  62616. /**
  62617. * Checks if the window object exists
  62618. * @returns true if the window object exists
  62619. */
  62620. static IsWindowObjectExist(): boolean;
  62621. /**
  62622. * Extracts text content from a DOM element hierarchy
  62623. * @param element defines the root element
  62624. * @returns a string
  62625. */
  62626. static GetDOMTextContent(element: HTMLElement): string;
  62627. }
  62628. }
  62629. declare module BABYLON {
  62630. /**
  62631. * Logger used througouht the application to allow configuration of
  62632. * the log level required for the messages.
  62633. */
  62634. export class Logger {
  62635. /**
  62636. * No log
  62637. */
  62638. static readonly NoneLogLevel: number;
  62639. /**
  62640. * Only message logs
  62641. */
  62642. static readonly MessageLogLevel: number;
  62643. /**
  62644. * Only warning logs
  62645. */
  62646. static readonly WarningLogLevel: number;
  62647. /**
  62648. * Only error logs
  62649. */
  62650. static readonly ErrorLogLevel: number;
  62651. /**
  62652. * All logs
  62653. */
  62654. static readonly AllLogLevel: number;
  62655. private static _LogCache;
  62656. /**
  62657. * Gets a value indicating the number of loading errors
  62658. * @ignorenaming
  62659. */
  62660. static errorsCount: number;
  62661. /**
  62662. * Callback called when a new log is added
  62663. */
  62664. static OnNewCacheEntry: (entry: string) => void;
  62665. private static _AddLogEntry;
  62666. private static _FormatMessage;
  62667. private static _LogDisabled;
  62668. private static _LogEnabled;
  62669. private static _WarnDisabled;
  62670. private static _WarnEnabled;
  62671. private static _ErrorDisabled;
  62672. private static _ErrorEnabled;
  62673. /**
  62674. * Log a message to the console
  62675. */
  62676. static Log: (message: string) => void;
  62677. /**
  62678. * Write a warning message to the console
  62679. */
  62680. static Warn: (message: string) => void;
  62681. /**
  62682. * Write an error message to the console
  62683. */
  62684. static Error: (message: string) => void;
  62685. /**
  62686. * Gets current log cache (list of logs)
  62687. */
  62688. static readonly LogCache: string;
  62689. /**
  62690. * Clears the log cache
  62691. */
  62692. static ClearLogCache(): void;
  62693. /**
  62694. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  62695. */
  62696. static LogLevels: number;
  62697. }
  62698. }
  62699. declare module BABYLON {
  62700. /** @hidden */
  62701. export class _TypeStore {
  62702. /** @hidden */
  62703. static RegisteredTypes: {
  62704. [key: string]: Object;
  62705. };
  62706. /** @hidden */
  62707. static GetClass(fqdn: string): any;
  62708. }
  62709. }
  62710. declare module BABYLON {
  62711. /**
  62712. * Class containing a set of static utilities functions for deep copy.
  62713. */
  62714. export class DeepCopier {
  62715. /**
  62716. * Tries to copy an object by duplicating every property
  62717. * @param source defines the source object
  62718. * @param destination defines the target object
  62719. * @param doNotCopyList defines a list of properties to avoid
  62720. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  62721. */
  62722. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  62723. }
  62724. }
  62725. declare module BABYLON {
  62726. /**
  62727. * Class containing a set of static utilities functions for precision date
  62728. */
  62729. export class PrecisionDate {
  62730. /**
  62731. * Gets either window.performance.now() if supported or Date.now() else
  62732. */
  62733. static readonly Now: number;
  62734. }
  62735. }
  62736. declare module BABYLON {
  62737. /** @hidden */
  62738. export class _DevTools {
  62739. static WarnImport(name: string): string;
  62740. }
  62741. }
  62742. declare module BABYLON {
  62743. /**
  62744. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  62745. */
  62746. export class WebRequest {
  62747. private _xhr;
  62748. /**
  62749. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  62750. * i.e. when loading files, where the server/service expects an Authorization header
  62751. */
  62752. static CustomRequestHeaders: {
  62753. [key: string]: string;
  62754. };
  62755. /**
  62756. * Add callback functions in this array to update all the requests before they get sent to the network
  62757. */
  62758. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  62759. private _injectCustomRequestHeaders;
  62760. /**
  62761. * Gets or sets a function to be called when loading progress changes
  62762. */
  62763. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  62764. /**
  62765. * Returns client's state
  62766. */
  62767. readonly readyState: number;
  62768. /**
  62769. * Returns client's status
  62770. */
  62771. readonly status: number;
  62772. /**
  62773. * Returns client's status as a text
  62774. */
  62775. readonly statusText: string;
  62776. /**
  62777. * Returns client's response
  62778. */
  62779. readonly response: any;
  62780. /**
  62781. * Returns client's response url
  62782. */
  62783. readonly responseURL: string;
  62784. /**
  62785. * Returns client's response as text
  62786. */
  62787. readonly responseText: string;
  62788. /**
  62789. * Gets or sets the expected response type
  62790. */
  62791. responseType: XMLHttpRequestResponseType;
  62792. /** @hidden */
  62793. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  62794. /** @hidden */
  62795. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  62796. /**
  62797. * Cancels any network activity
  62798. */
  62799. abort(): void;
  62800. /**
  62801. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  62802. * @param body defines an optional request body
  62803. */
  62804. send(body?: Document | BodyInit | null): void;
  62805. /**
  62806. * Sets the request method, request URL
  62807. * @param method defines the method to use (GET, POST, etc..)
  62808. * @param url defines the url to connect with
  62809. */
  62810. open(method: string, url: string): void;
  62811. }
  62812. }
  62813. declare module BABYLON {
  62814. /**
  62815. * Class used to evalaute queries containing `and` and `or` operators
  62816. */
  62817. export class AndOrNotEvaluator {
  62818. /**
  62819. * Evaluate a query
  62820. * @param query defines the query to evaluate
  62821. * @param evaluateCallback defines the callback used to filter result
  62822. * @returns true if the query matches
  62823. */
  62824. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  62825. private static _HandleParenthesisContent;
  62826. private static _SimplifyNegation;
  62827. }
  62828. }
  62829. declare module BABYLON {
  62830. /**
  62831. * Class used to store custom tags
  62832. */
  62833. export class Tags {
  62834. /**
  62835. * Adds support for tags on the given object
  62836. * @param obj defines the object to use
  62837. */
  62838. static EnableFor(obj: any): void;
  62839. /**
  62840. * Removes tags support
  62841. * @param obj defines the object to use
  62842. */
  62843. static DisableFor(obj: any): void;
  62844. /**
  62845. * Gets a boolean indicating if the given object has tags
  62846. * @param obj defines the object to use
  62847. * @returns a boolean
  62848. */
  62849. static HasTags(obj: any): boolean;
  62850. /**
  62851. * Gets the tags available on a given object
  62852. * @param obj defines the object to use
  62853. * @param asString defines if the tags must be returned as a string instead of an array of strings
  62854. * @returns the tags
  62855. */
  62856. static GetTags(obj: any, asString?: boolean): any;
  62857. /**
  62858. * Adds tags to an object
  62859. * @param obj defines the object to use
  62860. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  62861. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  62862. */
  62863. static AddTagsTo(obj: any, tagsString: string): void;
  62864. /**
  62865. * @hidden
  62866. */
  62867. static _AddTagTo(obj: any, tag: string): void;
  62868. /**
  62869. * Removes specific tags from a specific object
  62870. * @param obj defines the object to use
  62871. * @param tagsString defines the tags to remove
  62872. */
  62873. static RemoveTagsFrom(obj: any, tagsString: string): void;
  62874. /**
  62875. * @hidden
  62876. */
  62877. static _RemoveTagFrom(obj: any, tag: string): void;
  62878. /**
  62879. * Defines if tags hosted on an object match a given query
  62880. * @param obj defines the object to use
  62881. * @param tagsQuery defines the tag query
  62882. * @returns a boolean
  62883. */
  62884. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  62885. }
  62886. }
  62887. declare module BABYLON {
  62888. /**
  62889. * Manages the defines for the Material
  62890. */
  62891. export class MaterialDefines {
  62892. private _keys;
  62893. private _isDirty;
  62894. /** @hidden */
  62895. _renderId: number;
  62896. /** @hidden */
  62897. _areLightsDirty: boolean;
  62898. /** @hidden */
  62899. _areAttributesDirty: boolean;
  62900. /** @hidden */
  62901. _areTexturesDirty: boolean;
  62902. /** @hidden */
  62903. _areFresnelDirty: boolean;
  62904. /** @hidden */
  62905. _areMiscDirty: boolean;
  62906. /** @hidden */
  62907. _areImageProcessingDirty: boolean;
  62908. /** @hidden */
  62909. _normals: boolean;
  62910. /** @hidden */
  62911. _uvs: boolean;
  62912. /** @hidden */
  62913. _needNormals: boolean;
  62914. /** @hidden */
  62915. _needUVs: boolean;
  62916. /**
  62917. * Specifies if the material needs to be re-calculated
  62918. */
  62919. readonly isDirty: boolean;
  62920. /**
  62921. * Marks the material to indicate that it has been re-calculated
  62922. */
  62923. markAsProcessed(): void;
  62924. /**
  62925. * Marks the material to indicate that it needs to be re-calculated
  62926. */
  62927. markAsUnprocessed(): void;
  62928. /**
  62929. * Marks the material to indicate all of its defines need to be re-calculated
  62930. */
  62931. markAllAsDirty(): void;
  62932. /**
  62933. * Marks the material to indicate that image processing needs to be re-calculated
  62934. */
  62935. markAsImageProcessingDirty(): void;
  62936. /**
  62937. * Marks the material to indicate the lights need to be re-calculated
  62938. */
  62939. markAsLightDirty(): void;
  62940. /**
  62941. * Marks the attribute state as changed
  62942. */
  62943. markAsAttributesDirty(): void;
  62944. /**
  62945. * Marks the texture state as changed
  62946. */
  62947. markAsTexturesDirty(): void;
  62948. /**
  62949. * Marks the fresnel state as changed
  62950. */
  62951. markAsFresnelDirty(): void;
  62952. /**
  62953. * Marks the misc state as changed
  62954. */
  62955. markAsMiscDirty(): void;
  62956. /**
  62957. * Rebuilds the material defines
  62958. */
  62959. rebuild(): void;
  62960. /**
  62961. * Specifies if two material defines are equal
  62962. * @param other - A material define instance to compare to
  62963. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  62964. */
  62965. isEqual(other: MaterialDefines): boolean;
  62966. /**
  62967. * Clones this instance's defines to another instance
  62968. * @param other - material defines to clone values to
  62969. */
  62970. cloneTo(other: MaterialDefines): void;
  62971. /**
  62972. * Resets the material define values
  62973. */
  62974. reset(): void;
  62975. /**
  62976. * Converts the material define values to a string
  62977. * @returns - String of material define information
  62978. */
  62979. toString(): string;
  62980. }
  62981. }
  62982. declare module BABYLON {
  62983. /**
  62984. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  62985. */
  62986. export class PerformanceMonitor {
  62987. private _enabled;
  62988. private _rollingFrameTime;
  62989. private _lastFrameTimeMs;
  62990. /**
  62991. * constructor
  62992. * @param frameSampleSize The number of samples required to saturate the sliding window
  62993. */
  62994. constructor(frameSampleSize?: number);
  62995. /**
  62996. * Samples current frame
  62997. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  62998. */
  62999. sampleFrame(timeMs?: number): void;
  63000. /**
  63001. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  63002. */
  63003. readonly averageFrameTime: number;
  63004. /**
  63005. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  63006. */
  63007. readonly averageFrameTimeVariance: number;
  63008. /**
  63009. * Returns the frame time of the most recent frame
  63010. */
  63011. readonly instantaneousFrameTime: number;
  63012. /**
  63013. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  63014. */
  63015. readonly averageFPS: number;
  63016. /**
  63017. * Returns the average framerate in frames per second using the most recent frame time
  63018. */
  63019. readonly instantaneousFPS: number;
  63020. /**
  63021. * Returns true if enough samples have been taken to completely fill the sliding window
  63022. */
  63023. readonly isSaturated: boolean;
  63024. /**
  63025. * Enables contributions to the sliding window sample set
  63026. */
  63027. enable(): void;
  63028. /**
  63029. * Disables contributions to the sliding window sample set
  63030. * Samples will not be interpolated over the disabled period
  63031. */
  63032. disable(): void;
  63033. /**
  63034. * Returns true if sampling is enabled
  63035. */
  63036. readonly isEnabled: boolean;
  63037. /**
  63038. * Resets performance monitor
  63039. */
  63040. reset(): void;
  63041. }
  63042. /**
  63043. * RollingAverage
  63044. *
  63045. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  63046. */
  63047. export class RollingAverage {
  63048. /**
  63049. * Current average
  63050. */
  63051. average: number;
  63052. /**
  63053. * Current variance
  63054. */
  63055. variance: number;
  63056. protected _samples: Array<number>;
  63057. protected _sampleCount: number;
  63058. protected _pos: number;
  63059. protected _m2: number;
  63060. /**
  63061. * constructor
  63062. * @param length The number of samples required to saturate the sliding window
  63063. */
  63064. constructor(length: number);
  63065. /**
  63066. * Adds a sample to the sample set
  63067. * @param v The sample value
  63068. */
  63069. add(v: number): void;
  63070. /**
  63071. * Returns previously added values or null if outside of history or outside the sliding window domain
  63072. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  63073. * @return Value previously recorded with add() or null if outside of range
  63074. */
  63075. history(i: number): number;
  63076. /**
  63077. * Returns true if enough samples have been taken to completely fill the sliding window
  63078. * @return true if sample-set saturated
  63079. */
  63080. isSaturated(): boolean;
  63081. /**
  63082. * Resets the rolling average (equivalent to 0 samples taken so far)
  63083. */
  63084. reset(): void;
  63085. /**
  63086. * Wraps a value around the sample range boundaries
  63087. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  63088. * @return Wrapped position in sample range
  63089. */
  63090. protected _wrapPosition(i: number): number;
  63091. }
  63092. }
  63093. declare module BABYLON {
  63094. /**
  63095. * This class implement a typical dictionary using a string as key and the generic type T as value.
  63096. * The underlying implementation relies on an associative array to ensure the best performances.
  63097. * The value can be anything including 'null' but except 'undefined'
  63098. */
  63099. export class StringDictionary<T> {
  63100. /**
  63101. * This will clear this dictionary and copy the content from the 'source' one.
  63102. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  63103. * @param source the dictionary to take the content from and copy to this dictionary
  63104. */
  63105. copyFrom(source: StringDictionary<T>): void;
  63106. /**
  63107. * Get a value based from its key
  63108. * @param key the given key to get the matching value from
  63109. * @return the value if found, otherwise undefined is returned
  63110. */
  63111. get(key: string): T | undefined;
  63112. /**
  63113. * Get a value from its key or add it if it doesn't exist.
  63114. * This method will ensure you that a given key/data will be present in the dictionary.
  63115. * @param key the given key to get the matching value from
  63116. * @param factory the factory that will create the value if the key is not present in the dictionary.
  63117. * The factory will only be invoked if there's no data for the given key.
  63118. * @return the value corresponding to the key.
  63119. */
  63120. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  63121. /**
  63122. * Get a value from its key if present in the dictionary otherwise add it
  63123. * @param key the key to get the value from
  63124. * @param val if there's no such key/value pair in the dictionary add it with this value
  63125. * @return the value corresponding to the key
  63126. */
  63127. getOrAdd(key: string, val: T): T;
  63128. /**
  63129. * Check if there's a given key in the dictionary
  63130. * @param key the key to check for
  63131. * @return true if the key is present, false otherwise
  63132. */
  63133. contains(key: string): boolean;
  63134. /**
  63135. * Add a new key and its corresponding value
  63136. * @param key the key to add
  63137. * @param value the value corresponding to the key
  63138. * @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
  63139. */
  63140. add(key: string, value: T): boolean;
  63141. /**
  63142. * Update a specific value associated to a key
  63143. * @param key defines the key to use
  63144. * @param value defines the value to store
  63145. * @returns true if the value was updated (or false if the key was not found)
  63146. */
  63147. set(key: string, value: T): boolean;
  63148. /**
  63149. * Get the element of the given key and remove it from the dictionary
  63150. * @param key defines the key to search
  63151. * @returns the value associated with the key or null if not found
  63152. */
  63153. getAndRemove(key: string): Nullable<T>;
  63154. /**
  63155. * Remove a key/value from the dictionary.
  63156. * @param key the key to remove
  63157. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  63158. */
  63159. remove(key: string): boolean;
  63160. /**
  63161. * Clear the whole content of the dictionary
  63162. */
  63163. clear(): void;
  63164. /**
  63165. * Gets the current count
  63166. */
  63167. readonly count: number;
  63168. /**
  63169. * Execute a callback on each key/val of the dictionary.
  63170. * Note that you can remove any element in this dictionary in the callback implementation
  63171. * @param callback the callback to execute on a given key/value pair
  63172. */
  63173. forEach(callback: (key: string, val: T) => void): void;
  63174. /**
  63175. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  63176. * If the callback returns null or undefined the method will iterate to the next key/value pair
  63177. * Note that you can remove any element in this dictionary in the callback implementation
  63178. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  63179. * @returns the first item
  63180. */
  63181. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  63182. private _count;
  63183. private _data;
  63184. }
  63185. }
  63186. declare module BABYLON {
  63187. /**
  63188. * Helper class that provides a small promise polyfill
  63189. */
  63190. export class PromisePolyfill {
  63191. /**
  63192. * Static function used to check if the polyfill is required
  63193. * If this is the case then the function will inject the polyfill to window.Promise
  63194. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  63195. */
  63196. static Apply(force?: boolean): void;
  63197. }
  63198. }
  63199. declare module BABYLON {
  63200. /**
  63201. * Class used to store data that will be store in GPU memory
  63202. */
  63203. export class Buffer {
  63204. private _engine;
  63205. private _buffer;
  63206. /** @hidden */
  63207. _data: Nullable<DataArray>;
  63208. private _updatable;
  63209. private _instanced;
  63210. /**
  63211. * Gets the byte stride.
  63212. */
  63213. readonly byteStride: number;
  63214. /**
  63215. * Constructor
  63216. * @param engine the engine
  63217. * @param data the data to use for this buffer
  63218. * @param updatable whether the data is updatable
  63219. * @param stride the stride (optional)
  63220. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  63221. * @param instanced whether the buffer is instanced (optional)
  63222. * @param useBytes set to true if the stride in in bytes (optional)
  63223. */
  63224. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  63225. /**
  63226. * Create a new VertexBuffer based on the current buffer
  63227. * @param kind defines the vertex buffer kind (position, normal, etc.)
  63228. * @param offset defines offset in the buffer (0 by default)
  63229. * @param size defines the size in floats of attributes (position is 3 for instance)
  63230. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  63231. * @param instanced defines if the vertex buffer contains indexed data
  63232. * @param useBytes defines if the offset and stride are in bytes
  63233. * @returns the new vertex buffer
  63234. */
  63235. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  63236. /**
  63237. * Gets a boolean indicating if the Buffer is updatable?
  63238. * @returns true if the buffer is updatable
  63239. */
  63240. isUpdatable(): boolean;
  63241. /**
  63242. * Gets current buffer's data
  63243. * @returns a DataArray or null
  63244. */
  63245. getData(): Nullable<DataArray>;
  63246. /**
  63247. * Gets underlying native buffer
  63248. * @returns underlying native buffer
  63249. */
  63250. getBuffer(): Nullable<WebGLBuffer>;
  63251. /**
  63252. * Gets the stride in float32 units (i.e. byte stride / 4).
  63253. * May not be an integer if the byte stride is not divisible by 4.
  63254. * DEPRECATED. Use byteStride instead.
  63255. * @returns the stride in float32 units
  63256. */
  63257. getStrideSize(): number;
  63258. /**
  63259. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  63260. * @param data defines the data to store
  63261. */
  63262. create(data?: Nullable<DataArray>): void;
  63263. /** @hidden */
  63264. _rebuild(): void;
  63265. /**
  63266. * Update current buffer data
  63267. * @param data defines the data to store
  63268. */
  63269. update(data: DataArray): void;
  63270. /**
  63271. * Updates the data directly.
  63272. * @param data the new data
  63273. * @param offset the new offset
  63274. * @param vertexCount the vertex count (optional)
  63275. * @param useBytes set to true if the offset is in bytes
  63276. */
  63277. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  63278. /**
  63279. * Release all resources
  63280. */
  63281. dispose(): void;
  63282. }
  63283. /**
  63284. * Specialized buffer used to store vertex data
  63285. */
  63286. export class VertexBuffer {
  63287. /** @hidden */
  63288. _buffer: Buffer;
  63289. private _kind;
  63290. private _size;
  63291. private _ownsBuffer;
  63292. private _instanced;
  63293. private _instanceDivisor;
  63294. /**
  63295. * The byte type.
  63296. */
  63297. static readonly BYTE: number;
  63298. /**
  63299. * The unsigned byte type.
  63300. */
  63301. static readonly UNSIGNED_BYTE: number;
  63302. /**
  63303. * The short type.
  63304. */
  63305. static readonly SHORT: number;
  63306. /**
  63307. * The unsigned short type.
  63308. */
  63309. static readonly UNSIGNED_SHORT: number;
  63310. /**
  63311. * The integer type.
  63312. */
  63313. static readonly INT: number;
  63314. /**
  63315. * The unsigned integer type.
  63316. */
  63317. static readonly UNSIGNED_INT: number;
  63318. /**
  63319. * The float type.
  63320. */
  63321. static readonly FLOAT: number;
  63322. /**
  63323. * Gets or sets the instance divisor when in instanced mode
  63324. */
  63325. instanceDivisor: number;
  63326. /**
  63327. * Gets the byte stride.
  63328. */
  63329. readonly byteStride: number;
  63330. /**
  63331. * Gets the byte offset.
  63332. */
  63333. readonly byteOffset: number;
  63334. /**
  63335. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  63336. */
  63337. readonly normalized: boolean;
  63338. /**
  63339. * Gets the data type of each component in the array.
  63340. */
  63341. readonly type: number;
  63342. /**
  63343. * Constructor
  63344. * @param engine the engine
  63345. * @param data the data to use for this vertex buffer
  63346. * @param kind the vertex buffer kind
  63347. * @param updatable whether the data is updatable
  63348. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  63349. * @param stride the stride (optional)
  63350. * @param instanced whether the buffer is instanced (optional)
  63351. * @param offset the offset of the data (optional)
  63352. * @param size the number of components (optional)
  63353. * @param type the type of the component (optional)
  63354. * @param normalized whether the data contains normalized data (optional)
  63355. * @param useBytes set to true if stride and offset are in bytes (optional)
  63356. */
  63357. 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);
  63358. /** @hidden */
  63359. _rebuild(): void;
  63360. /**
  63361. * Returns the kind of the VertexBuffer (string)
  63362. * @returns a string
  63363. */
  63364. getKind(): string;
  63365. /**
  63366. * Gets a boolean indicating if the VertexBuffer is updatable?
  63367. * @returns true if the buffer is updatable
  63368. */
  63369. isUpdatable(): boolean;
  63370. /**
  63371. * Gets current buffer's data
  63372. * @returns a DataArray or null
  63373. */
  63374. getData(): Nullable<DataArray>;
  63375. /**
  63376. * Gets underlying native buffer
  63377. * @returns underlying native buffer
  63378. */
  63379. getBuffer(): Nullable<WebGLBuffer>;
  63380. /**
  63381. * Gets the stride in float32 units (i.e. byte stride / 4).
  63382. * May not be an integer if the byte stride is not divisible by 4.
  63383. * DEPRECATED. Use byteStride instead.
  63384. * @returns the stride in float32 units
  63385. */
  63386. getStrideSize(): number;
  63387. /**
  63388. * Returns the offset as a multiple of the type byte length.
  63389. * DEPRECATED. Use byteOffset instead.
  63390. * @returns the offset in bytes
  63391. */
  63392. getOffset(): number;
  63393. /**
  63394. * Returns the number of components per vertex attribute (integer)
  63395. * @returns the size in float
  63396. */
  63397. getSize(): number;
  63398. /**
  63399. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  63400. * @returns true if this buffer is instanced
  63401. */
  63402. getIsInstanced(): boolean;
  63403. /**
  63404. * Returns the instancing divisor, zero for non-instanced (integer).
  63405. * @returns a number
  63406. */
  63407. getInstanceDivisor(): number;
  63408. /**
  63409. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  63410. * @param data defines the data to store
  63411. */
  63412. create(data?: DataArray): void;
  63413. /**
  63414. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  63415. * This function will create a new buffer if the current one is not updatable
  63416. * @param data defines the data to store
  63417. */
  63418. update(data: DataArray): void;
  63419. /**
  63420. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  63421. * Returns the directly updated WebGLBuffer.
  63422. * @param data the new data
  63423. * @param offset the new offset
  63424. * @param useBytes set to true if the offset is in bytes
  63425. */
  63426. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  63427. /**
  63428. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  63429. */
  63430. dispose(): void;
  63431. /**
  63432. * Enumerates each value of this vertex buffer as numbers.
  63433. * @param count the number of values to enumerate
  63434. * @param callback the callback function called for each value
  63435. */
  63436. forEach(count: number, callback: (value: number, index: number) => void): void;
  63437. /**
  63438. * Positions
  63439. */
  63440. static readonly PositionKind: string;
  63441. /**
  63442. * Normals
  63443. */
  63444. static readonly NormalKind: string;
  63445. /**
  63446. * Tangents
  63447. */
  63448. static readonly TangentKind: string;
  63449. /**
  63450. * Texture coordinates
  63451. */
  63452. static readonly UVKind: string;
  63453. /**
  63454. * Texture coordinates 2
  63455. */
  63456. static readonly UV2Kind: string;
  63457. /**
  63458. * Texture coordinates 3
  63459. */
  63460. static readonly UV3Kind: string;
  63461. /**
  63462. * Texture coordinates 4
  63463. */
  63464. static readonly UV4Kind: string;
  63465. /**
  63466. * Texture coordinates 5
  63467. */
  63468. static readonly UV5Kind: string;
  63469. /**
  63470. * Texture coordinates 6
  63471. */
  63472. static readonly UV6Kind: string;
  63473. /**
  63474. * Colors
  63475. */
  63476. static readonly ColorKind: string;
  63477. /**
  63478. * Matrix indices (for bones)
  63479. */
  63480. static readonly MatricesIndicesKind: string;
  63481. /**
  63482. * Matrix weights (for bones)
  63483. */
  63484. static readonly MatricesWeightsKind: string;
  63485. /**
  63486. * Additional matrix indices (for bones)
  63487. */
  63488. static readonly MatricesIndicesExtraKind: string;
  63489. /**
  63490. * Additional matrix weights (for bones)
  63491. */
  63492. static readonly MatricesWeightsExtraKind: string;
  63493. /**
  63494. * Deduces the stride given a kind.
  63495. * @param kind The kind string to deduce
  63496. * @returns The deduced stride
  63497. */
  63498. static DeduceStride(kind: string): number;
  63499. /**
  63500. * Gets the byte length of the given type.
  63501. * @param type the type
  63502. * @returns the number of bytes
  63503. */
  63504. static GetTypeByteLength(type: number): number;
  63505. /**
  63506. * Enumerates each value of the given parameters as numbers.
  63507. * @param data the data to enumerate
  63508. * @param byteOffset the byte offset of the data
  63509. * @param byteStride the byte stride of the data
  63510. * @param componentCount the number of components per element
  63511. * @param componentType the type of the component
  63512. * @param count the total number of components
  63513. * @param normalized whether the data is normalized
  63514. * @param callback the callback function called for each value
  63515. */
  63516. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  63517. private static _GetFloatValue;
  63518. }
  63519. }
  63520. declare module BABYLON {
  63521. /**
  63522. * Class representing spherical polynomial coefficients to the 3rd degree
  63523. */
  63524. export class SphericalPolynomial {
  63525. /**
  63526. * The x coefficients of the spherical polynomial
  63527. */
  63528. x: Vector3;
  63529. /**
  63530. * The y coefficients of the spherical polynomial
  63531. */
  63532. y: Vector3;
  63533. /**
  63534. * The z coefficients of the spherical polynomial
  63535. */
  63536. z: Vector3;
  63537. /**
  63538. * The xx coefficients of the spherical polynomial
  63539. */
  63540. xx: Vector3;
  63541. /**
  63542. * The yy coefficients of the spherical polynomial
  63543. */
  63544. yy: Vector3;
  63545. /**
  63546. * The zz coefficients of the spherical polynomial
  63547. */
  63548. zz: Vector3;
  63549. /**
  63550. * The xy coefficients of the spherical polynomial
  63551. */
  63552. xy: Vector3;
  63553. /**
  63554. * The yz coefficients of the spherical polynomial
  63555. */
  63556. yz: Vector3;
  63557. /**
  63558. * The zx coefficients of the spherical polynomial
  63559. */
  63560. zx: Vector3;
  63561. /**
  63562. * Adds an ambient color to the spherical polynomial
  63563. * @param color the color to add
  63564. */
  63565. addAmbient(color: Color3): void;
  63566. /**
  63567. * Scales the spherical polynomial by the given amount
  63568. * @param scale the amount to scale
  63569. */
  63570. scale(scale: number): void;
  63571. /**
  63572. * Gets the spherical polynomial from harmonics
  63573. * @param harmonics the spherical harmonics
  63574. * @returns the spherical polynomial
  63575. */
  63576. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  63577. /**
  63578. * Constructs a spherical polynomial from an array.
  63579. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  63580. * @returns the spherical polynomial
  63581. */
  63582. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  63583. }
  63584. /**
  63585. * Class representing spherical harmonics coefficients to the 3rd degree
  63586. */
  63587. export class SphericalHarmonics {
  63588. /**
  63589. * The l0,0 coefficients of the spherical harmonics
  63590. */
  63591. l00: Vector3;
  63592. /**
  63593. * The l1,-1 coefficients of the spherical harmonics
  63594. */
  63595. l1_1: Vector3;
  63596. /**
  63597. * The l1,0 coefficients of the spherical harmonics
  63598. */
  63599. l10: Vector3;
  63600. /**
  63601. * The l1,1 coefficients of the spherical harmonics
  63602. */
  63603. l11: Vector3;
  63604. /**
  63605. * The l2,-2 coefficients of the spherical harmonics
  63606. */
  63607. l2_2: Vector3;
  63608. /**
  63609. * The l2,-1 coefficients of the spherical harmonics
  63610. */
  63611. l2_1: Vector3;
  63612. /**
  63613. * The l2,0 coefficients of the spherical harmonics
  63614. */
  63615. l20: Vector3;
  63616. /**
  63617. * The l2,1 coefficients of the spherical harmonics
  63618. */
  63619. l21: Vector3;
  63620. /**
  63621. * The l2,2 coefficients of the spherical harmonics
  63622. */
  63623. lL22: Vector3;
  63624. /**
  63625. * Adds a light to the spherical harmonics
  63626. * @param direction the direction of the light
  63627. * @param color the color of the light
  63628. * @param deltaSolidAngle the delta solid angle of the light
  63629. */
  63630. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  63631. /**
  63632. * Scales the spherical harmonics by the given amount
  63633. * @param scale the amount to scale
  63634. */
  63635. scale(scale: number): void;
  63636. /**
  63637. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  63638. *
  63639. * ```
  63640. * E_lm = A_l * L_lm
  63641. * ```
  63642. *
  63643. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  63644. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  63645. * the scaling factors are given in equation 9.
  63646. */
  63647. convertIncidentRadianceToIrradiance(): void;
  63648. /**
  63649. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  63650. *
  63651. * ```
  63652. * L = (1/pi) * E * rho
  63653. * ```
  63654. *
  63655. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  63656. */
  63657. convertIrradianceToLambertianRadiance(): void;
  63658. /**
  63659. * Gets the spherical harmonics from polynomial
  63660. * @param polynomial the spherical polynomial
  63661. * @returns the spherical harmonics
  63662. */
  63663. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  63664. /**
  63665. * Constructs a spherical harmonics from an array.
  63666. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  63667. * @returns the spherical harmonics
  63668. */
  63669. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  63670. }
  63671. }
  63672. declare module BABYLON {
  63673. /**
  63674. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  63675. */
  63676. export interface CubeMapInfo {
  63677. /**
  63678. * The pixel array for the front face.
  63679. * This is stored in format, left to right, up to down format.
  63680. */
  63681. front: Nullable<ArrayBufferView>;
  63682. /**
  63683. * The pixel array for the back face.
  63684. * This is stored in format, left to right, up to down format.
  63685. */
  63686. back: Nullable<ArrayBufferView>;
  63687. /**
  63688. * The pixel array for the left face.
  63689. * This is stored in format, left to right, up to down format.
  63690. */
  63691. left: Nullable<ArrayBufferView>;
  63692. /**
  63693. * The pixel array for the right face.
  63694. * This is stored in format, left to right, up to down format.
  63695. */
  63696. right: Nullable<ArrayBufferView>;
  63697. /**
  63698. * The pixel array for the up face.
  63699. * This is stored in format, left to right, up to down format.
  63700. */
  63701. up: Nullable<ArrayBufferView>;
  63702. /**
  63703. * The pixel array for the down face.
  63704. * This is stored in format, left to right, up to down format.
  63705. */
  63706. down: Nullable<ArrayBufferView>;
  63707. /**
  63708. * The size of the cubemap stored.
  63709. *
  63710. * Each faces will be size * size pixels.
  63711. */
  63712. size: number;
  63713. /**
  63714. * The format of the texture.
  63715. *
  63716. * RGBA, RGB.
  63717. */
  63718. format: number;
  63719. /**
  63720. * The type of the texture data.
  63721. *
  63722. * UNSIGNED_INT, FLOAT.
  63723. */
  63724. type: number;
  63725. /**
  63726. * Specifies whether the texture is in gamma space.
  63727. */
  63728. gammaSpace: boolean;
  63729. }
  63730. /**
  63731. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  63732. */
  63733. export class PanoramaToCubeMapTools {
  63734. private static FACE_FRONT;
  63735. private static FACE_BACK;
  63736. private static FACE_RIGHT;
  63737. private static FACE_LEFT;
  63738. private static FACE_DOWN;
  63739. private static FACE_UP;
  63740. /**
  63741. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  63742. *
  63743. * @param float32Array The source data.
  63744. * @param inputWidth The width of the input panorama.
  63745. * @param inputHeight The height of the input panorama.
  63746. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  63747. * @return The cubemap data
  63748. */
  63749. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  63750. private static CreateCubemapTexture;
  63751. private static CalcProjectionSpherical;
  63752. }
  63753. }
  63754. declare module BABYLON {
  63755. /**
  63756. * Helper class dealing with the extraction of spherical polynomial dataArray
  63757. * from a cube map.
  63758. */
  63759. export class CubeMapToSphericalPolynomialTools {
  63760. private static FileFaces;
  63761. /**
  63762. * Converts a texture to the according Spherical Polynomial data.
  63763. * This extracts the first 3 orders only as they are the only one used in the lighting.
  63764. *
  63765. * @param texture The texture to extract the information from.
  63766. * @return The Spherical Polynomial data.
  63767. */
  63768. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  63769. /**
  63770. * Converts a cubemap to the according Spherical Polynomial data.
  63771. * This extracts the first 3 orders only as they are the only one used in the lighting.
  63772. *
  63773. * @param cubeInfo The Cube map to extract the information from.
  63774. * @return The Spherical Polynomial data.
  63775. */
  63776. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  63777. }
  63778. }
  63779. declare module BABYLON {
  63780. /**
  63781. * The engine store class is responsible to hold all the instances of Engine and Scene created
  63782. * during the life time of the application.
  63783. */
  63784. export class EngineStore {
  63785. /** Gets the list of created engines */
  63786. static Instances: Engine[];
  63787. /**
  63788. * Gets the latest created engine
  63789. */
  63790. static readonly LastCreatedEngine: Nullable<Engine>;
  63791. /**
  63792. * Gets the latest created scene
  63793. */
  63794. static readonly LastCreatedScene: Nullable<Scene>;
  63795. }
  63796. }
  63797. declare module BABYLON {
  63798. /**
  63799. * Define options used to create a render target texture
  63800. */
  63801. export class RenderTargetCreationOptions {
  63802. /**
  63803. * Specifies is mipmaps must be generated
  63804. */
  63805. generateMipMaps?: boolean;
  63806. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  63807. generateDepthBuffer?: boolean;
  63808. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  63809. generateStencilBuffer?: boolean;
  63810. /** Defines texture type (int by default) */
  63811. type?: number;
  63812. /** Defines sampling mode (trilinear by default) */
  63813. samplingMode?: number;
  63814. /** Defines format (RGBA by default) */
  63815. format?: number;
  63816. }
  63817. }
  63818. declare module BABYLON {
  63819. /**
  63820. * @hidden
  63821. **/
  63822. export class _AlphaState {
  63823. private _isAlphaBlendDirty;
  63824. private _isBlendFunctionParametersDirty;
  63825. private _isBlendEquationParametersDirty;
  63826. private _isBlendConstantsDirty;
  63827. private _alphaBlend;
  63828. private _blendFunctionParameters;
  63829. private _blendEquationParameters;
  63830. private _blendConstants;
  63831. /**
  63832. * Initializes the state.
  63833. */
  63834. constructor();
  63835. readonly isDirty: boolean;
  63836. alphaBlend: boolean;
  63837. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  63838. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  63839. setAlphaEquationParameters(rgb: number, alpha: number): void;
  63840. reset(): void;
  63841. apply(gl: WebGLRenderingContext): void;
  63842. }
  63843. }
  63844. declare module BABYLON {
  63845. /**
  63846. * @hidden
  63847. **/
  63848. export class _DepthCullingState {
  63849. private _isDepthTestDirty;
  63850. private _isDepthMaskDirty;
  63851. private _isDepthFuncDirty;
  63852. private _isCullFaceDirty;
  63853. private _isCullDirty;
  63854. private _isZOffsetDirty;
  63855. private _isFrontFaceDirty;
  63856. private _depthTest;
  63857. private _depthMask;
  63858. private _depthFunc;
  63859. private _cull;
  63860. private _cullFace;
  63861. private _zOffset;
  63862. private _frontFace;
  63863. /**
  63864. * Initializes the state.
  63865. */
  63866. constructor();
  63867. readonly isDirty: boolean;
  63868. zOffset: number;
  63869. cullFace: Nullable<number>;
  63870. cull: Nullable<boolean>;
  63871. depthFunc: Nullable<number>;
  63872. depthMask: boolean;
  63873. depthTest: boolean;
  63874. frontFace: Nullable<number>;
  63875. reset(): void;
  63876. apply(gl: WebGLRenderingContext): void;
  63877. }
  63878. }
  63879. declare module BABYLON {
  63880. /**
  63881. * @hidden
  63882. **/
  63883. export class _StencilState {
  63884. /** 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 */
  63885. static readonly ALWAYS: number;
  63886. /** Passed to stencilOperation to specify that stencil value must be kept */
  63887. static readonly KEEP: number;
  63888. /** Passed to stencilOperation to specify that stencil value must be replaced */
  63889. static readonly REPLACE: number;
  63890. private _isStencilTestDirty;
  63891. private _isStencilMaskDirty;
  63892. private _isStencilFuncDirty;
  63893. private _isStencilOpDirty;
  63894. private _stencilTest;
  63895. private _stencilMask;
  63896. private _stencilFunc;
  63897. private _stencilFuncRef;
  63898. private _stencilFuncMask;
  63899. private _stencilOpStencilFail;
  63900. private _stencilOpDepthFail;
  63901. private _stencilOpStencilDepthPass;
  63902. readonly isDirty: boolean;
  63903. stencilFunc: number;
  63904. stencilFuncRef: number;
  63905. stencilFuncMask: number;
  63906. stencilOpStencilFail: number;
  63907. stencilOpDepthFail: number;
  63908. stencilOpStencilDepthPass: number;
  63909. stencilMask: number;
  63910. stencilTest: boolean;
  63911. constructor();
  63912. reset(): void;
  63913. apply(gl: WebGLRenderingContext): void;
  63914. }
  63915. }
  63916. declare module BABYLON {
  63917. /**
  63918. * @hidden
  63919. **/
  63920. export class _TimeToken {
  63921. _startTimeQuery: Nullable<WebGLQuery>;
  63922. _endTimeQuery: Nullable<WebGLQuery>;
  63923. _timeElapsedQuery: Nullable<WebGLQuery>;
  63924. _timeElapsedQueryEnded: boolean;
  63925. }
  63926. }
  63927. declare module BABYLON {
  63928. /**
  63929. * Internal interface used to track InternalTexture already bound to the GL context
  63930. */
  63931. export interface IInternalTextureTracker {
  63932. /**
  63933. * Gets or set the previous tracker in the list
  63934. */
  63935. previous: Nullable<IInternalTextureTracker>;
  63936. /**
  63937. * Gets or set the next tracker in the list
  63938. */
  63939. next: Nullable<IInternalTextureTracker>;
  63940. }
  63941. /**
  63942. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  63943. */
  63944. export class DummyInternalTextureTracker {
  63945. /**
  63946. * Gets or set the previous tracker in the list
  63947. */
  63948. previous: Nullable<IInternalTextureTracker>;
  63949. /**
  63950. * Gets or set the next tracker in the list
  63951. */
  63952. next: Nullable<IInternalTextureTracker>;
  63953. }
  63954. }
  63955. declare module BABYLON {
  63956. /**
  63957. * Class used to store data associated with WebGL texture data for the engine
  63958. * This class should not be used directly
  63959. */
  63960. export class InternalTexture implements IInternalTextureTracker {
  63961. /** hidden */
  63962. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  63963. /**
  63964. * The source of the texture data is unknown
  63965. */
  63966. static DATASOURCE_UNKNOWN: number;
  63967. /**
  63968. * Texture data comes from an URL
  63969. */
  63970. static DATASOURCE_URL: number;
  63971. /**
  63972. * Texture data is only used for temporary storage
  63973. */
  63974. static DATASOURCE_TEMP: number;
  63975. /**
  63976. * Texture data comes from raw data (ArrayBuffer)
  63977. */
  63978. static DATASOURCE_RAW: number;
  63979. /**
  63980. * Texture content is dynamic (video or dynamic texture)
  63981. */
  63982. static DATASOURCE_DYNAMIC: number;
  63983. /**
  63984. * Texture content is generated by rendering to it
  63985. */
  63986. static DATASOURCE_RENDERTARGET: number;
  63987. /**
  63988. * Texture content is part of a multi render target process
  63989. */
  63990. static DATASOURCE_MULTIRENDERTARGET: number;
  63991. /**
  63992. * Texture data comes from a cube data file
  63993. */
  63994. static DATASOURCE_CUBE: number;
  63995. /**
  63996. * Texture data comes from a raw cube data
  63997. */
  63998. static DATASOURCE_CUBERAW: number;
  63999. /**
  64000. * Texture data come from a prefiltered cube data file
  64001. */
  64002. static DATASOURCE_CUBEPREFILTERED: number;
  64003. /**
  64004. * Texture content is raw 3D data
  64005. */
  64006. static DATASOURCE_RAW3D: number;
  64007. /**
  64008. * Texture content is a depth texture
  64009. */
  64010. static DATASOURCE_DEPTHTEXTURE: number;
  64011. /**
  64012. * Texture data comes from a raw cube data encoded with RGBD
  64013. */
  64014. static DATASOURCE_CUBERAW_RGBD: number;
  64015. /**
  64016. * Defines if the texture is ready
  64017. */
  64018. isReady: boolean;
  64019. /**
  64020. * Defines if the texture is a cube texture
  64021. */
  64022. isCube: boolean;
  64023. /**
  64024. * Defines if the texture contains 3D data
  64025. */
  64026. is3D: boolean;
  64027. /**
  64028. * Gets the URL used to load this texture
  64029. */
  64030. url: string;
  64031. /**
  64032. * Gets the sampling mode of the texture
  64033. */
  64034. samplingMode: number;
  64035. /**
  64036. * Gets a boolean indicating if the texture needs mipmaps generation
  64037. */
  64038. generateMipMaps: boolean;
  64039. /**
  64040. * Gets the number of samples used by the texture (WebGL2+ only)
  64041. */
  64042. samples: number;
  64043. /**
  64044. * Gets the type of the texture (int, float...)
  64045. */
  64046. type: number;
  64047. /**
  64048. * Gets the format of the texture (RGB, RGBA...)
  64049. */
  64050. format: number;
  64051. /**
  64052. * Observable called when the texture is loaded
  64053. */
  64054. onLoadedObservable: Observable<InternalTexture>;
  64055. /**
  64056. * Gets the width of the texture
  64057. */
  64058. width: number;
  64059. /**
  64060. * Gets the height of the texture
  64061. */
  64062. height: number;
  64063. /**
  64064. * Gets the depth of the texture
  64065. */
  64066. depth: number;
  64067. /**
  64068. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  64069. */
  64070. baseWidth: number;
  64071. /**
  64072. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  64073. */
  64074. baseHeight: number;
  64075. /**
  64076. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  64077. */
  64078. baseDepth: number;
  64079. /**
  64080. * Gets a boolean indicating if the texture is inverted on Y axis
  64081. */
  64082. invertY: boolean;
  64083. /**
  64084. * Gets or set the previous tracker in the list
  64085. */
  64086. previous: Nullable<IInternalTextureTracker>;
  64087. /**
  64088. * Gets or set the next tracker in the list
  64089. */
  64090. next: Nullable<IInternalTextureTracker>;
  64091. /** @hidden */
  64092. _invertVScale: boolean;
  64093. /** @hidden */
  64094. _initialSlot: number;
  64095. /** @hidden */
  64096. _designatedSlot: number;
  64097. /** @hidden */
  64098. _dataSource: number;
  64099. /** @hidden */
  64100. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  64101. /** @hidden */
  64102. _bufferView: Nullable<ArrayBufferView>;
  64103. /** @hidden */
  64104. _bufferViewArray: Nullable<ArrayBufferView[]>;
  64105. /** @hidden */
  64106. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  64107. /** @hidden */
  64108. _size: number;
  64109. /** @hidden */
  64110. _extension: string;
  64111. /** @hidden */
  64112. _files: Nullable<string[]>;
  64113. /** @hidden */
  64114. _workingCanvas: HTMLCanvasElement;
  64115. /** @hidden */
  64116. _workingContext: CanvasRenderingContext2D;
  64117. /** @hidden */
  64118. _framebuffer: Nullable<WebGLFramebuffer>;
  64119. /** @hidden */
  64120. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  64121. /** @hidden */
  64122. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  64123. /** @hidden */
  64124. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  64125. /** @hidden */
  64126. _attachments: Nullable<number[]>;
  64127. /** @hidden */
  64128. _cachedCoordinatesMode: Nullable<number>;
  64129. /** @hidden */
  64130. _cachedWrapU: Nullable<number>;
  64131. /** @hidden */
  64132. _cachedWrapV: Nullable<number>;
  64133. /** @hidden */
  64134. _cachedWrapR: Nullable<number>;
  64135. /** @hidden */
  64136. _cachedAnisotropicFilteringLevel: Nullable<number>;
  64137. /** @hidden */
  64138. _isDisabled: boolean;
  64139. /** @hidden */
  64140. _compression: Nullable<string>;
  64141. /** @hidden */
  64142. _generateStencilBuffer: boolean;
  64143. /** @hidden */
  64144. _generateDepthBuffer: boolean;
  64145. /** @hidden */
  64146. _comparisonFunction: number;
  64147. /** @hidden */
  64148. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  64149. /** @hidden */
  64150. _lodGenerationScale: number;
  64151. /** @hidden */
  64152. _lodGenerationOffset: number;
  64153. /** @hidden */
  64154. _lodTextureHigh: BaseTexture;
  64155. /** @hidden */
  64156. _lodTextureMid: BaseTexture;
  64157. /** @hidden */
  64158. _lodTextureLow: BaseTexture;
  64159. /** @hidden */
  64160. _isRGBD: boolean;
  64161. /** @hidden */
  64162. _webGLTexture: Nullable<WebGLTexture>;
  64163. /** @hidden */
  64164. _references: number;
  64165. private _engine;
  64166. /**
  64167. * Gets the Engine the texture belongs to.
  64168. * @returns The babylon engine
  64169. */
  64170. getEngine(): Engine;
  64171. /**
  64172. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  64173. */
  64174. readonly dataSource: number;
  64175. /**
  64176. * Creates a new InternalTexture
  64177. * @param engine defines the engine to use
  64178. * @param dataSource defines the type of data that will be used
  64179. * @param delayAllocation if the texture allocation should be delayed (default: false)
  64180. */
  64181. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  64182. /**
  64183. * Increments the number of references (ie. the number of Texture that point to it)
  64184. */
  64185. incrementReferences(): void;
  64186. /**
  64187. * Change the size of the texture (not the size of the content)
  64188. * @param width defines the new width
  64189. * @param height defines the new height
  64190. * @param depth defines the new depth (1 by default)
  64191. */
  64192. updateSize(width: int, height: int, depth?: int): void;
  64193. /** @hidden */
  64194. _rebuild(): void;
  64195. /** @hidden */
  64196. _swapAndDie(target: InternalTexture): void;
  64197. /**
  64198. * Dispose the current allocated resources
  64199. */
  64200. dispose(): void;
  64201. }
  64202. }
  64203. declare module BABYLON {
  64204. /**
  64205. * This represents the main contract an easing function should follow.
  64206. * Easing functions are used throughout the animation system.
  64207. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64208. */
  64209. export interface IEasingFunction {
  64210. /**
  64211. * Given an input gradient between 0 and 1, this returns the corrseponding value
  64212. * of the easing function.
  64213. * The link below provides some of the most common examples of easing functions.
  64214. * @see https://easings.net/
  64215. * @param gradient Defines the value between 0 and 1 we want the easing value for
  64216. * @returns the corresponding value on the curve defined by the easing function
  64217. */
  64218. ease(gradient: number): number;
  64219. }
  64220. /**
  64221. * Base class used for every default easing function.
  64222. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64223. */
  64224. export class EasingFunction implements IEasingFunction {
  64225. /**
  64226. * Interpolation follows the mathematical formula associated with the easing function.
  64227. */
  64228. static readonly EASINGMODE_EASEIN: number;
  64229. /**
  64230. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  64231. */
  64232. static readonly EASINGMODE_EASEOUT: number;
  64233. /**
  64234. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  64235. */
  64236. static readonly EASINGMODE_EASEINOUT: number;
  64237. private _easingMode;
  64238. /**
  64239. * Sets the easing mode of the current function.
  64240. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  64241. */
  64242. setEasingMode(easingMode: number): void;
  64243. /**
  64244. * Gets the current easing mode.
  64245. * @returns the easing mode
  64246. */
  64247. getEasingMode(): number;
  64248. /**
  64249. * @hidden
  64250. */
  64251. easeInCore(gradient: number): number;
  64252. /**
  64253. * Given an input gradient between 0 and 1, this returns the corrseponding value
  64254. * of the easing function.
  64255. * @param gradient Defines the value between 0 and 1 we want the easing value for
  64256. * @returns the corresponding value on the curve defined by the easing function
  64257. */
  64258. ease(gradient: number): number;
  64259. }
  64260. /**
  64261. * Easing function with a circle shape (see link below).
  64262. * @see https://easings.net/#easeInCirc
  64263. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64264. */
  64265. export class CircleEase extends EasingFunction implements IEasingFunction {
  64266. /** @hidden */
  64267. easeInCore(gradient: number): number;
  64268. }
  64269. /**
  64270. * Easing function with a ease back shape (see link below).
  64271. * @see https://easings.net/#easeInBack
  64272. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64273. */
  64274. export class BackEase extends EasingFunction implements IEasingFunction {
  64275. /** Defines the amplitude of the function */
  64276. amplitude: number;
  64277. /**
  64278. * Instantiates a back ease easing
  64279. * @see https://easings.net/#easeInBack
  64280. * @param amplitude Defines the amplitude of the function
  64281. */
  64282. constructor(
  64283. /** Defines the amplitude of the function */
  64284. amplitude?: number);
  64285. /** @hidden */
  64286. easeInCore(gradient: number): number;
  64287. }
  64288. /**
  64289. * Easing function with a bouncing shape (see link below).
  64290. * @see https://easings.net/#easeInBounce
  64291. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64292. */
  64293. export class BounceEase extends EasingFunction implements IEasingFunction {
  64294. /** Defines the number of bounces */
  64295. bounces: number;
  64296. /** Defines the amplitude of the bounce */
  64297. bounciness: number;
  64298. /**
  64299. * Instantiates a bounce easing
  64300. * @see https://easings.net/#easeInBounce
  64301. * @param bounces Defines the number of bounces
  64302. * @param bounciness Defines the amplitude of the bounce
  64303. */
  64304. constructor(
  64305. /** Defines the number of bounces */
  64306. bounces?: number,
  64307. /** Defines the amplitude of the bounce */
  64308. bounciness?: number);
  64309. /** @hidden */
  64310. easeInCore(gradient: number): number;
  64311. }
  64312. /**
  64313. * Easing function with a power of 3 shape (see link below).
  64314. * @see https://easings.net/#easeInCubic
  64315. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64316. */
  64317. export class CubicEase extends EasingFunction implements IEasingFunction {
  64318. /** @hidden */
  64319. easeInCore(gradient: number): number;
  64320. }
  64321. /**
  64322. * Easing function with an elastic shape (see link below).
  64323. * @see https://easings.net/#easeInElastic
  64324. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64325. */
  64326. export class ElasticEase extends EasingFunction implements IEasingFunction {
  64327. /** Defines the number of oscillations*/
  64328. oscillations: number;
  64329. /** Defines the amplitude of the oscillations*/
  64330. springiness: number;
  64331. /**
  64332. * Instantiates an elastic easing function
  64333. * @see https://easings.net/#easeInElastic
  64334. * @param oscillations Defines the number of oscillations
  64335. * @param springiness Defines the amplitude of the oscillations
  64336. */
  64337. constructor(
  64338. /** Defines the number of oscillations*/
  64339. oscillations?: number,
  64340. /** Defines the amplitude of the oscillations*/
  64341. springiness?: number);
  64342. /** @hidden */
  64343. easeInCore(gradient: number): number;
  64344. }
  64345. /**
  64346. * Easing function with an exponential shape (see link below).
  64347. * @see https://easings.net/#easeInExpo
  64348. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64349. */
  64350. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  64351. /** Defines the exponent of the function */
  64352. exponent: number;
  64353. /**
  64354. * Instantiates an exponential easing function
  64355. * @see https://easings.net/#easeInExpo
  64356. * @param exponent Defines the exponent of the function
  64357. */
  64358. constructor(
  64359. /** Defines the exponent of the function */
  64360. exponent?: number);
  64361. /** @hidden */
  64362. easeInCore(gradient: number): number;
  64363. }
  64364. /**
  64365. * Easing function with a power shape (see link below).
  64366. * @see https://easings.net/#easeInQuad
  64367. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64368. */
  64369. export class PowerEase extends EasingFunction implements IEasingFunction {
  64370. /** Defines the power of the function */
  64371. power: number;
  64372. /**
  64373. * Instantiates an power base easing function
  64374. * @see https://easings.net/#easeInQuad
  64375. * @param power Defines the power of the function
  64376. */
  64377. constructor(
  64378. /** Defines the power of the function */
  64379. power?: number);
  64380. /** @hidden */
  64381. easeInCore(gradient: number): number;
  64382. }
  64383. /**
  64384. * Easing function with a power of 2 shape (see link below).
  64385. * @see https://easings.net/#easeInQuad
  64386. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64387. */
  64388. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  64389. /** @hidden */
  64390. easeInCore(gradient: number): number;
  64391. }
  64392. /**
  64393. * Easing function with a power of 4 shape (see link below).
  64394. * @see https://easings.net/#easeInQuart
  64395. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64396. */
  64397. export class QuarticEase extends EasingFunction implements IEasingFunction {
  64398. /** @hidden */
  64399. easeInCore(gradient: number): number;
  64400. }
  64401. /**
  64402. * Easing function with a power of 5 shape (see link below).
  64403. * @see https://easings.net/#easeInQuint
  64404. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64405. */
  64406. export class QuinticEase extends EasingFunction implements IEasingFunction {
  64407. /** @hidden */
  64408. easeInCore(gradient: number): number;
  64409. }
  64410. /**
  64411. * Easing function with a sin shape (see link below).
  64412. * @see https://easings.net/#easeInSine
  64413. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64414. */
  64415. export class SineEase extends EasingFunction implements IEasingFunction {
  64416. /** @hidden */
  64417. easeInCore(gradient: number): number;
  64418. }
  64419. /**
  64420. * Easing function with a bezier shape (see link below).
  64421. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  64422. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64423. */
  64424. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  64425. /** Defines the x component of the start tangent in the bezier curve */
  64426. x1: number;
  64427. /** Defines the y component of the start tangent in the bezier curve */
  64428. y1: number;
  64429. /** Defines the x component of the end tangent in the bezier curve */
  64430. x2: number;
  64431. /** Defines the y component of the end tangent in the bezier curve */
  64432. y2: number;
  64433. /**
  64434. * Instantiates a bezier function
  64435. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  64436. * @param x1 Defines the x component of the start tangent in the bezier curve
  64437. * @param y1 Defines the y component of the start tangent in the bezier curve
  64438. * @param x2 Defines the x component of the end tangent in the bezier curve
  64439. * @param y2 Defines the y component of the end tangent in the bezier curve
  64440. */
  64441. constructor(
  64442. /** Defines the x component of the start tangent in the bezier curve */
  64443. x1?: number,
  64444. /** Defines the y component of the start tangent in the bezier curve */
  64445. y1?: number,
  64446. /** Defines the x component of the end tangent in the bezier curve */
  64447. x2?: number,
  64448. /** Defines the y component of the end tangent in the bezier curve */
  64449. y2?: number);
  64450. /** @hidden */
  64451. easeInCore(gradient: number): number;
  64452. }
  64453. }
  64454. declare module BABYLON {
  64455. /**
  64456. * Defines an interface which represents an animation key frame
  64457. */
  64458. export interface IAnimationKey {
  64459. /**
  64460. * Frame of the key frame
  64461. */
  64462. frame: number;
  64463. /**
  64464. * Value at the specifies key frame
  64465. */
  64466. value: any;
  64467. /**
  64468. * The input tangent for the cubic hermite spline
  64469. */
  64470. inTangent?: any;
  64471. /**
  64472. * The output tangent for the cubic hermite spline
  64473. */
  64474. outTangent?: any;
  64475. /**
  64476. * The animation interpolation type
  64477. */
  64478. interpolation?: AnimationKeyInterpolation;
  64479. }
  64480. /**
  64481. * Enum for the animation key frame interpolation type
  64482. */
  64483. export enum AnimationKeyInterpolation {
  64484. /**
  64485. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  64486. */
  64487. STEP = 1
  64488. }
  64489. }
  64490. declare module BABYLON {
  64491. /**
  64492. * Represents the range of an animation
  64493. */
  64494. export class AnimationRange {
  64495. /**The name of the animation range**/
  64496. name: string;
  64497. /**The starting frame of the animation */
  64498. from: number;
  64499. /**The ending frame of the animation*/
  64500. to: number;
  64501. /**
  64502. * Initializes the range of an animation
  64503. * @param name The name of the animation range
  64504. * @param from The starting frame of the animation
  64505. * @param to The ending frame of the animation
  64506. */
  64507. constructor(
  64508. /**The name of the animation range**/
  64509. name: string,
  64510. /**The starting frame of the animation */
  64511. from: number,
  64512. /**The ending frame of the animation*/
  64513. to: number);
  64514. /**
  64515. * Makes a copy of the animation range
  64516. * @returns A copy of the animation range
  64517. */
  64518. clone(): AnimationRange;
  64519. }
  64520. }
  64521. declare module BABYLON {
  64522. /**
  64523. * Composed of a frame, and an action function
  64524. */
  64525. export class AnimationEvent {
  64526. /** The frame for which the event is triggered **/
  64527. frame: number;
  64528. /** The event to perform when triggered **/
  64529. action: (currentFrame: number) => void;
  64530. /** Specifies if the event should be triggered only once**/
  64531. onlyOnce?: boolean | undefined;
  64532. /**
  64533. * Specifies if the animation event is done
  64534. */
  64535. isDone: boolean;
  64536. /**
  64537. * Initializes the animation event
  64538. * @param frame The frame for which the event is triggered
  64539. * @param action The event to perform when triggered
  64540. * @param onlyOnce Specifies if the event should be triggered only once
  64541. */
  64542. constructor(
  64543. /** The frame for which the event is triggered **/
  64544. frame: number,
  64545. /** The event to perform when triggered **/
  64546. action: (currentFrame: number) => void,
  64547. /** Specifies if the event should be triggered only once**/
  64548. onlyOnce?: boolean | undefined);
  64549. /** @hidden */
  64550. _clone(): AnimationEvent;
  64551. }
  64552. }
  64553. declare module BABYLON {
  64554. /**
  64555. * Interface used to define a behavior
  64556. */
  64557. export interface Behavior<T> {
  64558. /** gets or sets behavior's name */
  64559. name: string;
  64560. /**
  64561. * Function called when the behavior needs to be initialized (after attaching it to a target)
  64562. */
  64563. init(): void;
  64564. /**
  64565. * Called when the behavior is attached to a target
  64566. * @param target defines the target where the behavior is attached to
  64567. */
  64568. attach(target: T): void;
  64569. /**
  64570. * Called when the behavior is detached from its target
  64571. */
  64572. detach(): void;
  64573. }
  64574. /**
  64575. * Interface implemented by classes supporting behaviors
  64576. */
  64577. export interface IBehaviorAware<T> {
  64578. /**
  64579. * Attach a behavior
  64580. * @param behavior defines the behavior to attach
  64581. * @returns the current host
  64582. */
  64583. addBehavior(behavior: Behavior<T>): T;
  64584. /**
  64585. * Remove a behavior from the current object
  64586. * @param behavior defines the behavior to detach
  64587. * @returns the current host
  64588. */
  64589. removeBehavior(behavior: Behavior<T>): T;
  64590. /**
  64591. * Gets a behavior using its name to search
  64592. * @param name defines the name to search
  64593. * @returns the behavior or null if not found
  64594. */
  64595. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  64596. }
  64597. }
  64598. declare module BABYLON {
  64599. /**
  64600. * @hidden
  64601. */
  64602. export class IntersectionInfo {
  64603. bu: Nullable<number>;
  64604. bv: Nullable<number>;
  64605. distance: number;
  64606. faceId: number;
  64607. subMeshId: number;
  64608. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  64609. }
  64610. }
  64611. declare module BABYLON {
  64612. /**
  64613. * Class used to store bounding sphere information
  64614. */
  64615. export class BoundingSphere {
  64616. /**
  64617. * Gets the center of the bounding sphere in local space
  64618. */
  64619. readonly center: Vector3;
  64620. /**
  64621. * Radius of the bounding sphere in local space
  64622. */
  64623. radius: number;
  64624. /**
  64625. * Gets the center of the bounding sphere in world space
  64626. */
  64627. readonly centerWorld: Vector3;
  64628. /**
  64629. * Radius of the bounding sphere in world space
  64630. */
  64631. radiusWorld: number;
  64632. /**
  64633. * Gets the minimum vector in local space
  64634. */
  64635. readonly minimum: Vector3;
  64636. /**
  64637. * Gets the maximum vector in local space
  64638. */
  64639. readonly maximum: Vector3;
  64640. private _worldMatrix;
  64641. private static readonly TmpVector3;
  64642. /**
  64643. * Creates a new bounding sphere
  64644. * @param min defines the minimum vector (in local space)
  64645. * @param max defines the maximum vector (in local space)
  64646. * @param worldMatrix defines the new world matrix
  64647. */
  64648. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  64649. /**
  64650. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  64651. * @param min defines the new minimum vector (in local space)
  64652. * @param max defines the new maximum vector (in local space)
  64653. * @param worldMatrix defines the new world matrix
  64654. */
  64655. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  64656. /**
  64657. * Scale the current bounding sphere by applying a scale factor
  64658. * @param factor defines the scale factor to apply
  64659. * @returns the current bounding box
  64660. */
  64661. scale(factor: number): BoundingSphere;
  64662. /**
  64663. * Gets the world matrix of the bounding box
  64664. * @returns a matrix
  64665. */
  64666. getWorldMatrix(): DeepImmutable<Matrix>;
  64667. /** @hidden */
  64668. _update(worldMatrix: DeepImmutable<Matrix>): void;
  64669. /**
  64670. * Tests if the bounding sphere is intersecting the frustum planes
  64671. * @param frustumPlanes defines the frustum planes to test
  64672. * @returns true if there is an intersection
  64673. */
  64674. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64675. /**
  64676. * Tests if the bounding sphere center is in between the frustum planes.
  64677. * Used for optimistic fast inclusion.
  64678. * @param frustumPlanes defines the frustum planes to test
  64679. * @returns true if the sphere center is in between the frustum planes
  64680. */
  64681. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64682. /**
  64683. * Tests if a point is inside the bounding sphere
  64684. * @param point defines the point to test
  64685. * @returns true if the point is inside the bounding sphere
  64686. */
  64687. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  64688. /**
  64689. * Checks if two sphere intersct
  64690. * @param sphere0 sphere 0
  64691. * @param sphere1 sphere 1
  64692. * @returns true if the speres intersect
  64693. */
  64694. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  64695. }
  64696. }
  64697. declare module BABYLON {
  64698. /**
  64699. * Class used to store bounding box information
  64700. */
  64701. export class BoundingBox implements ICullable {
  64702. /**
  64703. * Gets the 8 vectors representing the bounding box in local space
  64704. */
  64705. readonly vectors: Vector3[];
  64706. /**
  64707. * Gets the center of the bounding box in local space
  64708. */
  64709. readonly center: Vector3;
  64710. /**
  64711. * Gets the center of the bounding box in world space
  64712. */
  64713. readonly centerWorld: Vector3;
  64714. /**
  64715. * Gets the extend size in local space
  64716. */
  64717. readonly extendSize: Vector3;
  64718. /**
  64719. * Gets the extend size in world space
  64720. */
  64721. readonly extendSizeWorld: Vector3;
  64722. /**
  64723. * Gets the OBB (object bounding box) directions
  64724. */
  64725. readonly directions: Vector3[];
  64726. /**
  64727. * Gets the 8 vectors representing the bounding box in world space
  64728. */
  64729. readonly vectorsWorld: Vector3[];
  64730. /**
  64731. * Gets the minimum vector in world space
  64732. */
  64733. readonly minimumWorld: Vector3;
  64734. /**
  64735. * Gets the maximum vector in world space
  64736. */
  64737. readonly maximumWorld: Vector3;
  64738. /**
  64739. * Gets the minimum vector in local space
  64740. */
  64741. readonly minimum: Vector3;
  64742. /**
  64743. * Gets the maximum vector in local space
  64744. */
  64745. readonly maximum: Vector3;
  64746. private _worldMatrix;
  64747. private static readonly TmpVector3;
  64748. /**
  64749. * @hidden
  64750. */
  64751. _tag: number;
  64752. /**
  64753. * Creates a new bounding box
  64754. * @param min defines the minimum vector (in local space)
  64755. * @param max defines the maximum vector (in local space)
  64756. * @param worldMatrix defines the new world matrix
  64757. */
  64758. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  64759. /**
  64760. * Recreates the entire bounding box from scratch as if we call the constructor in place
  64761. * @param min defines the new minimum vector (in local space)
  64762. * @param max defines the new maximum vector (in local space)
  64763. * @param worldMatrix defines the new world matrix
  64764. */
  64765. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  64766. /**
  64767. * Scale the current bounding box by applying a scale factor
  64768. * @param factor defines the scale factor to apply
  64769. * @returns the current bounding box
  64770. */
  64771. scale(factor: number): BoundingBox;
  64772. /**
  64773. * Gets the world matrix of the bounding box
  64774. * @returns a matrix
  64775. */
  64776. getWorldMatrix(): DeepImmutable<Matrix>;
  64777. /** @hidden */
  64778. _update(world: DeepImmutable<Matrix>): void;
  64779. /**
  64780. * Tests if the bounding box is intersecting the frustum planes
  64781. * @param frustumPlanes defines the frustum planes to test
  64782. * @returns true if there is an intersection
  64783. */
  64784. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64785. /**
  64786. * Tests if the bounding box is entirely inside the frustum planes
  64787. * @param frustumPlanes defines the frustum planes to test
  64788. * @returns true if there is an inclusion
  64789. */
  64790. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64791. /**
  64792. * Tests if a point is inside the bounding box
  64793. * @param point defines the point to test
  64794. * @returns true if the point is inside the bounding box
  64795. */
  64796. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  64797. /**
  64798. * Tests if the bounding box intersects with a bounding sphere
  64799. * @param sphere defines the sphere to test
  64800. * @returns true if there is an intersection
  64801. */
  64802. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  64803. /**
  64804. * Tests if the bounding box intersects with a box defined by a min and max vectors
  64805. * @param min defines the min vector to use
  64806. * @param max defines the max vector to use
  64807. * @returns true if there is an intersection
  64808. */
  64809. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  64810. /**
  64811. * Tests if two bounding boxes are intersections
  64812. * @param box0 defines the first box to test
  64813. * @param box1 defines the second box to test
  64814. * @returns true if there is an intersection
  64815. */
  64816. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  64817. /**
  64818. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  64819. * @param minPoint defines the minimum vector of the bounding box
  64820. * @param maxPoint defines the maximum vector of the bounding box
  64821. * @param sphereCenter defines the sphere center
  64822. * @param sphereRadius defines the sphere radius
  64823. * @returns true if there is an intersection
  64824. */
  64825. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  64826. /**
  64827. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  64828. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  64829. * @param frustumPlanes defines the frustum planes to test
  64830. * @return true if there is an inclusion
  64831. */
  64832. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64833. /**
  64834. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  64835. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  64836. * @param frustumPlanes defines the frustum planes to test
  64837. * @return true if there is an intersection
  64838. */
  64839. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64840. }
  64841. }
  64842. declare module BABYLON {
  64843. /** @hidden */
  64844. export class Collider {
  64845. /** Define if a collision was found */
  64846. collisionFound: boolean;
  64847. /**
  64848. * Define last intersection point in local space
  64849. */
  64850. intersectionPoint: Vector3;
  64851. /**
  64852. * Define last collided mesh
  64853. */
  64854. collidedMesh: Nullable<AbstractMesh>;
  64855. private _collisionPoint;
  64856. private _planeIntersectionPoint;
  64857. private _tempVector;
  64858. private _tempVector2;
  64859. private _tempVector3;
  64860. private _tempVector4;
  64861. private _edge;
  64862. private _baseToVertex;
  64863. private _destinationPoint;
  64864. private _slidePlaneNormal;
  64865. private _displacementVector;
  64866. /** @hidden */
  64867. _radius: Vector3;
  64868. /** @hidden */
  64869. _retry: number;
  64870. private _velocity;
  64871. private _basePoint;
  64872. private _epsilon;
  64873. /** @hidden */
  64874. _velocityWorldLength: number;
  64875. /** @hidden */
  64876. _basePointWorld: Vector3;
  64877. private _velocityWorld;
  64878. private _normalizedVelocity;
  64879. /** @hidden */
  64880. _initialVelocity: Vector3;
  64881. /** @hidden */
  64882. _initialPosition: Vector3;
  64883. private _nearestDistance;
  64884. private _collisionMask;
  64885. collisionMask: number;
  64886. /**
  64887. * Gets the plane normal used to compute the sliding response (in local space)
  64888. */
  64889. readonly slidePlaneNormal: Vector3;
  64890. /** @hidden */
  64891. _initialize(source: Vector3, dir: Vector3, e: number): void;
  64892. /** @hidden */
  64893. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  64894. /** @hidden */
  64895. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  64896. /** @hidden */
  64897. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  64898. /** @hidden */
  64899. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  64900. /** @hidden */
  64901. _getResponse(pos: Vector3, vel: Vector3): void;
  64902. }
  64903. }
  64904. declare module BABYLON {
  64905. /**
  64906. * Interface for cullable objects
  64907. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  64908. */
  64909. export interface ICullable {
  64910. /**
  64911. * Checks if the object or part of the object is in the frustum
  64912. * @param frustumPlanes Camera near/planes
  64913. * @returns true if the object is in frustum otherwise false
  64914. */
  64915. isInFrustum(frustumPlanes: Plane[]): boolean;
  64916. /**
  64917. * Checks if a cullable object (mesh...) is in the camera frustum
  64918. * Unlike isInFrustum this cheks the full bounding box
  64919. * @param frustumPlanes Camera near/planes
  64920. * @returns true if the object is in frustum otherwise false
  64921. */
  64922. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  64923. }
  64924. /**
  64925. * Info for a bounding data of a mesh
  64926. */
  64927. export class BoundingInfo implements ICullable {
  64928. /**
  64929. * Bounding box for the mesh
  64930. */
  64931. readonly boundingBox: BoundingBox;
  64932. /**
  64933. * Bounding sphere for the mesh
  64934. */
  64935. readonly boundingSphere: BoundingSphere;
  64936. private _isLocked;
  64937. private static readonly TmpVector3;
  64938. /**
  64939. * Constructs bounding info
  64940. * @param minimum min vector of the bounding box/sphere
  64941. * @param maximum max vector of the bounding box/sphere
  64942. * @param worldMatrix defines the new world matrix
  64943. */
  64944. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  64945. /**
  64946. * Recreates the entire bounding info from scratch as if we call the constructor in place
  64947. * @param min defines the new minimum vector (in local space)
  64948. * @param max defines the new maximum vector (in local space)
  64949. * @param worldMatrix defines the new world matrix
  64950. */
  64951. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  64952. /**
  64953. * min vector of the bounding box/sphere
  64954. */
  64955. readonly minimum: Vector3;
  64956. /**
  64957. * max vector of the bounding box/sphere
  64958. */
  64959. readonly maximum: Vector3;
  64960. /**
  64961. * If the info is locked and won't be updated to avoid perf overhead
  64962. */
  64963. isLocked: boolean;
  64964. /**
  64965. * Updates the bounding sphere and box
  64966. * @param world world matrix to be used to update
  64967. */
  64968. update(world: DeepImmutable<Matrix>): void;
  64969. /**
  64970. * Recreate the bounding info to be centered around a specific point given a specific extend.
  64971. * @param center New center of the bounding info
  64972. * @param extend New extend of the bounding info
  64973. * @returns the current bounding info
  64974. */
  64975. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  64976. /**
  64977. * Scale the current bounding info by applying a scale factor
  64978. * @param factor defines the scale factor to apply
  64979. * @returns the current bounding info
  64980. */
  64981. scale(factor: number): BoundingInfo;
  64982. /**
  64983. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  64984. * @param frustumPlanes defines the frustum to test
  64985. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  64986. * @returns true if the bounding info is in the frustum planes
  64987. */
  64988. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  64989. /**
  64990. * Gets the world distance between the min and max points of the bounding box
  64991. */
  64992. readonly diagonalLength: number;
  64993. /**
  64994. * Checks if a cullable object (mesh...) is in the camera frustum
  64995. * Unlike isInFrustum this cheks the full bounding box
  64996. * @param frustumPlanes Camera near/planes
  64997. * @returns true if the object is in frustum otherwise false
  64998. */
  64999. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65000. /** @hidden */
  65001. _checkCollision(collider: Collider): boolean;
  65002. /**
  65003. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  65004. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  65005. * @param point the point to check intersection with
  65006. * @returns if the point intersects
  65007. */
  65008. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  65009. /**
  65010. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  65011. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  65012. * @param boundingInfo the bounding info to check intersection with
  65013. * @param precise if the intersection should be done using OBB
  65014. * @returns if the bounding info intersects
  65015. */
  65016. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  65017. }
  65018. }
  65019. declare module BABYLON {
  65020. /**
  65021. * Defines an array and its length.
  65022. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  65023. */
  65024. export interface ISmartArrayLike<T> {
  65025. /**
  65026. * The data of the array.
  65027. */
  65028. data: Array<T>;
  65029. /**
  65030. * The active length of the array.
  65031. */
  65032. length: number;
  65033. }
  65034. /**
  65035. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  65036. */
  65037. export class SmartArray<T> implements ISmartArrayLike<T> {
  65038. /**
  65039. * The full set of data from the array.
  65040. */
  65041. data: Array<T>;
  65042. /**
  65043. * The active length of the array.
  65044. */
  65045. length: number;
  65046. protected _id: number;
  65047. /**
  65048. * Instantiates a Smart Array.
  65049. * @param capacity defines the default capacity of the array.
  65050. */
  65051. constructor(capacity: number);
  65052. /**
  65053. * Pushes a value at the end of the active data.
  65054. * @param value defines the object to push in the array.
  65055. */
  65056. push(value: T): void;
  65057. /**
  65058. * Iterates over the active data and apply the lambda to them.
  65059. * @param func defines the action to apply on each value.
  65060. */
  65061. forEach(func: (content: T) => void): void;
  65062. /**
  65063. * Sorts the full sets of data.
  65064. * @param compareFn defines the comparison function to apply.
  65065. */
  65066. sort(compareFn: (a: T, b: T) => number): void;
  65067. /**
  65068. * Resets the active data to an empty array.
  65069. */
  65070. reset(): void;
  65071. /**
  65072. * Releases all the data from the array as well as the array.
  65073. */
  65074. dispose(): void;
  65075. /**
  65076. * Concats the active data with a given array.
  65077. * @param array defines the data to concatenate with.
  65078. */
  65079. concat(array: any): void;
  65080. /**
  65081. * Returns the position of a value in the active data.
  65082. * @param value defines the value to find the index for
  65083. * @returns the index if found in the active data otherwise -1
  65084. */
  65085. indexOf(value: T): number;
  65086. /**
  65087. * Returns whether an element is part of the active data.
  65088. * @param value defines the value to look for
  65089. * @returns true if found in the active data otherwise false
  65090. */
  65091. contains(value: T): boolean;
  65092. private static _GlobalId;
  65093. }
  65094. /**
  65095. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  65096. * The data in this array can only be present once
  65097. */
  65098. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  65099. private _duplicateId;
  65100. /**
  65101. * Pushes a value at the end of the active data.
  65102. * THIS DOES NOT PREVENT DUPPLICATE DATA
  65103. * @param value defines the object to push in the array.
  65104. */
  65105. push(value: T): void;
  65106. /**
  65107. * Pushes a value at the end of the active data.
  65108. * If the data is already present, it won t be added again
  65109. * @param value defines the object to push in the array.
  65110. * @returns true if added false if it was already present
  65111. */
  65112. pushNoDuplicate(value: T): boolean;
  65113. /**
  65114. * Resets the active data to an empty array.
  65115. */
  65116. reset(): void;
  65117. /**
  65118. * Concats the active data with a given array.
  65119. * This ensures no dupplicate will be present in the result.
  65120. * @param array defines the data to concatenate with.
  65121. */
  65122. concatWithNoDuplicate(array: any): void;
  65123. }
  65124. }
  65125. declare module BABYLON {
  65126. /**
  65127. * A multi-material is used to apply different materials to different parts of the same object without the need of
  65128. * separate meshes. This can be use to improve performances.
  65129. * @see http://doc.babylonjs.com/how_to/multi_materials
  65130. */
  65131. export class MultiMaterial extends Material {
  65132. private _subMaterials;
  65133. /**
  65134. * Gets or Sets the list of Materials used within the multi material.
  65135. * They need to be ordered according to the submeshes order in the associated mesh
  65136. */
  65137. subMaterials: Nullable<Material>[];
  65138. /**
  65139. * Function used to align with Node.getChildren()
  65140. * @returns the list of Materials used within the multi material
  65141. */
  65142. getChildren(): Nullable<Material>[];
  65143. /**
  65144. * Instantiates a new Multi Material
  65145. * A multi-material is used to apply different materials to different parts of the same object without the need of
  65146. * separate meshes. This can be use to improve performances.
  65147. * @see http://doc.babylonjs.com/how_to/multi_materials
  65148. * @param name Define the name in the scene
  65149. * @param scene Define the scene the material belongs to
  65150. */
  65151. constructor(name: string, scene: Scene);
  65152. private _hookArray;
  65153. /**
  65154. * Get one of the submaterial by its index in the submaterials array
  65155. * @param index The index to look the sub material at
  65156. * @returns The Material if the index has been defined
  65157. */
  65158. getSubMaterial(index: number): Nullable<Material>;
  65159. /**
  65160. * Get the list of active textures for the whole sub materials list.
  65161. * @returns All the textures that will be used during the rendering
  65162. */
  65163. getActiveTextures(): BaseTexture[];
  65164. /**
  65165. * Gets the current class name of the material e.g. "MultiMaterial"
  65166. * Mainly use in serialization.
  65167. * @returns the class name
  65168. */
  65169. getClassName(): string;
  65170. /**
  65171. * Checks if the material is ready to render the requested sub mesh
  65172. * @param mesh Define the mesh the submesh belongs to
  65173. * @param subMesh Define the sub mesh to look readyness for
  65174. * @param useInstances Define whether or not the material is used with instances
  65175. * @returns true if ready, otherwise false
  65176. */
  65177. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  65178. /**
  65179. * Clones the current material and its related sub materials
  65180. * @param name Define the name of the newly cloned material
  65181. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  65182. * @returns the cloned material
  65183. */
  65184. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  65185. /**
  65186. * Serializes the materials into a JSON representation.
  65187. * @returns the JSON representation
  65188. */
  65189. serialize(): any;
  65190. /**
  65191. * Dispose the material and release its associated resources
  65192. * @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)
  65193. * @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)
  65194. * @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)
  65195. */
  65196. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  65197. /**
  65198. * Creates a MultiMaterial from parsed MultiMaterial data.
  65199. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  65200. * @param scene defines the hosting scene
  65201. * @returns a new MultiMaterial
  65202. */
  65203. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  65204. }
  65205. }
  65206. declare module BABYLON {
  65207. /**
  65208. * Class used to represent data loading progression
  65209. */
  65210. export class SceneLoaderFlags {
  65211. private static _ForceFullSceneLoadingForIncremental;
  65212. private static _ShowLoadingScreen;
  65213. private static _CleanBoneMatrixWeights;
  65214. private static _loggingLevel;
  65215. /**
  65216. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  65217. */
  65218. static ForceFullSceneLoadingForIncremental: boolean;
  65219. /**
  65220. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  65221. */
  65222. static ShowLoadingScreen: boolean;
  65223. /**
  65224. * Defines the current logging level (while loading the scene)
  65225. * @ignorenaming
  65226. */
  65227. static loggingLevel: number;
  65228. /**
  65229. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  65230. */
  65231. static CleanBoneMatrixWeights: boolean;
  65232. }
  65233. }
  65234. declare module BABYLON {
  65235. /**
  65236. * 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.
  65237. * @see https://doc.babylonjs.com/how_to/transformnode
  65238. */
  65239. export class TransformNode extends Node {
  65240. /**
  65241. * Object will not rotate to face the camera
  65242. */
  65243. static BILLBOARDMODE_NONE: number;
  65244. /**
  65245. * Object will rotate to face the camera but only on the x axis
  65246. */
  65247. static BILLBOARDMODE_X: number;
  65248. /**
  65249. * Object will rotate to face the camera but only on the y axis
  65250. */
  65251. static BILLBOARDMODE_Y: number;
  65252. /**
  65253. * Object will rotate to face the camera but only on the z axis
  65254. */
  65255. static BILLBOARDMODE_Z: number;
  65256. /**
  65257. * Object will rotate to face the camera
  65258. */
  65259. static BILLBOARDMODE_ALL: number;
  65260. private _forward;
  65261. private _forwardInverted;
  65262. private _up;
  65263. private _right;
  65264. private _rightInverted;
  65265. private _position;
  65266. private _rotation;
  65267. private _rotationQuaternion;
  65268. protected _scaling: Vector3;
  65269. protected _isDirty: boolean;
  65270. private _transformToBoneReferal;
  65271. /**
  65272. * Set the billboard mode. Default is 0.
  65273. *
  65274. * | Value | Type | Description |
  65275. * | --- | --- | --- |
  65276. * | 0 | BILLBOARDMODE_NONE | |
  65277. * | 1 | BILLBOARDMODE_X | |
  65278. * | 2 | BILLBOARDMODE_Y | |
  65279. * | 4 | BILLBOARDMODE_Z | |
  65280. * | 7 | BILLBOARDMODE_ALL | |
  65281. *
  65282. */
  65283. billboardMode: number;
  65284. /**
  65285. * 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
  65286. */
  65287. scalingDeterminant: number;
  65288. /**
  65289. * Sets the distance of the object to max, often used by skybox
  65290. */
  65291. infiniteDistance: boolean;
  65292. /**
  65293. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  65294. * By default the system will update normals to compensate
  65295. */
  65296. ignoreNonUniformScaling: boolean;
  65297. /** @hidden */
  65298. _poseMatrix: Matrix;
  65299. /** @hidden */
  65300. _localMatrix: Matrix;
  65301. private _absolutePosition;
  65302. private _pivotMatrix;
  65303. private _pivotMatrixInverse;
  65304. protected _postMultiplyPivotMatrix: boolean;
  65305. private _tempMatrix;
  65306. private _tempMatrix2;
  65307. protected _isWorldMatrixFrozen: boolean;
  65308. /** @hidden */
  65309. _indexInSceneTransformNodesArray: number;
  65310. /**
  65311. * An event triggered after the world matrix is updated
  65312. */
  65313. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  65314. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  65315. /**
  65316. * Gets a string identifying the name of the class
  65317. * @returns "TransformNode" string
  65318. */
  65319. getClassName(): string;
  65320. /**
  65321. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  65322. */
  65323. position: Vector3;
  65324. /**
  65325. * 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)).
  65326. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  65327. */
  65328. rotation: Vector3;
  65329. /**
  65330. * 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)).
  65331. */
  65332. scaling: Vector3;
  65333. /**
  65334. * 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).
  65335. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  65336. */
  65337. rotationQuaternion: Nullable<Quaternion>;
  65338. /**
  65339. * The forward direction of that transform in world space.
  65340. */
  65341. readonly forward: Vector3;
  65342. /**
  65343. * The up direction of that transform in world space.
  65344. */
  65345. readonly up: Vector3;
  65346. /**
  65347. * The right direction of that transform in world space.
  65348. */
  65349. readonly right: Vector3;
  65350. /**
  65351. * Copies the parameter passed Matrix into the mesh Pose matrix.
  65352. * @param matrix the matrix to copy the pose from
  65353. * @returns this TransformNode.
  65354. */
  65355. updatePoseMatrix(matrix: Matrix): TransformNode;
  65356. /**
  65357. * Returns the mesh Pose matrix.
  65358. * @returns the pose matrix
  65359. */
  65360. getPoseMatrix(): Matrix;
  65361. /** @hidden */
  65362. _isSynchronized(): boolean;
  65363. /** @hidden */
  65364. _initCache(): void;
  65365. /**
  65366. * Flag the transform node as dirty (Forcing it to update everything)
  65367. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  65368. * @returns this transform node
  65369. */
  65370. markAsDirty(property: string): TransformNode;
  65371. /**
  65372. * Returns the current mesh absolute position.
  65373. * Returns a Vector3.
  65374. */
  65375. readonly absolutePosition: Vector3;
  65376. /**
  65377. * Sets a new matrix to apply before all other transformation
  65378. * @param matrix defines the transform matrix
  65379. * @returns the current TransformNode
  65380. */
  65381. setPreTransformMatrix(matrix: Matrix): TransformNode;
  65382. /**
  65383. * Sets a new pivot matrix to the current node
  65384. * @param matrix defines the new pivot matrix to use
  65385. * @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
  65386. * @returns the current TransformNode
  65387. */
  65388. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  65389. /**
  65390. * Returns the mesh pivot matrix.
  65391. * Default : Identity.
  65392. * @returns the matrix
  65393. */
  65394. getPivotMatrix(): Matrix;
  65395. /**
  65396. * Prevents the World matrix to be computed any longer.
  65397. * @returns the TransformNode.
  65398. */
  65399. freezeWorldMatrix(): TransformNode;
  65400. /**
  65401. * Allows back the World matrix computation.
  65402. * @returns the TransformNode.
  65403. */
  65404. unfreezeWorldMatrix(): this;
  65405. /**
  65406. * True if the World matrix has been frozen.
  65407. */
  65408. readonly isWorldMatrixFrozen: boolean;
  65409. /**
  65410. * Retuns the mesh absolute position in the World.
  65411. * @returns a Vector3.
  65412. */
  65413. getAbsolutePosition(): Vector3;
  65414. /**
  65415. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  65416. * @param absolutePosition the absolute position to set
  65417. * @returns the TransformNode.
  65418. */
  65419. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  65420. /**
  65421. * Sets the mesh position in its local space.
  65422. * @param vector3 the position to set in localspace
  65423. * @returns the TransformNode.
  65424. */
  65425. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  65426. /**
  65427. * Returns the mesh position in the local space from the current World matrix values.
  65428. * @returns a new Vector3.
  65429. */
  65430. getPositionExpressedInLocalSpace(): Vector3;
  65431. /**
  65432. * Translates the mesh along the passed Vector3 in its local space.
  65433. * @param vector3 the distance to translate in localspace
  65434. * @returns the TransformNode.
  65435. */
  65436. locallyTranslate(vector3: Vector3): TransformNode;
  65437. private static _lookAtVectorCache;
  65438. /**
  65439. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  65440. * @param targetPoint the position (must be in same space as current mesh) to look at
  65441. * @param yawCor optional yaw (y-axis) correction in radians
  65442. * @param pitchCor optional pitch (x-axis) correction in radians
  65443. * @param rollCor optional roll (z-axis) correction in radians
  65444. * @param space the choosen space of the target
  65445. * @returns the TransformNode.
  65446. */
  65447. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  65448. /**
  65449. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  65450. * This Vector3 is expressed in the World space.
  65451. * @param localAxis axis to rotate
  65452. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  65453. */
  65454. getDirection(localAxis: Vector3): Vector3;
  65455. /**
  65456. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  65457. * localAxis is expressed in the mesh local space.
  65458. * result is computed in the Wordl space from the mesh World matrix.
  65459. * @param localAxis axis to rotate
  65460. * @param result the resulting transformnode
  65461. * @returns this TransformNode.
  65462. */
  65463. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  65464. /**
  65465. * Sets this transform node rotation to the given local axis.
  65466. * @param localAxis the axis in local space
  65467. * @param yawCor optional yaw (y-axis) correction in radians
  65468. * @param pitchCor optional pitch (x-axis) correction in radians
  65469. * @param rollCor optional roll (z-axis) correction in radians
  65470. * @returns this TransformNode
  65471. */
  65472. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  65473. /**
  65474. * Sets a new pivot point to the current node
  65475. * @param point defines the new pivot point to use
  65476. * @param space defines if the point is in world or local space (local by default)
  65477. * @returns the current TransformNode
  65478. */
  65479. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  65480. /**
  65481. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  65482. * @returns the pivot point
  65483. */
  65484. getPivotPoint(): Vector3;
  65485. /**
  65486. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  65487. * @param result the vector3 to store the result
  65488. * @returns this TransformNode.
  65489. */
  65490. getPivotPointToRef(result: Vector3): TransformNode;
  65491. /**
  65492. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  65493. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  65494. */
  65495. getAbsolutePivotPoint(): Vector3;
  65496. /**
  65497. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  65498. * @param result vector3 to store the result
  65499. * @returns this TransformNode.
  65500. */
  65501. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  65502. /**
  65503. * Defines the passed node as the parent of the current node.
  65504. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  65505. * @param node the node ot set as the parent
  65506. * @returns this TransformNode.
  65507. */
  65508. setParent(node: Nullable<Node>): TransformNode;
  65509. private _nonUniformScaling;
  65510. /**
  65511. * True if the scaling property of this object is non uniform eg. (1,2,1)
  65512. */
  65513. readonly nonUniformScaling: boolean;
  65514. /** @hidden */
  65515. _updateNonUniformScalingState(value: boolean): boolean;
  65516. /**
  65517. * Attach the current TransformNode to another TransformNode associated with a bone
  65518. * @param bone Bone affecting the TransformNode
  65519. * @param affectedTransformNode TransformNode associated with the bone
  65520. * @returns this object
  65521. */
  65522. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  65523. /**
  65524. * Detach the transform node if its associated with a bone
  65525. * @returns this object
  65526. */
  65527. detachFromBone(): TransformNode;
  65528. private static _rotationAxisCache;
  65529. /**
  65530. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  65531. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  65532. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  65533. * The passed axis is also normalized.
  65534. * @param axis the axis to rotate around
  65535. * @param amount the amount to rotate in radians
  65536. * @param space Space to rotate in (Default: local)
  65537. * @returns the TransformNode.
  65538. */
  65539. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  65540. /**
  65541. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  65542. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  65543. * The passed axis is also normalized. .
  65544. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  65545. * @param point the point to rotate around
  65546. * @param axis the axis to rotate around
  65547. * @param amount the amount to rotate in radians
  65548. * @returns the TransformNode
  65549. */
  65550. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  65551. /**
  65552. * Translates the mesh along the axis vector for the passed distance in the given space.
  65553. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  65554. * @param axis the axis to translate in
  65555. * @param distance the distance to translate
  65556. * @param space Space to rotate in (Default: local)
  65557. * @returns the TransformNode.
  65558. */
  65559. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  65560. /**
  65561. * Adds a rotation step to the mesh current rotation.
  65562. * x, y, z are Euler angles expressed in radians.
  65563. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  65564. * This means this rotation is made in the mesh local space only.
  65565. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  65566. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  65567. * ```javascript
  65568. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  65569. * ```
  65570. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  65571. * 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.
  65572. * @param x Rotation to add
  65573. * @param y Rotation to add
  65574. * @param z Rotation to add
  65575. * @returns the TransformNode.
  65576. */
  65577. addRotation(x: number, y: number, z: number): TransformNode;
  65578. /**
  65579. * Computes the world matrix of the node
  65580. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  65581. * @returns the world matrix
  65582. */
  65583. computeWorldMatrix(force?: boolean): Matrix;
  65584. protected _afterComputeWorldMatrix(): void;
  65585. /**
  65586. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  65587. * @param func callback function to add
  65588. *
  65589. * @returns the TransformNode.
  65590. */
  65591. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  65592. /**
  65593. * Removes a registered callback function.
  65594. * @param func callback function to remove
  65595. * @returns the TransformNode.
  65596. */
  65597. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  65598. /**
  65599. * Gets the position of the current mesh in camera space
  65600. * @param camera defines the camera to use
  65601. * @returns a position
  65602. */
  65603. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  65604. /**
  65605. * Returns the distance from the mesh to the active camera
  65606. * @param camera defines the camera to use
  65607. * @returns the distance
  65608. */
  65609. getDistanceToCamera(camera?: Nullable<Camera>): number;
  65610. /**
  65611. * Clone the current transform node
  65612. * @param name Name of the new clone
  65613. * @param newParent New parent for the clone
  65614. * @param doNotCloneChildren Do not clone children hierarchy
  65615. * @returns the new transform node
  65616. */
  65617. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  65618. /**
  65619. * Serializes the objects information.
  65620. * @param currentSerializationObject defines the object to serialize in
  65621. * @returns the serialized object
  65622. */
  65623. serialize(currentSerializationObject?: any): any;
  65624. /**
  65625. * Returns a new TransformNode object parsed from the source provided.
  65626. * @param parsedTransformNode is the source.
  65627. * @param scene the scne the object belongs to
  65628. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  65629. * @returns a new TransformNode object parsed from the source provided.
  65630. */
  65631. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  65632. /**
  65633. * Get all child-transformNodes of this node
  65634. * @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
  65635. * @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
  65636. * @returns an array of TransformNode
  65637. */
  65638. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  65639. /**
  65640. * Releases resources associated with this transform node.
  65641. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  65642. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  65643. */
  65644. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  65645. }
  65646. }
  65647. declare module BABYLON {
  65648. /**
  65649. * Class used to override all child animations of a given target
  65650. */
  65651. export class AnimationPropertiesOverride {
  65652. /**
  65653. * Gets or sets a value indicating if animation blending must be used
  65654. */
  65655. enableBlending: boolean;
  65656. /**
  65657. * Gets or sets the blending speed to use when enableBlending is true
  65658. */
  65659. blendingSpeed: number;
  65660. /**
  65661. * Gets or sets the default loop mode to use
  65662. */
  65663. loopMode: number;
  65664. }
  65665. }
  65666. declare module BABYLON {
  65667. /**
  65668. * Class used to store bone information
  65669. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  65670. */
  65671. export class Bone extends Node {
  65672. /**
  65673. * defines the bone name
  65674. */
  65675. name: string;
  65676. private static _tmpVecs;
  65677. private static _tmpQuat;
  65678. private static _tmpMats;
  65679. /**
  65680. * Gets the list of child bones
  65681. */
  65682. children: Bone[];
  65683. /** Gets the animations associated with this bone */
  65684. animations: Animation[];
  65685. /**
  65686. * Gets or sets bone length
  65687. */
  65688. length: number;
  65689. /**
  65690. * @hidden Internal only
  65691. * Set this value to map this bone to a different index in the transform matrices
  65692. * Set this value to -1 to exclude the bone from the transform matrices
  65693. */
  65694. _index: Nullable<number>;
  65695. private _skeleton;
  65696. private _localMatrix;
  65697. private _restPose;
  65698. private _baseMatrix;
  65699. private _absoluteTransform;
  65700. private _invertedAbsoluteTransform;
  65701. private _parent;
  65702. private _scalingDeterminant;
  65703. private _worldTransform;
  65704. private _localScaling;
  65705. private _localRotation;
  65706. private _localPosition;
  65707. private _needToDecompose;
  65708. private _needToCompose;
  65709. /** @hidden */
  65710. _linkedTransformNode: Nullable<TransformNode>;
  65711. /** @hidden */
  65712. /** @hidden */
  65713. _matrix: Matrix;
  65714. /**
  65715. * Create a new bone
  65716. * @param name defines the bone name
  65717. * @param skeleton defines the parent skeleton
  65718. * @param parentBone defines the parent (can be null if the bone is the root)
  65719. * @param localMatrix defines the local matrix
  65720. * @param restPose defines the rest pose matrix
  65721. * @param baseMatrix defines the base matrix
  65722. * @param index defines index of the bone in the hiearchy
  65723. */
  65724. constructor(
  65725. /**
  65726. * defines the bone name
  65727. */
  65728. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  65729. /**
  65730. * Gets the current object class name.
  65731. * @return the class name
  65732. */
  65733. getClassName(): string;
  65734. /**
  65735. * Gets the parent skeleton
  65736. * @returns a skeleton
  65737. */
  65738. getSkeleton(): Skeleton;
  65739. /**
  65740. * Gets parent bone
  65741. * @returns a bone or null if the bone is the root of the bone hierarchy
  65742. */
  65743. getParent(): Nullable<Bone>;
  65744. /**
  65745. * Returns an array containing the root bones
  65746. * @returns an array containing the root bones
  65747. */
  65748. getChildren(): Array<Bone>;
  65749. /**
  65750. * Sets the parent bone
  65751. * @param parent defines the parent (can be null if the bone is the root)
  65752. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  65753. */
  65754. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  65755. /**
  65756. * Gets the local matrix
  65757. * @returns a matrix
  65758. */
  65759. getLocalMatrix(): Matrix;
  65760. /**
  65761. * Gets the base matrix (initial matrix which remains unchanged)
  65762. * @returns a matrix
  65763. */
  65764. getBaseMatrix(): Matrix;
  65765. /**
  65766. * Gets the rest pose matrix
  65767. * @returns a matrix
  65768. */
  65769. getRestPose(): Matrix;
  65770. /**
  65771. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  65772. */
  65773. getWorldMatrix(): Matrix;
  65774. /**
  65775. * Sets the local matrix to rest pose matrix
  65776. */
  65777. returnToRest(): void;
  65778. /**
  65779. * Gets the inverse of the absolute transform matrix.
  65780. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  65781. * @returns a matrix
  65782. */
  65783. getInvertedAbsoluteTransform(): Matrix;
  65784. /**
  65785. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  65786. * @returns a matrix
  65787. */
  65788. getAbsoluteTransform(): Matrix;
  65789. /**
  65790. * Links with the given transform node.
  65791. * The local matrix of this bone is copied from the transform node every frame.
  65792. * @param transformNode defines the transform node to link to
  65793. */
  65794. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  65795. /** Gets or sets current position (in local space) */
  65796. position: Vector3;
  65797. /** Gets or sets current rotation (in local space) */
  65798. rotation: Vector3;
  65799. /** Gets or sets current rotation quaternion (in local space) */
  65800. rotationQuaternion: Quaternion;
  65801. /** Gets or sets current scaling (in local space) */
  65802. scaling: Vector3;
  65803. /**
  65804. * Gets the animation properties override
  65805. */
  65806. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  65807. private _decompose;
  65808. private _compose;
  65809. /**
  65810. * Update the base and local matrices
  65811. * @param matrix defines the new base or local matrix
  65812. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  65813. * @param updateLocalMatrix defines if the local matrix should be updated
  65814. */
  65815. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  65816. /** @hidden */
  65817. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  65818. /**
  65819. * Flag the bone as dirty (Forcing it to update everything)
  65820. */
  65821. markAsDirty(): void;
  65822. private _markAsDirtyAndCompose;
  65823. private _markAsDirtyAndDecompose;
  65824. /**
  65825. * Translate the bone in local or world space
  65826. * @param vec The amount to translate the bone
  65827. * @param space The space that the translation is in
  65828. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65829. */
  65830. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  65831. /**
  65832. * Set the postion of the bone in local or world space
  65833. * @param position The position to set the bone
  65834. * @param space The space that the position is in
  65835. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65836. */
  65837. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  65838. /**
  65839. * Set the absolute position of the bone (world space)
  65840. * @param position The position to set the bone
  65841. * @param mesh The mesh that this bone is attached to
  65842. */
  65843. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  65844. /**
  65845. * Scale the bone on the x, y and z axes (in local space)
  65846. * @param x The amount to scale the bone on the x axis
  65847. * @param y The amount to scale the bone on the y axis
  65848. * @param z The amount to scale the bone on the z axis
  65849. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  65850. */
  65851. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  65852. /**
  65853. * Set the bone scaling in local space
  65854. * @param scale defines the scaling vector
  65855. */
  65856. setScale(scale: Vector3): void;
  65857. /**
  65858. * Gets the current scaling in local space
  65859. * @returns the current scaling vector
  65860. */
  65861. getScale(): Vector3;
  65862. /**
  65863. * Gets the current scaling in local space and stores it in a target vector
  65864. * @param result defines the target vector
  65865. */
  65866. getScaleToRef(result: Vector3): void;
  65867. /**
  65868. * Set the yaw, pitch, and roll of the bone in local or world space
  65869. * @param yaw The rotation of the bone on the y axis
  65870. * @param pitch The rotation of the bone on the x axis
  65871. * @param roll The rotation of the bone on the z axis
  65872. * @param space The space that the axes of rotation are in
  65873. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65874. */
  65875. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  65876. /**
  65877. * Add a rotation to the bone on an axis in local or world space
  65878. * @param axis The axis to rotate the bone on
  65879. * @param amount The amount to rotate the bone
  65880. * @param space The space that the axis is in
  65881. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65882. */
  65883. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  65884. /**
  65885. * Set the rotation of the bone to a particular axis angle in local or world space
  65886. * @param axis The axis to rotate the bone on
  65887. * @param angle The angle that the bone should be rotated to
  65888. * @param space The space that the axis is in
  65889. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65890. */
  65891. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  65892. /**
  65893. * Set the euler rotation of the bone in local of world space
  65894. * @param rotation The euler rotation that the bone should be set to
  65895. * @param space The space that the rotation is in
  65896. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65897. */
  65898. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  65899. /**
  65900. * Set the quaternion rotation of the bone in local of world space
  65901. * @param quat The quaternion rotation that the bone should be set to
  65902. * @param space The space that the rotation is in
  65903. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65904. */
  65905. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  65906. /**
  65907. * Set the rotation matrix of the bone in local of world space
  65908. * @param rotMat The rotation matrix that the bone should be set to
  65909. * @param space The space that the rotation is in
  65910. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65911. */
  65912. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  65913. private _rotateWithMatrix;
  65914. private _getNegativeRotationToRef;
  65915. /**
  65916. * Get the position of the bone in local or world space
  65917. * @param space The space that the returned position is in
  65918. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65919. * @returns The position of the bone
  65920. */
  65921. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  65922. /**
  65923. * Copy the position of the bone to a vector3 in local or world space
  65924. * @param space The space that the returned position is in
  65925. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65926. * @param result The vector3 to copy the position to
  65927. */
  65928. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  65929. /**
  65930. * Get the absolute position of the bone (world space)
  65931. * @param mesh The mesh that this bone is attached to
  65932. * @returns The absolute position of the bone
  65933. */
  65934. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  65935. /**
  65936. * Copy the absolute position of the bone (world space) to the result param
  65937. * @param mesh The mesh that this bone is attached to
  65938. * @param result The vector3 to copy the absolute position to
  65939. */
  65940. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  65941. /**
  65942. * Compute the absolute transforms of this bone and its children
  65943. */
  65944. computeAbsoluteTransforms(): void;
  65945. /**
  65946. * Get the world direction from an axis that is in the local space of the bone
  65947. * @param localAxis The local direction that is used to compute the world direction
  65948. * @param mesh The mesh that this bone is attached to
  65949. * @returns The world direction
  65950. */
  65951. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  65952. /**
  65953. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  65954. * @param localAxis The local direction that is used to compute the world direction
  65955. * @param mesh The mesh that this bone is attached to
  65956. * @param result The vector3 that the world direction will be copied to
  65957. */
  65958. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65959. /**
  65960. * Get the euler rotation of the bone in local or world space
  65961. * @param space The space that the rotation should be in
  65962. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65963. * @returns The euler rotation
  65964. */
  65965. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  65966. /**
  65967. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  65968. * @param space The space that the rotation should be in
  65969. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65970. * @param result The vector3 that the rotation should be copied to
  65971. */
  65972. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65973. /**
  65974. * Get the quaternion rotation of the bone in either local or world space
  65975. * @param space The space that the rotation should be in
  65976. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65977. * @returns The quaternion rotation
  65978. */
  65979. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  65980. /**
  65981. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  65982. * @param space The space that the rotation should be in
  65983. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65984. * @param result The quaternion that the rotation should be copied to
  65985. */
  65986. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  65987. /**
  65988. * Get the rotation matrix of the bone in local or world space
  65989. * @param space The space that the rotation should be in
  65990. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65991. * @returns The rotation matrix
  65992. */
  65993. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  65994. /**
  65995. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  65996. * @param space The space that the rotation should be in
  65997. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65998. * @param result The quaternion that the rotation should be copied to
  65999. */
  66000. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  66001. /**
  66002. * Get the world position of a point that is in the local space of the bone
  66003. * @param position The local position
  66004. * @param mesh The mesh that this bone is attached to
  66005. * @returns The world position
  66006. */
  66007. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  66008. /**
  66009. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  66010. * @param position The local position
  66011. * @param mesh The mesh that this bone is attached to
  66012. * @param result The vector3 that the world position should be copied to
  66013. */
  66014. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  66015. /**
  66016. * Get the local position of a point that is in world space
  66017. * @param position The world position
  66018. * @param mesh The mesh that this bone is attached to
  66019. * @returns The local position
  66020. */
  66021. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  66022. /**
  66023. * Get the local position of a point that is in world space and copy it to the result param
  66024. * @param position The world position
  66025. * @param mesh The mesh that this bone is attached to
  66026. * @param result The vector3 that the local position should be copied to
  66027. */
  66028. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  66029. }
  66030. }
  66031. declare module BABYLON {
  66032. /**
  66033. * Class for creating a cube texture
  66034. */
  66035. export class CubeTexture extends BaseTexture {
  66036. private _delayedOnLoad;
  66037. /**
  66038. * The url of the texture
  66039. */
  66040. url: string;
  66041. /**
  66042. * Gets or sets the center of the bounding box associated with the cube texture.
  66043. * It must define where the camera used to render the texture was set
  66044. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  66045. */
  66046. boundingBoxPosition: Vector3;
  66047. private _boundingBoxSize;
  66048. /**
  66049. * Gets or sets the size of the bounding box associated with the cube texture
  66050. * When defined, the cubemap will switch to local mode
  66051. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  66052. * @example https://www.babylonjs-playground.com/#RNASML
  66053. */
  66054. /**
  66055. * Returns the bounding box size
  66056. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  66057. */
  66058. boundingBoxSize: Vector3;
  66059. protected _rotationY: number;
  66060. /**
  66061. * Sets texture matrix rotation angle around Y axis in radians.
  66062. */
  66063. /**
  66064. * Gets texture matrix rotation angle around Y axis radians.
  66065. */
  66066. rotationY: number;
  66067. /**
  66068. * Are mip maps generated for this texture or not.
  66069. */
  66070. readonly noMipmap: boolean;
  66071. private _noMipmap;
  66072. private _files;
  66073. private _extensions;
  66074. private _textureMatrix;
  66075. private _format;
  66076. private _createPolynomials;
  66077. /** @hidden */
  66078. _prefiltered: boolean;
  66079. /**
  66080. * Creates a cube texture from an array of image urls
  66081. * @param files defines an array of image urls
  66082. * @param scene defines the hosting scene
  66083. * @param noMipmap specifies if mip maps are not used
  66084. * @returns a cube texture
  66085. */
  66086. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  66087. /**
  66088. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  66089. * @param url defines the url of the prefiltered texture
  66090. * @param scene defines the scene the texture is attached to
  66091. * @param forcedExtension defines the extension of the file if different from the url
  66092. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  66093. * @return the prefiltered texture
  66094. */
  66095. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  66096. /**
  66097. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  66098. * as prefiltered data.
  66099. * @param rootUrl defines the url of the texture or the root name of the six images
  66100. * @param scene defines the scene the texture is attached to
  66101. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  66102. * @param noMipmap defines if mipmaps should be created or not
  66103. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  66104. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  66105. * @param onError defines a callback triggered in case of error during load
  66106. * @param format defines the internal format to use for the texture once loaded
  66107. * @param prefiltered defines whether or not the texture is created from prefiltered data
  66108. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  66109. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  66110. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  66111. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  66112. * @return the cube texture
  66113. */
  66114. 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);
  66115. /**
  66116. * Get the current class name of the texture useful for serialization or dynamic coding.
  66117. * @returns "CubeTexture"
  66118. */
  66119. getClassName(): string;
  66120. /**
  66121. * Update the url (and optional buffer) of this texture if url was null during construction.
  66122. * @param url the url of the texture
  66123. * @param forcedExtension defines the extension to use
  66124. * @param onLoad callback called when the texture is loaded (defaults to null)
  66125. */
  66126. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  66127. /**
  66128. * Delays loading of the cube texture
  66129. * @param forcedExtension defines the extension to use
  66130. */
  66131. delayLoad(forcedExtension?: string): void;
  66132. /**
  66133. * Returns the reflection texture matrix
  66134. * @returns the reflection texture matrix
  66135. */
  66136. getReflectionTextureMatrix(): Matrix;
  66137. /**
  66138. * Sets the reflection texture matrix
  66139. * @param value Reflection texture matrix
  66140. */
  66141. setReflectionTextureMatrix(value: Matrix): void;
  66142. /**
  66143. * Parses text to create a cube texture
  66144. * @param parsedTexture define the serialized text to read from
  66145. * @param scene defines the hosting scene
  66146. * @param rootUrl defines the root url of the cube texture
  66147. * @returns a cube texture
  66148. */
  66149. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  66150. /**
  66151. * Makes a clone, or deep copy, of the cube texture
  66152. * @returns a new cube texture
  66153. */
  66154. clone(): CubeTexture;
  66155. }
  66156. }
  66157. declare module BABYLON {
  66158. /** @hidden */
  66159. export var postprocessVertexShader: {
  66160. name: string;
  66161. shader: string;
  66162. };
  66163. }
  66164. declare module BABYLON {
  66165. /**
  66166. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  66167. * This is the base of the follow, arc rotate cameras and Free camera
  66168. * @see http://doc.babylonjs.com/features/cameras
  66169. */
  66170. export class TargetCamera extends Camera {
  66171. private static _RigCamTransformMatrix;
  66172. private static _TargetTransformMatrix;
  66173. private static _TargetFocalPoint;
  66174. /**
  66175. * Define the current direction the camera is moving to
  66176. */
  66177. cameraDirection: Vector3;
  66178. /**
  66179. * Define the current rotation the camera is rotating to
  66180. */
  66181. cameraRotation: Vector2;
  66182. /**
  66183. * When set, the up vector of the camera will be updated by the rotation of the camera
  66184. */
  66185. updateUpVectorFromRotation: boolean;
  66186. private _tmpQuaternion;
  66187. /**
  66188. * Define the current rotation of the camera
  66189. */
  66190. rotation: Vector3;
  66191. /**
  66192. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  66193. */
  66194. rotationQuaternion: Quaternion;
  66195. /**
  66196. * Define the current speed of the camera
  66197. */
  66198. speed: number;
  66199. /**
  66200. * Add cconstraint to the camera to prevent it to move freely in all directions and
  66201. * around all axis.
  66202. */
  66203. noRotationConstraint: boolean;
  66204. /**
  66205. * Define the current target of the camera as an object or a position.
  66206. */
  66207. lockedTarget: any;
  66208. /** @hidden */
  66209. _currentTarget: Vector3;
  66210. /** @hidden */
  66211. _initialFocalDistance: number;
  66212. /** @hidden */
  66213. _viewMatrix: Matrix;
  66214. /** @hidden */
  66215. _camMatrix: Matrix;
  66216. /** @hidden */
  66217. _cameraTransformMatrix: Matrix;
  66218. /** @hidden */
  66219. _cameraRotationMatrix: Matrix;
  66220. /** @hidden */
  66221. _referencePoint: Vector3;
  66222. /** @hidden */
  66223. _transformedReferencePoint: Vector3;
  66224. protected _globalCurrentTarget: Vector3;
  66225. protected _globalCurrentUpVector: Vector3;
  66226. /** @hidden */
  66227. _reset: () => void;
  66228. private _defaultUp;
  66229. /**
  66230. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  66231. * This is the base of the follow, arc rotate cameras and Free camera
  66232. * @see http://doc.babylonjs.com/features/cameras
  66233. * @param name Defines the name of the camera in the scene
  66234. * @param position Defines the start position of the camera in the scene
  66235. * @param scene Defines the scene the camera belongs to
  66236. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  66237. */
  66238. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  66239. /**
  66240. * Gets the position in front of the camera at a given distance.
  66241. * @param distance The distance from the camera we want the position to be
  66242. * @returns the position
  66243. */
  66244. getFrontPosition(distance: number): Vector3;
  66245. /** @hidden */
  66246. _getLockedTargetPosition(): Nullable<Vector3>;
  66247. private _storedPosition;
  66248. private _storedRotation;
  66249. private _storedRotationQuaternion;
  66250. /**
  66251. * Store current camera state of the camera (fov, position, rotation, etc..)
  66252. * @returns the camera
  66253. */
  66254. storeState(): Camera;
  66255. /**
  66256. * Restored camera state. You must call storeState() first
  66257. * @returns whether it was successful or not
  66258. * @hidden
  66259. */
  66260. _restoreStateValues(): boolean;
  66261. /** @hidden */
  66262. _initCache(): void;
  66263. /** @hidden */
  66264. _updateCache(ignoreParentClass?: boolean): void;
  66265. /** @hidden */
  66266. _isSynchronizedViewMatrix(): boolean;
  66267. /** @hidden */
  66268. _computeLocalCameraSpeed(): number;
  66269. /**
  66270. * Defines the target the camera should look at.
  66271. * This will automatically adapt alpha beta and radius to fit within the new target.
  66272. * @param target Defines the new target as a Vector or a mesh
  66273. */
  66274. setTarget(target: Vector3): void;
  66275. /**
  66276. * Return the current target position of the camera. This value is expressed in local space.
  66277. * @returns the target position
  66278. */
  66279. getTarget(): Vector3;
  66280. /** @hidden */
  66281. _decideIfNeedsToMove(): boolean;
  66282. /** @hidden */
  66283. _updatePosition(): void;
  66284. /** @hidden */
  66285. _checkInputs(): void;
  66286. protected _updateCameraRotationMatrix(): void;
  66287. /**
  66288. * 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)
  66289. * @returns the current camera
  66290. */
  66291. private _rotateUpVectorWithCameraRotationMatrix;
  66292. private _cachedRotationZ;
  66293. private _cachedQuaternionRotationZ;
  66294. /** @hidden */
  66295. _getViewMatrix(): Matrix;
  66296. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  66297. /**
  66298. * @hidden
  66299. */
  66300. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  66301. /**
  66302. * @hidden
  66303. */
  66304. _updateRigCameras(): void;
  66305. private _getRigCamPositionAndTarget;
  66306. /**
  66307. * Gets the current object class name.
  66308. * @return the class name
  66309. */
  66310. getClassName(): string;
  66311. }
  66312. }
  66313. declare module BABYLON {
  66314. /**
  66315. * @ignore
  66316. * This is a list of all the different input types that are available in the application.
  66317. * Fo instance: ArcRotateCameraGamepadInput...
  66318. */
  66319. export var CameraInputTypes: {};
  66320. /**
  66321. * This is the contract to implement in order to create a new input class.
  66322. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  66323. */
  66324. export interface ICameraInput<TCamera extends Camera> {
  66325. /**
  66326. * Defines the camera the input is attached to.
  66327. */
  66328. camera: Nullable<TCamera>;
  66329. /**
  66330. * Gets the class name of the current intput.
  66331. * @returns the class name
  66332. */
  66333. getClassName(): string;
  66334. /**
  66335. * Get the friendly name associated with the input class.
  66336. * @returns the input friendly name
  66337. */
  66338. getSimpleName(): string;
  66339. /**
  66340. * Attach the input controls to a specific dom element to get the input from.
  66341. * @param element Defines the element the controls should be listened from
  66342. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  66343. */
  66344. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  66345. /**
  66346. * Detach the current controls from the specified dom element.
  66347. * @param element Defines the element to stop listening the inputs from
  66348. */
  66349. detachControl(element: Nullable<HTMLElement>): void;
  66350. /**
  66351. * Update the current camera state depending on the inputs that have been used this frame.
  66352. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  66353. */
  66354. checkInputs?: () => void;
  66355. }
  66356. /**
  66357. * Represents a map of input types to input instance or input index to input instance.
  66358. */
  66359. export interface CameraInputsMap<TCamera extends Camera> {
  66360. /**
  66361. * Accessor to the input by input type.
  66362. */
  66363. [name: string]: ICameraInput<TCamera>;
  66364. /**
  66365. * Accessor to the input by input index.
  66366. */
  66367. [idx: number]: ICameraInput<TCamera>;
  66368. }
  66369. /**
  66370. * This represents the input manager used within a camera.
  66371. * It helps dealing with all the different kind of input attached to a camera.
  66372. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  66373. */
  66374. export class CameraInputsManager<TCamera extends Camera> {
  66375. /**
  66376. * Defines the list of inputs attahed to the camera.
  66377. */
  66378. attached: CameraInputsMap<TCamera>;
  66379. /**
  66380. * Defines the dom element the camera is collecting inputs from.
  66381. * This is null if the controls have not been attached.
  66382. */
  66383. attachedElement: Nullable<HTMLElement>;
  66384. /**
  66385. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  66386. */
  66387. noPreventDefault: boolean;
  66388. /**
  66389. * Defined the camera the input manager belongs to.
  66390. */
  66391. camera: TCamera;
  66392. /**
  66393. * Update the current camera state depending on the inputs that have been used this frame.
  66394. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  66395. */
  66396. checkInputs: () => void;
  66397. /**
  66398. * Instantiate a new Camera Input Manager.
  66399. * @param camera Defines the camera the input manager blongs to
  66400. */
  66401. constructor(camera: TCamera);
  66402. /**
  66403. * Add an input method to a camera
  66404. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  66405. * @param input camera input method
  66406. */
  66407. add(input: ICameraInput<TCamera>): void;
  66408. /**
  66409. * Remove a specific input method from a camera
  66410. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  66411. * @param inputToRemove camera input method
  66412. */
  66413. remove(inputToRemove: ICameraInput<TCamera>): void;
  66414. /**
  66415. * Remove a specific input type from a camera
  66416. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  66417. * @param inputType the type of the input to remove
  66418. */
  66419. removeByType(inputType: string): void;
  66420. private _addCheckInputs;
  66421. /**
  66422. * Attach the input controls to the currently attached dom element to listen the events from.
  66423. * @param input Defines the input to attach
  66424. */
  66425. attachInput(input: ICameraInput<TCamera>): void;
  66426. /**
  66427. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  66428. * @param element Defines the dom element to collect the events from
  66429. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  66430. */
  66431. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  66432. /**
  66433. * Detach the current manager inputs controls from a specific dom element.
  66434. * @param element Defines the dom element to collect the events from
  66435. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  66436. */
  66437. detachElement(element: HTMLElement, disconnect?: boolean): void;
  66438. /**
  66439. * Rebuild the dynamic inputCheck function from the current list of
  66440. * defined inputs in the manager.
  66441. */
  66442. rebuildInputCheck(): void;
  66443. /**
  66444. * Remove all attached input methods from a camera
  66445. */
  66446. clear(): void;
  66447. /**
  66448. * Serialize the current input manager attached to a camera.
  66449. * This ensures than once parsed,
  66450. * the input associated to the camera will be identical to the current ones
  66451. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  66452. */
  66453. serialize(serializedCamera: any): void;
  66454. /**
  66455. * Parses an input manager serialized JSON to restore the previous list of inputs
  66456. * and states associated to a camera.
  66457. * @param parsedCamera Defines the JSON to parse
  66458. */
  66459. parse(parsedCamera: any): void;
  66460. }
  66461. }
  66462. declare module BABYLON {
  66463. /**
  66464. * Gather the list of keyboard event types as constants.
  66465. */
  66466. export class KeyboardEventTypes {
  66467. /**
  66468. * The keydown event is fired when a key becomes active (pressed).
  66469. */
  66470. static readonly KEYDOWN: number;
  66471. /**
  66472. * The keyup event is fired when a key has been released.
  66473. */
  66474. static readonly KEYUP: number;
  66475. }
  66476. /**
  66477. * This class is used to store keyboard related info for the onKeyboardObservable event.
  66478. */
  66479. export class KeyboardInfo {
  66480. /**
  66481. * Defines the type of event (KeyboardEventTypes)
  66482. */
  66483. type: number;
  66484. /**
  66485. * Defines the related dom event
  66486. */
  66487. event: KeyboardEvent;
  66488. /**
  66489. * Instantiates a new keyboard info.
  66490. * This class is used to store keyboard related info for the onKeyboardObservable event.
  66491. * @param type Defines the type of event (KeyboardEventTypes)
  66492. * @param event Defines the related dom event
  66493. */
  66494. constructor(
  66495. /**
  66496. * Defines the type of event (KeyboardEventTypes)
  66497. */
  66498. type: number,
  66499. /**
  66500. * Defines the related dom event
  66501. */
  66502. event: KeyboardEvent);
  66503. }
  66504. /**
  66505. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  66506. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  66507. */
  66508. export class KeyboardInfoPre extends KeyboardInfo {
  66509. /**
  66510. * Defines the type of event (KeyboardEventTypes)
  66511. */
  66512. type: number;
  66513. /**
  66514. * Defines the related dom event
  66515. */
  66516. event: KeyboardEvent;
  66517. /**
  66518. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  66519. */
  66520. skipOnPointerObservable: boolean;
  66521. /**
  66522. * Instantiates a new keyboard pre info.
  66523. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  66524. * @param type Defines the type of event (KeyboardEventTypes)
  66525. * @param event Defines the related dom event
  66526. */
  66527. constructor(
  66528. /**
  66529. * Defines the type of event (KeyboardEventTypes)
  66530. */
  66531. type: number,
  66532. /**
  66533. * Defines the related dom event
  66534. */
  66535. event: KeyboardEvent);
  66536. }
  66537. }
  66538. declare module BABYLON {
  66539. /**
  66540. * Manage the keyboard inputs to control the movement of a free camera.
  66541. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  66542. */
  66543. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  66544. /**
  66545. * Defines the camera the input is attached to.
  66546. */
  66547. camera: FreeCamera;
  66548. /**
  66549. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  66550. */
  66551. keysUp: number[];
  66552. /**
  66553. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  66554. */
  66555. keysDown: number[];
  66556. /**
  66557. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  66558. */
  66559. keysLeft: number[];
  66560. /**
  66561. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  66562. */
  66563. keysRight: number[];
  66564. private _keys;
  66565. private _onCanvasBlurObserver;
  66566. private _onKeyboardObserver;
  66567. private _engine;
  66568. private _scene;
  66569. /**
  66570. * Attach the input controls to a specific dom element to get the input from.
  66571. * @param element Defines the element the controls should be listened from
  66572. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  66573. */
  66574. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  66575. /**
  66576. * Detach the current controls from the specified dom element.
  66577. * @param element Defines the element to stop listening the inputs from
  66578. */
  66579. detachControl(element: Nullable<HTMLElement>): void;
  66580. /**
  66581. * Update the current camera state depending on the inputs that have been used this frame.
  66582. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  66583. */
  66584. checkInputs(): void;
  66585. /**
  66586. * Gets the class name of the current intput.
  66587. * @returns the class name
  66588. */
  66589. getClassName(): string;
  66590. /** @hidden */
  66591. _onLostFocus(): void;
  66592. /**
  66593. * Get the friendly name associated with the input class.
  66594. * @returns the input friendly name
  66595. */
  66596. getSimpleName(): string;
  66597. }
  66598. }
  66599. declare module BABYLON {
  66600. /**
  66601. * Interface describing all the common properties and methods a shadow light needs to implement.
  66602. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  66603. * as well as binding the different shadow properties to the effects.
  66604. */
  66605. export interface IShadowLight extends Light {
  66606. /**
  66607. * The light id in the scene (used in scene.findLighById for instance)
  66608. */
  66609. id: string;
  66610. /**
  66611. * The position the shdow will be casted from.
  66612. */
  66613. position: Vector3;
  66614. /**
  66615. * In 2d mode (needCube being false), the direction used to cast the shadow.
  66616. */
  66617. direction: Vector3;
  66618. /**
  66619. * The transformed position. Position of the light in world space taking parenting in account.
  66620. */
  66621. transformedPosition: Vector3;
  66622. /**
  66623. * The transformed direction. Direction of the light in world space taking parenting in account.
  66624. */
  66625. transformedDirection: Vector3;
  66626. /**
  66627. * The friendly name of the light in the scene.
  66628. */
  66629. name: string;
  66630. /**
  66631. * Defines the shadow projection clipping minimum z value.
  66632. */
  66633. shadowMinZ: number;
  66634. /**
  66635. * Defines the shadow projection clipping maximum z value.
  66636. */
  66637. shadowMaxZ: number;
  66638. /**
  66639. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  66640. * @returns true if the information has been computed, false if it does not need to (no parenting)
  66641. */
  66642. computeTransformedInformation(): boolean;
  66643. /**
  66644. * Gets the scene the light belongs to.
  66645. * @returns The scene
  66646. */
  66647. getScene(): Scene;
  66648. /**
  66649. * Callback defining a custom Projection Matrix Builder.
  66650. * This can be used to override the default projection matrix computation.
  66651. */
  66652. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  66653. /**
  66654. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  66655. * @param matrix The materix to updated with the projection information
  66656. * @param viewMatrix The transform matrix of the light
  66657. * @param renderList The list of mesh to render in the map
  66658. * @returns The current light
  66659. */
  66660. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  66661. /**
  66662. * Gets the current depth scale used in ESM.
  66663. * @returns The scale
  66664. */
  66665. getDepthScale(): number;
  66666. /**
  66667. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  66668. * @returns true if a cube texture needs to be use
  66669. */
  66670. needCube(): boolean;
  66671. /**
  66672. * Detects if the projection matrix requires to be recomputed this frame.
  66673. * @returns true if it requires to be recomputed otherwise, false.
  66674. */
  66675. needProjectionMatrixCompute(): boolean;
  66676. /**
  66677. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  66678. */
  66679. forceProjectionMatrixCompute(): void;
  66680. /**
  66681. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  66682. * @param faceIndex The index of the face we are computed the direction to generate shadow
  66683. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  66684. */
  66685. getShadowDirection(faceIndex?: number): Vector3;
  66686. /**
  66687. * Gets the minZ used for shadow according to both the scene and the light.
  66688. * @param activeCamera The camera we are returning the min for
  66689. * @returns the depth min z
  66690. */
  66691. getDepthMinZ(activeCamera: Camera): number;
  66692. /**
  66693. * Gets the maxZ used for shadow according to both the scene and the light.
  66694. * @param activeCamera The camera we are returning the max for
  66695. * @returns the depth max z
  66696. */
  66697. getDepthMaxZ(activeCamera: Camera): number;
  66698. }
  66699. /**
  66700. * Base implementation IShadowLight
  66701. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  66702. */
  66703. export abstract class ShadowLight extends Light implements IShadowLight {
  66704. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  66705. protected _position: Vector3;
  66706. protected _setPosition(value: Vector3): void;
  66707. /**
  66708. * Sets the position the shadow will be casted from. Also use as the light position for both
  66709. * point and spot lights.
  66710. */
  66711. /**
  66712. * Sets the position the shadow will be casted from. Also use as the light position for both
  66713. * point and spot lights.
  66714. */
  66715. position: Vector3;
  66716. protected _direction: Vector3;
  66717. protected _setDirection(value: Vector3): void;
  66718. /**
  66719. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  66720. * Also use as the light direction on spot and directional lights.
  66721. */
  66722. /**
  66723. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  66724. * Also use as the light direction on spot and directional lights.
  66725. */
  66726. direction: Vector3;
  66727. private _shadowMinZ;
  66728. /**
  66729. * Gets the shadow projection clipping minimum z value.
  66730. */
  66731. /**
  66732. * Sets the shadow projection clipping minimum z value.
  66733. */
  66734. shadowMinZ: number;
  66735. private _shadowMaxZ;
  66736. /**
  66737. * Sets the shadow projection clipping maximum z value.
  66738. */
  66739. /**
  66740. * Gets the shadow projection clipping maximum z value.
  66741. */
  66742. shadowMaxZ: number;
  66743. /**
  66744. * Callback defining a custom Projection Matrix Builder.
  66745. * This can be used to override the default projection matrix computation.
  66746. */
  66747. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  66748. /**
  66749. * The transformed position. Position of the light in world space taking parenting in account.
  66750. */
  66751. transformedPosition: Vector3;
  66752. /**
  66753. * The transformed direction. Direction of the light in world space taking parenting in account.
  66754. */
  66755. transformedDirection: Vector3;
  66756. private _needProjectionMatrixCompute;
  66757. /**
  66758. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  66759. * @returns true if the information has been computed, false if it does not need to (no parenting)
  66760. */
  66761. computeTransformedInformation(): boolean;
  66762. /**
  66763. * Return the depth scale used for the shadow map.
  66764. * @returns the depth scale.
  66765. */
  66766. getDepthScale(): number;
  66767. /**
  66768. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  66769. * @param faceIndex The index of the face we are computed the direction to generate shadow
  66770. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  66771. */
  66772. getShadowDirection(faceIndex?: number): Vector3;
  66773. /**
  66774. * Returns the ShadowLight absolute position in the World.
  66775. * @returns the position vector in world space
  66776. */
  66777. getAbsolutePosition(): Vector3;
  66778. /**
  66779. * Sets the ShadowLight direction toward the passed target.
  66780. * @param target The point to target in local space
  66781. * @returns the updated ShadowLight direction
  66782. */
  66783. setDirectionToTarget(target: Vector3): Vector3;
  66784. /**
  66785. * Returns the light rotation in euler definition.
  66786. * @returns the x y z rotation in local space.
  66787. */
  66788. getRotation(): Vector3;
  66789. /**
  66790. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  66791. * @returns true if a cube texture needs to be use
  66792. */
  66793. needCube(): boolean;
  66794. /**
  66795. * Detects if the projection matrix requires to be recomputed this frame.
  66796. * @returns true if it requires to be recomputed otherwise, false.
  66797. */
  66798. needProjectionMatrixCompute(): boolean;
  66799. /**
  66800. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  66801. */
  66802. forceProjectionMatrixCompute(): void;
  66803. /** @hidden */
  66804. _initCache(): void;
  66805. /** @hidden */
  66806. _isSynchronized(): boolean;
  66807. /**
  66808. * Computes the world matrix of the node
  66809. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  66810. * @returns the world matrix
  66811. */
  66812. computeWorldMatrix(force?: boolean): Matrix;
  66813. /**
  66814. * Gets the minZ used for shadow according to both the scene and the light.
  66815. * @param activeCamera The camera we are returning the min for
  66816. * @returns the depth min z
  66817. */
  66818. getDepthMinZ(activeCamera: Camera): number;
  66819. /**
  66820. * Gets the maxZ used for shadow according to both the scene and the light.
  66821. * @param activeCamera The camera we are returning the max for
  66822. * @returns the depth max z
  66823. */
  66824. getDepthMaxZ(activeCamera: Camera): number;
  66825. /**
  66826. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  66827. * @param matrix The materix to updated with the projection information
  66828. * @param viewMatrix The transform matrix of the light
  66829. * @param renderList The list of mesh to render in the map
  66830. * @returns The current light
  66831. */
  66832. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  66833. }
  66834. }
  66835. declare module BABYLON {
  66836. /**
  66837. * "Static Class" containing the most commonly used helper while dealing with material for
  66838. * rendering purpose.
  66839. *
  66840. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  66841. *
  66842. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  66843. */
  66844. export class MaterialHelper {
  66845. /**
  66846. * Bind the current view position to an effect.
  66847. * @param effect The effect to be bound
  66848. * @param scene The scene the eyes position is used from
  66849. */
  66850. static BindEyePosition(effect: Effect, scene: Scene): void;
  66851. /**
  66852. * Helps preparing the defines values about the UVs in used in the effect.
  66853. * UVs are shared as much as we can accross channels in the shaders.
  66854. * @param texture The texture we are preparing the UVs for
  66855. * @param defines The defines to update
  66856. * @param key The channel key "diffuse", "specular"... used in the shader
  66857. */
  66858. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  66859. /**
  66860. * Binds a texture matrix value to its corrsponding uniform
  66861. * @param texture The texture to bind the matrix for
  66862. * @param uniformBuffer The uniform buffer receivin the data
  66863. * @param key The channel key "diffuse", "specular"... used in the shader
  66864. */
  66865. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  66866. /**
  66867. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  66868. * @param mesh defines the current mesh
  66869. * @param scene defines the current scene
  66870. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  66871. * @param pointsCloud defines if point cloud rendering has to be turned on
  66872. * @param fogEnabled defines if fog has to be turned on
  66873. * @param alphaTest defines if alpha testing has to be turned on
  66874. * @param defines defines the current list of defines
  66875. */
  66876. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  66877. /**
  66878. * Helper used to prepare the list of defines associated with frame values for shader compilation
  66879. * @param scene defines the current scene
  66880. * @param engine defines the current engine
  66881. * @param defines specifies the list of active defines
  66882. * @param useInstances defines if instances have to be turned on
  66883. * @param useClipPlane defines if clip plane have to be turned on
  66884. */
  66885. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  66886. /**
  66887. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  66888. * @param mesh The mesh containing the geometry data we will draw
  66889. * @param defines The defines to update
  66890. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  66891. * @param useBones Precise whether bones should be used or not (override mesh info)
  66892. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  66893. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  66894. * @returns false if defines are considered not dirty and have not been checked
  66895. */
  66896. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  66897. /**
  66898. * Prepares the defines related to the light information passed in parameter
  66899. * @param scene The scene we are intending to draw
  66900. * @param mesh The mesh the effect is compiling for
  66901. * @param defines The defines to update
  66902. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  66903. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  66904. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  66905. * @returns true if normals will be required for the rest of the effect
  66906. */
  66907. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  66908. /**
  66909. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  66910. * that won t be acctive due to defines being turned off.
  66911. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  66912. * @param samplersList The samplers list
  66913. * @param defines The defines helping in the list generation
  66914. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  66915. */
  66916. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  66917. /**
  66918. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  66919. * @param defines The defines to update while falling back
  66920. * @param fallbacks The authorized effect fallbacks
  66921. * @param maxSimultaneousLights The maximum number of lights allowed
  66922. * @param rank the current rank of the Effect
  66923. * @returns The newly affected rank
  66924. */
  66925. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  66926. /**
  66927. * Prepares the list of attributes required for morph targets according to the effect defines.
  66928. * @param attribs The current list of supported attribs
  66929. * @param mesh The mesh to prepare the morph targets attributes for
  66930. * @param defines The current Defines of the effect
  66931. */
  66932. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  66933. /**
  66934. * Prepares the list of attributes required for bones according to the effect defines.
  66935. * @param attribs The current list of supported attribs
  66936. * @param mesh The mesh to prepare the bones attributes for
  66937. * @param defines The current Defines of the effect
  66938. * @param fallbacks The current efffect fallback strategy
  66939. */
  66940. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  66941. /**
  66942. * Prepares the list of attributes required for instances according to the effect defines.
  66943. * @param attribs The current list of supported attribs
  66944. * @param defines The current Defines of the effect
  66945. */
  66946. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  66947. /**
  66948. * Binds the light shadow information to the effect for the given mesh.
  66949. * @param light The light containing the generator
  66950. * @param scene The scene the lights belongs to
  66951. * @param mesh The mesh we are binding the information to render
  66952. * @param lightIndex The light index in the effect used to render the mesh
  66953. * @param effect The effect we are binding the data to
  66954. */
  66955. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  66956. /**
  66957. * Binds the light information to the effect.
  66958. * @param light The light containing the generator
  66959. * @param effect The effect we are binding the data to
  66960. * @param lightIndex The light index in the effect used to render
  66961. */
  66962. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  66963. /**
  66964. * Binds the lights information from the scene to the effect for the given mesh.
  66965. * @param scene The scene the lights belongs to
  66966. * @param mesh The mesh we are binding the information to render
  66967. * @param effect The effect we are binding the data to
  66968. * @param defines The generated defines for the effect
  66969. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  66970. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  66971. */
  66972. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  66973. private static _tempFogColor;
  66974. /**
  66975. * Binds the fog information from the scene to the effect for the given mesh.
  66976. * @param scene The scene the lights belongs to
  66977. * @param mesh The mesh we are binding the information to render
  66978. * @param effect The effect we are binding the data to
  66979. * @param linearSpace Defines if the fog effect is applied in linear space
  66980. */
  66981. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  66982. /**
  66983. * Binds the bones information from the mesh to the effect.
  66984. * @param mesh The mesh we are binding the information to render
  66985. * @param effect The effect we are binding the data to
  66986. */
  66987. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  66988. /**
  66989. * Binds the morph targets information from the mesh to the effect.
  66990. * @param abstractMesh The mesh we are binding the information to render
  66991. * @param effect The effect we are binding the data to
  66992. */
  66993. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  66994. /**
  66995. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  66996. * @param defines The generated defines used in the effect
  66997. * @param effect The effect we are binding the data to
  66998. * @param scene The scene we are willing to render with logarithmic scale for
  66999. */
  67000. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  67001. /**
  67002. * Binds the clip plane information from the scene to the effect.
  67003. * @param scene The scene the clip plane information are extracted from
  67004. * @param effect The effect we are binding the data to
  67005. */
  67006. static BindClipPlane(effect: Effect, scene: Scene): void;
  67007. }
  67008. }
  67009. declare module BABYLON {
  67010. /** @hidden */
  67011. export var kernelBlurVaryingDeclaration: {
  67012. name: string;
  67013. shader: string;
  67014. };
  67015. }
  67016. declare module BABYLON {
  67017. /** @hidden */
  67018. export var kernelBlurFragment: {
  67019. name: string;
  67020. shader: string;
  67021. };
  67022. }
  67023. declare module BABYLON {
  67024. /** @hidden */
  67025. export var kernelBlurFragment2: {
  67026. name: string;
  67027. shader: string;
  67028. };
  67029. }
  67030. declare module BABYLON {
  67031. /** @hidden */
  67032. export var kernelBlurPixelShader: {
  67033. name: string;
  67034. shader: string;
  67035. };
  67036. }
  67037. declare module BABYLON {
  67038. /** @hidden */
  67039. export var kernelBlurVertex: {
  67040. name: string;
  67041. shader: string;
  67042. };
  67043. }
  67044. declare module BABYLON {
  67045. /** @hidden */
  67046. export var kernelBlurVertexShader: {
  67047. name: string;
  67048. shader: string;
  67049. };
  67050. }
  67051. declare module BABYLON {
  67052. /**
  67053. * The Blur Post Process which blurs an image based on a kernel and direction.
  67054. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  67055. */
  67056. export class BlurPostProcess extends PostProcess {
  67057. /** The direction in which to blur the image. */
  67058. direction: Vector2;
  67059. private blockCompilation;
  67060. protected _kernel: number;
  67061. protected _idealKernel: number;
  67062. protected _packedFloat: boolean;
  67063. private _staticDefines;
  67064. /**
  67065. * Sets the length in pixels of the blur sample region
  67066. */
  67067. /**
  67068. * Gets the length in pixels of the blur sample region
  67069. */
  67070. kernel: number;
  67071. /**
  67072. * Sets wether or not the blur needs to unpack/repack floats
  67073. */
  67074. /**
  67075. * Gets wether or not the blur is unpacking/repacking floats
  67076. */
  67077. packedFloat: boolean;
  67078. /**
  67079. * Creates a new instance BlurPostProcess
  67080. * @param name The name of the effect.
  67081. * @param direction The direction in which to blur the image.
  67082. * @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.
  67083. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  67084. * @param camera The camera to apply the render pass to.
  67085. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67086. * @param engine The engine which the post process will be applied. (default: current engine)
  67087. * @param reusable If the post process can be reused on the same frame. (default: false)
  67088. * @param textureType Type of textures used when performing the post process. (default: 0)
  67089. * @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)
  67090. */
  67091. constructor(name: string,
  67092. /** The direction in which to blur the image. */
  67093. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  67094. /**
  67095. * Updates the effect with the current post process compile time values and recompiles the shader.
  67096. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67097. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67098. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67099. * @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
  67100. * @param onCompiled Called when the shader has been compiled.
  67101. * @param onError Called if there is an error when compiling a shader.
  67102. */
  67103. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67104. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67105. /**
  67106. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  67107. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  67108. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  67109. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  67110. * The gaps between physical kernels are compensated for in the weighting of the samples
  67111. * @param idealKernel Ideal blur kernel.
  67112. * @return Nearest best kernel.
  67113. */
  67114. protected _nearestBestKernel(idealKernel: number): number;
  67115. /**
  67116. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  67117. * @param x The point on the Gaussian distribution to sample.
  67118. * @return the value of the Gaussian function at x.
  67119. */
  67120. protected _gaussianWeight(x: number): number;
  67121. /**
  67122. * Generates a string that can be used as a floating point number in GLSL.
  67123. * @param x Value to print.
  67124. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  67125. * @return GLSL float string.
  67126. */
  67127. protected _glslFloat(x: number, decimalFigures?: number): string;
  67128. }
  67129. }
  67130. declare module BABYLON {
  67131. /** @hidden */
  67132. export var shadowMapPixelShader: {
  67133. name: string;
  67134. shader: string;
  67135. };
  67136. }
  67137. declare module BABYLON {
  67138. /** @hidden */
  67139. export var bonesDeclaration: {
  67140. name: string;
  67141. shader: string;
  67142. };
  67143. }
  67144. declare module BABYLON {
  67145. /** @hidden */
  67146. export var morphTargetsVertexGlobalDeclaration: {
  67147. name: string;
  67148. shader: string;
  67149. };
  67150. }
  67151. declare module BABYLON {
  67152. /** @hidden */
  67153. export var morphTargetsVertexDeclaration: {
  67154. name: string;
  67155. shader: string;
  67156. };
  67157. }
  67158. declare module BABYLON {
  67159. /** @hidden */
  67160. export var instancesDeclaration: {
  67161. name: string;
  67162. shader: string;
  67163. };
  67164. }
  67165. declare module BABYLON {
  67166. /** @hidden */
  67167. export var helperFunctions: {
  67168. name: string;
  67169. shader: string;
  67170. };
  67171. }
  67172. declare module BABYLON {
  67173. /** @hidden */
  67174. export var morphTargetsVertex: {
  67175. name: string;
  67176. shader: string;
  67177. };
  67178. }
  67179. declare module BABYLON {
  67180. /** @hidden */
  67181. export var instancesVertex: {
  67182. name: string;
  67183. shader: string;
  67184. };
  67185. }
  67186. declare module BABYLON {
  67187. /** @hidden */
  67188. export var bonesVertex: {
  67189. name: string;
  67190. shader: string;
  67191. };
  67192. }
  67193. declare module BABYLON {
  67194. /** @hidden */
  67195. export var shadowMapVertexShader: {
  67196. name: string;
  67197. shader: string;
  67198. };
  67199. }
  67200. declare module BABYLON {
  67201. /** @hidden */
  67202. export var depthBoxBlurPixelShader: {
  67203. name: string;
  67204. shader: string;
  67205. };
  67206. }
  67207. declare module BABYLON {
  67208. /**
  67209. * Defines the options associated with the creation of a custom shader for a shadow generator.
  67210. */
  67211. export interface ICustomShaderOptions {
  67212. /**
  67213. * Gets or sets the custom shader name to use
  67214. */
  67215. shaderName: string;
  67216. /**
  67217. * The list of attribute names used in the shader
  67218. */
  67219. attributes?: string[];
  67220. /**
  67221. * The list of unifrom names used in the shader
  67222. */
  67223. uniforms?: string[];
  67224. /**
  67225. * The list of sampler names used in the shader
  67226. */
  67227. samplers?: string[];
  67228. /**
  67229. * The list of defines used in the shader
  67230. */
  67231. defines?: string[];
  67232. }
  67233. /**
  67234. * Interface to implement to create a shadow generator compatible with BJS.
  67235. */
  67236. export interface IShadowGenerator {
  67237. /**
  67238. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  67239. * @returns The render target texture if present otherwise, null
  67240. */
  67241. getShadowMap(): Nullable<RenderTargetTexture>;
  67242. /**
  67243. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  67244. * @returns The render target texture if the shadow map is present otherwise, null
  67245. */
  67246. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  67247. /**
  67248. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  67249. * @param subMesh The submesh we want to render in the shadow map
  67250. * @param useInstances Defines wether will draw in the map using instances
  67251. * @returns true if ready otherwise, false
  67252. */
  67253. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67254. /**
  67255. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  67256. * @param defines Defines of the material we want to update
  67257. * @param lightIndex Index of the light in the enabled light list of the material
  67258. */
  67259. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  67260. /**
  67261. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  67262. * defined in the generator but impacting the effect).
  67263. * It implies the unifroms available on the materials are the standard BJS ones.
  67264. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  67265. * @param effect The effect we are binfing the information for
  67266. */
  67267. bindShadowLight(lightIndex: string, effect: Effect): void;
  67268. /**
  67269. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  67270. * (eq to shadow prjection matrix * light transform matrix)
  67271. * @returns The transform matrix used to create the shadow map
  67272. */
  67273. getTransformMatrix(): Matrix;
  67274. /**
  67275. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  67276. * Cube and 2D textures for instance.
  67277. */
  67278. recreateShadowMap(): void;
  67279. /**
  67280. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67281. * @param onCompiled Callback triggered at the and of the effects compilation
  67282. * @param options Sets of optional options forcing the compilation with different modes
  67283. */
  67284. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  67285. useInstances: boolean;
  67286. }>): void;
  67287. /**
  67288. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67289. * @param options Sets of optional options forcing the compilation with different modes
  67290. * @returns A promise that resolves when the compilation completes
  67291. */
  67292. forceCompilationAsync(options?: Partial<{
  67293. useInstances: boolean;
  67294. }>): Promise<void>;
  67295. /**
  67296. * Serializes the shadow generator setup to a json object.
  67297. * @returns The serialized JSON object
  67298. */
  67299. serialize(): any;
  67300. /**
  67301. * Disposes the Shadow map and related Textures and effects.
  67302. */
  67303. dispose(): void;
  67304. }
  67305. /**
  67306. * Default implementation IShadowGenerator.
  67307. * This is the main object responsible of generating shadows in the framework.
  67308. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  67309. */
  67310. export class ShadowGenerator implements IShadowGenerator {
  67311. /**
  67312. * Shadow generator mode None: no filtering applied.
  67313. */
  67314. static readonly FILTER_NONE: number;
  67315. /**
  67316. * Shadow generator mode ESM: Exponential Shadow Mapping.
  67317. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  67318. */
  67319. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  67320. /**
  67321. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  67322. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  67323. */
  67324. static readonly FILTER_POISSONSAMPLING: number;
  67325. /**
  67326. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  67327. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  67328. */
  67329. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  67330. /**
  67331. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  67332. * edge artifacts on steep falloff.
  67333. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  67334. */
  67335. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  67336. /**
  67337. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  67338. * edge artifacts on steep falloff.
  67339. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  67340. */
  67341. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  67342. /**
  67343. * Shadow generator mode PCF: Percentage Closer Filtering
  67344. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  67345. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  67346. */
  67347. static readonly FILTER_PCF: number;
  67348. /**
  67349. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  67350. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  67351. * Contact Hardening
  67352. */
  67353. static readonly FILTER_PCSS: number;
  67354. /**
  67355. * Reserved for PCF and PCSS
  67356. * Highest Quality.
  67357. *
  67358. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  67359. *
  67360. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  67361. */
  67362. static readonly QUALITY_HIGH: number;
  67363. /**
  67364. * Reserved for PCF and PCSS
  67365. * Good tradeoff for quality/perf cross devices
  67366. *
  67367. * Execute PCF on a 3*3 kernel.
  67368. *
  67369. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  67370. */
  67371. static readonly QUALITY_MEDIUM: number;
  67372. /**
  67373. * Reserved for PCF and PCSS
  67374. * The lowest quality but the fastest.
  67375. *
  67376. * Execute PCF on a 1*1 kernel.
  67377. *
  67378. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  67379. */
  67380. static readonly QUALITY_LOW: number;
  67381. /** Gets or sets the custom shader name to use */
  67382. customShaderOptions: ICustomShaderOptions;
  67383. /**
  67384. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  67385. */
  67386. onBeforeShadowMapRenderObservable: Observable<Effect>;
  67387. /**
  67388. * Observable triggered before a mesh is rendered in the shadow map.
  67389. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  67390. */
  67391. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  67392. private _bias;
  67393. /**
  67394. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  67395. */
  67396. /**
  67397. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  67398. */
  67399. bias: number;
  67400. private _normalBias;
  67401. /**
  67402. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  67403. */
  67404. /**
  67405. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  67406. */
  67407. normalBias: number;
  67408. private _blurBoxOffset;
  67409. /**
  67410. * Gets the blur box offset: offset applied during the blur pass.
  67411. * Only useful if useKernelBlur = false
  67412. */
  67413. /**
  67414. * Sets the blur box offset: offset applied during the blur pass.
  67415. * Only useful if useKernelBlur = false
  67416. */
  67417. blurBoxOffset: number;
  67418. private _blurScale;
  67419. /**
  67420. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  67421. * 2 means half of the size.
  67422. */
  67423. /**
  67424. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  67425. * 2 means half of the size.
  67426. */
  67427. blurScale: number;
  67428. private _blurKernel;
  67429. /**
  67430. * Gets the blur kernel: kernel size of the blur pass.
  67431. * Only useful if useKernelBlur = true
  67432. */
  67433. /**
  67434. * Sets the blur kernel: kernel size of the blur pass.
  67435. * Only useful if useKernelBlur = true
  67436. */
  67437. blurKernel: number;
  67438. private _useKernelBlur;
  67439. /**
  67440. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  67441. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  67442. */
  67443. /**
  67444. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  67445. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  67446. */
  67447. useKernelBlur: boolean;
  67448. private _depthScale;
  67449. /**
  67450. * Gets the depth scale used in ESM mode.
  67451. */
  67452. /**
  67453. * Sets the depth scale used in ESM mode.
  67454. * This can override the scale stored on the light.
  67455. */
  67456. depthScale: number;
  67457. private _filter;
  67458. /**
  67459. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  67460. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  67461. */
  67462. /**
  67463. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  67464. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  67465. */
  67466. filter: number;
  67467. /**
  67468. * Gets if the current filter is set to Poisson Sampling.
  67469. */
  67470. /**
  67471. * Sets the current filter to Poisson Sampling.
  67472. */
  67473. usePoissonSampling: boolean;
  67474. /**
  67475. * Gets if the current filter is set to ESM.
  67476. */
  67477. /**
  67478. * Sets the current filter is to ESM.
  67479. */
  67480. useExponentialShadowMap: boolean;
  67481. /**
  67482. * Gets if the current filter is set to filtered ESM.
  67483. */
  67484. /**
  67485. * Gets if the current filter is set to filtered ESM.
  67486. */
  67487. useBlurExponentialShadowMap: boolean;
  67488. /**
  67489. * Gets if the current filter is set to "close ESM" (using the inverse of the
  67490. * exponential to prevent steep falloff artifacts).
  67491. */
  67492. /**
  67493. * Sets the current filter to "close ESM" (using the inverse of the
  67494. * exponential to prevent steep falloff artifacts).
  67495. */
  67496. useCloseExponentialShadowMap: boolean;
  67497. /**
  67498. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  67499. * exponential to prevent steep falloff artifacts).
  67500. */
  67501. /**
  67502. * Sets the current filter to filtered "close ESM" (using the inverse of the
  67503. * exponential to prevent steep falloff artifacts).
  67504. */
  67505. useBlurCloseExponentialShadowMap: boolean;
  67506. /**
  67507. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  67508. */
  67509. /**
  67510. * Sets the current filter to "PCF" (percentage closer filtering).
  67511. */
  67512. usePercentageCloserFiltering: boolean;
  67513. private _filteringQuality;
  67514. /**
  67515. * Gets the PCF or PCSS Quality.
  67516. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  67517. */
  67518. /**
  67519. * Sets the PCF or PCSS Quality.
  67520. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  67521. */
  67522. filteringQuality: number;
  67523. /**
  67524. * Gets if the current filter is set to "PCSS" (contact hardening).
  67525. */
  67526. /**
  67527. * Sets the current filter to "PCSS" (contact hardening).
  67528. */
  67529. useContactHardeningShadow: boolean;
  67530. private _contactHardeningLightSizeUVRatio;
  67531. /**
  67532. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  67533. * Using a ratio helps keeping shape stability independently of the map size.
  67534. *
  67535. * It does not account for the light projection as it was having too much
  67536. * instability during the light setup or during light position changes.
  67537. *
  67538. * Only valid if useContactHardeningShadow is true.
  67539. */
  67540. /**
  67541. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  67542. * Using a ratio helps keeping shape stability independently of the map size.
  67543. *
  67544. * It does not account for the light projection as it was having too much
  67545. * instability during the light setup or during light position changes.
  67546. *
  67547. * Only valid if useContactHardeningShadow is true.
  67548. */
  67549. contactHardeningLightSizeUVRatio: number;
  67550. private _darkness;
  67551. /**
  67552. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  67553. * 0 means strongest and 1 would means no shadow.
  67554. * @returns the darkness.
  67555. */
  67556. getDarkness(): number;
  67557. /**
  67558. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  67559. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  67560. * @returns the shadow generator allowing fluent coding.
  67561. */
  67562. setDarkness(darkness: number): ShadowGenerator;
  67563. private _transparencyShadow;
  67564. /**
  67565. * Sets the ability to have transparent shadow (boolean).
  67566. * @param transparent True if transparent else False
  67567. * @returns the shadow generator allowing fluent coding
  67568. */
  67569. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  67570. private _shadowMap;
  67571. private _shadowMap2;
  67572. /**
  67573. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  67574. * @returns The render target texture if present otherwise, null
  67575. */
  67576. getShadowMap(): Nullable<RenderTargetTexture>;
  67577. /**
  67578. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  67579. * @returns The render target texture if the shadow map is present otherwise, null
  67580. */
  67581. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  67582. /**
  67583. * Helper function to add a mesh and its descendants to the list of shadow casters.
  67584. * @param mesh Mesh to add
  67585. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  67586. * @returns the Shadow Generator itself
  67587. */
  67588. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  67589. /**
  67590. * Helper function to remove a mesh and its descendants from the list of shadow casters
  67591. * @param mesh Mesh to remove
  67592. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  67593. * @returns the Shadow Generator itself
  67594. */
  67595. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  67596. /**
  67597. * Controls the extent to which the shadows fade out at the edge of the frustum
  67598. * Used only by directionals and spots
  67599. */
  67600. frustumEdgeFalloff: number;
  67601. private _light;
  67602. /**
  67603. * Returns the associated light object.
  67604. * @returns the light generating the shadow
  67605. */
  67606. getLight(): IShadowLight;
  67607. /**
  67608. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  67609. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  67610. * It might on the other hand introduce peter panning.
  67611. */
  67612. forceBackFacesOnly: boolean;
  67613. private _scene;
  67614. private _lightDirection;
  67615. private _effect;
  67616. private _viewMatrix;
  67617. private _projectionMatrix;
  67618. private _transformMatrix;
  67619. private _cachedPosition;
  67620. private _cachedDirection;
  67621. private _cachedDefines;
  67622. private _currentRenderID;
  67623. private _boxBlurPostprocess;
  67624. private _kernelBlurXPostprocess;
  67625. private _kernelBlurYPostprocess;
  67626. private _blurPostProcesses;
  67627. private _mapSize;
  67628. private _currentFaceIndex;
  67629. private _currentFaceIndexCache;
  67630. private _textureType;
  67631. private _defaultTextureMatrix;
  67632. /** @hidden */
  67633. static _SceneComponentInitialization: (scene: Scene) => void;
  67634. /**
  67635. * Creates a ShadowGenerator object.
  67636. * A ShadowGenerator is the required tool to use the shadows.
  67637. * Each light casting shadows needs to use its own ShadowGenerator.
  67638. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  67639. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  67640. * @param light The light object generating the shadows.
  67641. * @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.
  67642. */
  67643. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  67644. private _initializeGenerator;
  67645. private _initializeShadowMap;
  67646. private _initializeBlurRTTAndPostProcesses;
  67647. private _renderForShadowMap;
  67648. private _renderSubMeshForShadowMap;
  67649. private _applyFilterValues;
  67650. /**
  67651. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67652. * @param onCompiled Callback triggered at the and of the effects compilation
  67653. * @param options Sets of optional options forcing the compilation with different modes
  67654. */
  67655. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  67656. useInstances: boolean;
  67657. }>): void;
  67658. /**
  67659. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67660. * @param options Sets of optional options forcing the compilation with different modes
  67661. * @returns A promise that resolves when the compilation completes
  67662. */
  67663. forceCompilationAsync(options?: Partial<{
  67664. useInstances: boolean;
  67665. }>): Promise<void>;
  67666. /**
  67667. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  67668. * @param subMesh The submesh we want to render in the shadow map
  67669. * @param useInstances Defines wether will draw in the map using instances
  67670. * @returns true if ready otherwise, false
  67671. */
  67672. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67673. /**
  67674. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  67675. * @param defines Defines of the material we want to update
  67676. * @param lightIndex Index of the light in the enabled light list of the material
  67677. */
  67678. prepareDefines(defines: any, lightIndex: number): void;
  67679. /**
  67680. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  67681. * defined in the generator but impacting the effect).
  67682. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  67683. * @param effect The effect we are binfing the information for
  67684. */
  67685. bindShadowLight(lightIndex: string, effect: Effect): void;
  67686. /**
  67687. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  67688. * (eq to shadow prjection matrix * light transform matrix)
  67689. * @returns The transform matrix used to create the shadow map
  67690. */
  67691. getTransformMatrix(): Matrix;
  67692. /**
  67693. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  67694. * Cube and 2D textures for instance.
  67695. */
  67696. recreateShadowMap(): void;
  67697. private _disposeBlurPostProcesses;
  67698. private _disposeRTTandPostProcesses;
  67699. /**
  67700. * Disposes the ShadowGenerator.
  67701. * Returns nothing.
  67702. */
  67703. dispose(): void;
  67704. /**
  67705. * Serializes the shadow generator setup to a json object.
  67706. * @returns The serialized JSON object
  67707. */
  67708. serialize(): any;
  67709. /**
  67710. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  67711. * @param parsedShadowGenerator The JSON object to parse
  67712. * @param scene The scene to create the shadow map for
  67713. * @returns The parsed shadow generator
  67714. */
  67715. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  67716. }
  67717. }
  67718. declare module BABYLON {
  67719. /**
  67720. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  67721. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  67722. * 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.
  67723. */
  67724. export abstract class Light extends Node {
  67725. /**
  67726. * Falloff Default: light is falling off following the material specification:
  67727. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  67728. */
  67729. static readonly FALLOFF_DEFAULT: number;
  67730. /**
  67731. * Falloff Physical: light is falling off following the inverse squared distance law.
  67732. */
  67733. static readonly FALLOFF_PHYSICAL: number;
  67734. /**
  67735. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  67736. * to enhance interoperability with other engines.
  67737. */
  67738. static readonly FALLOFF_GLTF: number;
  67739. /**
  67740. * Falloff Standard: light is falling off like in the standard material
  67741. * to enhance interoperability with other materials.
  67742. */
  67743. static readonly FALLOFF_STANDARD: number;
  67744. /**
  67745. * If every light affecting the material is in this lightmapMode,
  67746. * material.lightmapTexture adds or multiplies
  67747. * (depends on material.useLightmapAsShadowmap)
  67748. * after every other light calculations.
  67749. */
  67750. static readonly LIGHTMAP_DEFAULT: number;
  67751. /**
  67752. * material.lightmapTexture as only diffuse lighting from this light
  67753. * adds only specular lighting from this light
  67754. * adds dynamic shadows
  67755. */
  67756. static readonly LIGHTMAP_SPECULAR: number;
  67757. /**
  67758. * material.lightmapTexture as only lighting
  67759. * no light calculation from this light
  67760. * only adds dynamic shadows from this light
  67761. */
  67762. static readonly LIGHTMAP_SHADOWSONLY: number;
  67763. /**
  67764. * Each light type uses the default quantity according to its type:
  67765. * point/spot lights use luminous intensity
  67766. * directional lights use illuminance
  67767. */
  67768. static readonly INTENSITYMODE_AUTOMATIC: number;
  67769. /**
  67770. * lumen (lm)
  67771. */
  67772. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  67773. /**
  67774. * candela (lm/sr)
  67775. */
  67776. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  67777. /**
  67778. * lux (lm/m^2)
  67779. */
  67780. static readonly INTENSITYMODE_ILLUMINANCE: number;
  67781. /**
  67782. * nit (cd/m^2)
  67783. */
  67784. static readonly INTENSITYMODE_LUMINANCE: number;
  67785. /**
  67786. * Light type const id of the point light.
  67787. */
  67788. static readonly LIGHTTYPEID_POINTLIGHT: number;
  67789. /**
  67790. * Light type const id of the directional light.
  67791. */
  67792. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  67793. /**
  67794. * Light type const id of the spot light.
  67795. */
  67796. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  67797. /**
  67798. * Light type const id of the hemispheric light.
  67799. */
  67800. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  67801. /**
  67802. * Diffuse gives the basic color to an object.
  67803. */
  67804. diffuse: Color3;
  67805. /**
  67806. * Specular produces a highlight color on an object.
  67807. * Note: This is note affecting PBR materials.
  67808. */
  67809. specular: Color3;
  67810. /**
  67811. * Defines the falloff type for this light. This lets overrriding how punctual light are
  67812. * falling off base on range or angle.
  67813. * This can be set to any values in Light.FALLOFF_x.
  67814. *
  67815. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  67816. * other types of materials.
  67817. */
  67818. falloffType: number;
  67819. /**
  67820. * Strength of the light.
  67821. * Note: By default it is define in the framework own unit.
  67822. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  67823. */
  67824. intensity: number;
  67825. private _range;
  67826. protected _inverseSquaredRange: number;
  67827. /**
  67828. * Defines how far from the source the light is impacting in scene units.
  67829. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  67830. */
  67831. /**
  67832. * Defines how far from the source the light is impacting in scene units.
  67833. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  67834. */
  67835. range: number;
  67836. /**
  67837. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  67838. * of light.
  67839. */
  67840. private _photometricScale;
  67841. private _intensityMode;
  67842. /**
  67843. * Gets the photometric scale used to interpret the intensity.
  67844. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  67845. */
  67846. /**
  67847. * Sets the photometric scale used to interpret the intensity.
  67848. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  67849. */
  67850. intensityMode: number;
  67851. private _radius;
  67852. /**
  67853. * Gets the light radius used by PBR Materials to simulate soft area lights.
  67854. */
  67855. /**
  67856. * sets the light radius used by PBR Materials to simulate soft area lights.
  67857. */
  67858. radius: number;
  67859. private _renderPriority;
  67860. /**
  67861. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  67862. * exceeding the number allowed of the materials.
  67863. */
  67864. renderPriority: number;
  67865. private _shadowEnabled;
  67866. /**
  67867. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  67868. * the current shadow generator.
  67869. */
  67870. /**
  67871. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  67872. * the current shadow generator.
  67873. */
  67874. shadowEnabled: boolean;
  67875. private _includedOnlyMeshes;
  67876. /**
  67877. * Gets the only meshes impacted by this light.
  67878. */
  67879. /**
  67880. * Sets the only meshes impacted by this light.
  67881. */
  67882. includedOnlyMeshes: AbstractMesh[];
  67883. private _excludedMeshes;
  67884. /**
  67885. * Gets the meshes not impacted by this light.
  67886. */
  67887. /**
  67888. * Sets the meshes not impacted by this light.
  67889. */
  67890. excludedMeshes: AbstractMesh[];
  67891. private _excludeWithLayerMask;
  67892. /**
  67893. * Gets the layer id use to find what meshes are not impacted by the light.
  67894. * Inactive if 0
  67895. */
  67896. /**
  67897. * Sets the layer id use to find what meshes are not impacted by the light.
  67898. * Inactive if 0
  67899. */
  67900. excludeWithLayerMask: number;
  67901. private _includeOnlyWithLayerMask;
  67902. /**
  67903. * Gets the layer id use to find what meshes are impacted by the light.
  67904. * Inactive if 0
  67905. */
  67906. /**
  67907. * Sets the layer id use to find what meshes are impacted by the light.
  67908. * Inactive if 0
  67909. */
  67910. includeOnlyWithLayerMask: number;
  67911. private _lightmapMode;
  67912. /**
  67913. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  67914. */
  67915. /**
  67916. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  67917. */
  67918. lightmapMode: number;
  67919. /**
  67920. * Shadow generator associted to the light.
  67921. * @hidden Internal use only.
  67922. */
  67923. _shadowGenerator: Nullable<IShadowGenerator>;
  67924. /**
  67925. * @hidden Internal use only.
  67926. */
  67927. _excludedMeshesIds: string[];
  67928. /**
  67929. * @hidden Internal use only.
  67930. */
  67931. _includedOnlyMeshesIds: string[];
  67932. /**
  67933. * The current light unifom buffer.
  67934. * @hidden Internal use only.
  67935. */
  67936. _uniformBuffer: UniformBuffer;
  67937. /**
  67938. * Creates a Light object in the scene.
  67939. * Documentation : https://doc.babylonjs.com/babylon101/lights
  67940. * @param name The firendly name of the light
  67941. * @param scene The scene the light belongs too
  67942. */
  67943. constructor(name: string, scene: Scene);
  67944. protected abstract _buildUniformLayout(): void;
  67945. /**
  67946. * Sets the passed Effect "effect" with the Light information.
  67947. * @param effect The effect to update
  67948. * @param lightIndex The index of the light in the effect to update
  67949. * @returns The light
  67950. */
  67951. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  67952. /**
  67953. * Returns the string "Light".
  67954. * @returns the class name
  67955. */
  67956. getClassName(): string;
  67957. /** @hidden */
  67958. readonly _isLight: boolean;
  67959. /**
  67960. * Converts the light information to a readable string for debug purpose.
  67961. * @param fullDetails Supports for multiple levels of logging within scene loading
  67962. * @returns the human readable light info
  67963. */
  67964. toString(fullDetails?: boolean): string;
  67965. /** @hidden */
  67966. protected _syncParentEnabledState(): void;
  67967. /**
  67968. * Set the enabled state of this node.
  67969. * @param value - the new enabled state
  67970. */
  67971. setEnabled(value: boolean): void;
  67972. /**
  67973. * Returns the Light associated shadow generator if any.
  67974. * @return the associated shadow generator.
  67975. */
  67976. getShadowGenerator(): Nullable<IShadowGenerator>;
  67977. /**
  67978. * Returns a Vector3, the absolute light position in the World.
  67979. * @returns the world space position of the light
  67980. */
  67981. getAbsolutePosition(): Vector3;
  67982. /**
  67983. * Specifies if the light will affect the passed mesh.
  67984. * @param mesh The mesh to test against the light
  67985. * @return true the mesh is affected otherwise, false.
  67986. */
  67987. canAffectMesh(mesh: AbstractMesh): boolean;
  67988. /**
  67989. * Sort function to order lights for rendering.
  67990. * @param a First Light object to compare to second.
  67991. * @param b Second Light object to compare first.
  67992. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  67993. */
  67994. static CompareLightsPriority(a: Light, b: Light): number;
  67995. /**
  67996. * Releases resources associated with this node.
  67997. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  67998. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  67999. */
  68000. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  68001. /**
  68002. * Returns the light type ID (integer).
  68003. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  68004. */
  68005. getTypeID(): number;
  68006. /**
  68007. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  68008. * @returns the scaled intensity in intensity mode unit
  68009. */
  68010. getScaledIntensity(): number;
  68011. /**
  68012. * Returns a new Light object, named "name", from the current one.
  68013. * @param name The name of the cloned light
  68014. * @returns the new created light
  68015. */
  68016. clone(name: string): Nullable<Light>;
  68017. /**
  68018. * Serializes the current light into a Serialization object.
  68019. * @returns the serialized object.
  68020. */
  68021. serialize(): any;
  68022. /**
  68023. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  68024. * This new light is named "name" and added to the passed scene.
  68025. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  68026. * @param name The friendly name of the light
  68027. * @param scene The scene the new light will belong to
  68028. * @returns the constructor function
  68029. */
  68030. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  68031. /**
  68032. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  68033. * @param parsedLight The JSON representation of the light
  68034. * @param scene The scene to create the parsed light in
  68035. * @returns the created light after parsing
  68036. */
  68037. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  68038. private _hookArrayForExcluded;
  68039. private _hookArrayForIncludedOnly;
  68040. private _resyncMeshes;
  68041. /**
  68042. * Forces the meshes to update their light related information in their rendering used effects
  68043. * @hidden Internal Use Only
  68044. */
  68045. _markMeshesAsLightDirty(): void;
  68046. /**
  68047. * Recomputes the cached photometric scale if needed.
  68048. */
  68049. private _computePhotometricScale;
  68050. /**
  68051. * Returns the Photometric Scale according to the light type and intensity mode.
  68052. */
  68053. private _getPhotometricScale;
  68054. /**
  68055. * Reorder the light in the scene according to their defined priority.
  68056. * @hidden Internal Use Only
  68057. */
  68058. _reorderLightsInScene(): void;
  68059. /**
  68060. * Prepares the list of defines specific to the light type.
  68061. * @param defines the list of defines
  68062. * @param lightIndex defines the index of the light for the effect
  68063. */
  68064. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  68065. }
  68066. }
  68067. declare module BABYLON {
  68068. /**
  68069. * Interface used to define Action
  68070. */
  68071. export interface IAction {
  68072. /**
  68073. * Trigger for the action
  68074. */
  68075. trigger: number;
  68076. /** Options of the trigger */
  68077. triggerOptions: any;
  68078. /**
  68079. * Gets the trigger parameters
  68080. * @returns the trigger parameters
  68081. */
  68082. getTriggerParameter(): any;
  68083. /**
  68084. * Internal only - executes current action event
  68085. * @hidden
  68086. */
  68087. _executeCurrent(evt?: ActionEvent): void;
  68088. /**
  68089. * Serialize placeholder for child classes
  68090. * @param parent of child
  68091. * @returns the serialized object
  68092. */
  68093. serialize(parent: any): any;
  68094. /**
  68095. * Internal only
  68096. * @hidden
  68097. */
  68098. _prepare(): void;
  68099. /**
  68100. * Internal only - manager for action
  68101. * @hidden
  68102. */
  68103. _actionManager: AbstractActionManager;
  68104. }
  68105. /**
  68106. * The action to be carried out following a trigger
  68107. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  68108. */
  68109. export class Action implements IAction {
  68110. /** the trigger, with or without parameters, for the action */
  68111. triggerOptions: any;
  68112. /**
  68113. * Trigger for the action
  68114. */
  68115. trigger: number;
  68116. /**
  68117. * Internal only - manager for action
  68118. * @hidden
  68119. */
  68120. _actionManager: ActionManager;
  68121. private _nextActiveAction;
  68122. private _child;
  68123. private _condition?;
  68124. private _triggerParameter;
  68125. /**
  68126. * An event triggered prior to action being executed.
  68127. */
  68128. onBeforeExecuteObservable: Observable<Action>;
  68129. /**
  68130. * Creates a new Action
  68131. * @param triggerOptions the trigger, with or without parameters, for the action
  68132. * @param condition an optional determinant of action
  68133. */
  68134. constructor(
  68135. /** the trigger, with or without parameters, for the action */
  68136. triggerOptions: any, condition?: Condition);
  68137. /**
  68138. * Internal only
  68139. * @hidden
  68140. */
  68141. _prepare(): void;
  68142. /**
  68143. * Gets the trigger parameters
  68144. * @returns the trigger parameters
  68145. */
  68146. getTriggerParameter(): any;
  68147. /**
  68148. * Internal only - executes current action event
  68149. * @hidden
  68150. */
  68151. _executeCurrent(evt?: ActionEvent): void;
  68152. /**
  68153. * Execute placeholder for child classes
  68154. * @param evt optional action event
  68155. */
  68156. execute(evt?: ActionEvent): void;
  68157. /**
  68158. * Skips to next active action
  68159. */
  68160. skipToNextActiveAction(): void;
  68161. /**
  68162. * Adds action to chain of actions, may be a DoNothingAction
  68163. * @param action defines the next action to execute
  68164. * @returns The action passed in
  68165. * @see https://www.babylonjs-playground.com/#1T30HR#0
  68166. */
  68167. then(action: Action): Action;
  68168. /**
  68169. * Internal only
  68170. * @hidden
  68171. */
  68172. _getProperty(propertyPath: string): string;
  68173. /**
  68174. * Internal only
  68175. * @hidden
  68176. */
  68177. _getEffectiveTarget(target: any, propertyPath: string): any;
  68178. /**
  68179. * Serialize placeholder for child classes
  68180. * @param parent of child
  68181. * @returns the serialized object
  68182. */
  68183. serialize(parent: any): any;
  68184. /**
  68185. * Internal only called by serialize
  68186. * @hidden
  68187. */
  68188. protected _serialize(serializedAction: any, parent?: any): any;
  68189. /**
  68190. * Internal only
  68191. * @hidden
  68192. */
  68193. static _SerializeValueAsString: (value: any) => string;
  68194. /**
  68195. * Internal only
  68196. * @hidden
  68197. */
  68198. static _GetTargetProperty: (target: Scene | Node) => {
  68199. name: string;
  68200. targetType: string;
  68201. value: string;
  68202. };
  68203. }
  68204. }
  68205. declare module BABYLON {
  68206. /**
  68207. * A Condition applied to an Action
  68208. */
  68209. export class Condition {
  68210. /**
  68211. * Internal only - manager for action
  68212. * @hidden
  68213. */
  68214. _actionManager: ActionManager;
  68215. /**
  68216. * Internal only
  68217. * @hidden
  68218. */
  68219. _evaluationId: number;
  68220. /**
  68221. * Internal only
  68222. * @hidden
  68223. */
  68224. _currentResult: boolean;
  68225. /**
  68226. * Creates a new Condition
  68227. * @param actionManager the manager of the action the condition is applied to
  68228. */
  68229. constructor(actionManager: ActionManager);
  68230. /**
  68231. * Check if the current condition is valid
  68232. * @returns a boolean
  68233. */
  68234. isValid(): boolean;
  68235. /**
  68236. * Internal only
  68237. * @hidden
  68238. */
  68239. _getProperty(propertyPath: string): string;
  68240. /**
  68241. * Internal only
  68242. * @hidden
  68243. */
  68244. _getEffectiveTarget(target: any, propertyPath: string): any;
  68245. /**
  68246. * Serialize placeholder for child classes
  68247. * @returns the serialized object
  68248. */
  68249. serialize(): any;
  68250. /**
  68251. * Internal only
  68252. * @hidden
  68253. */
  68254. protected _serialize(serializedCondition: any): any;
  68255. }
  68256. /**
  68257. * Defines specific conditional operators as extensions of Condition
  68258. */
  68259. export class ValueCondition extends Condition {
  68260. /** path to specify the property of the target the conditional operator uses */
  68261. propertyPath: string;
  68262. /** the value compared by the conditional operator against the current value of the property */
  68263. value: any;
  68264. /** the conditional operator, default ValueCondition.IsEqual */
  68265. operator: number;
  68266. /**
  68267. * Internal only
  68268. * @hidden
  68269. */
  68270. private static _IsEqual;
  68271. /**
  68272. * Internal only
  68273. * @hidden
  68274. */
  68275. private static _IsDifferent;
  68276. /**
  68277. * Internal only
  68278. * @hidden
  68279. */
  68280. private static _IsGreater;
  68281. /**
  68282. * Internal only
  68283. * @hidden
  68284. */
  68285. private static _IsLesser;
  68286. /**
  68287. * returns the number for IsEqual
  68288. */
  68289. static readonly IsEqual: number;
  68290. /**
  68291. * Returns the number for IsDifferent
  68292. */
  68293. static readonly IsDifferent: number;
  68294. /**
  68295. * Returns the number for IsGreater
  68296. */
  68297. static readonly IsGreater: number;
  68298. /**
  68299. * Returns the number for IsLesser
  68300. */
  68301. static readonly IsLesser: number;
  68302. /**
  68303. * Internal only The action manager for the condition
  68304. * @hidden
  68305. */
  68306. _actionManager: ActionManager;
  68307. /**
  68308. * Internal only
  68309. * @hidden
  68310. */
  68311. private _target;
  68312. /**
  68313. * Internal only
  68314. * @hidden
  68315. */
  68316. private _effectiveTarget;
  68317. /**
  68318. * Internal only
  68319. * @hidden
  68320. */
  68321. private _property;
  68322. /**
  68323. * Creates a new ValueCondition
  68324. * @param actionManager manager for the action the condition applies to
  68325. * @param target for the action
  68326. * @param propertyPath path to specify the property of the target the conditional operator uses
  68327. * @param value the value compared by the conditional operator against the current value of the property
  68328. * @param operator the conditional operator, default ValueCondition.IsEqual
  68329. */
  68330. constructor(actionManager: ActionManager, target: any,
  68331. /** path to specify the property of the target the conditional operator uses */
  68332. propertyPath: string,
  68333. /** the value compared by the conditional operator against the current value of the property */
  68334. value: any,
  68335. /** the conditional operator, default ValueCondition.IsEqual */
  68336. operator?: number);
  68337. /**
  68338. * Compares the given value with the property value for the specified conditional operator
  68339. * @returns the result of the comparison
  68340. */
  68341. isValid(): boolean;
  68342. /**
  68343. * Serialize the ValueCondition into a JSON compatible object
  68344. * @returns serialization object
  68345. */
  68346. serialize(): any;
  68347. /**
  68348. * Gets the name of the conditional operator for the ValueCondition
  68349. * @param operator the conditional operator
  68350. * @returns the name
  68351. */
  68352. static GetOperatorName(operator: number): string;
  68353. }
  68354. /**
  68355. * Defines a predicate condition as an extension of Condition
  68356. */
  68357. export class PredicateCondition extends Condition {
  68358. /** defines the predicate function used to validate the condition */
  68359. predicate: () => boolean;
  68360. /**
  68361. * Internal only - manager for action
  68362. * @hidden
  68363. */
  68364. _actionManager: ActionManager;
  68365. /**
  68366. * Creates a new PredicateCondition
  68367. * @param actionManager manager for the action the condition applies to
  68368. * @param predicate defines the predicate function used to validate the condition
  68369. */
  68370. constructor(actionManager: ActionManager,
  68371. /** defines the predicate function used to validate the condition */
  68372. predicate: () => boolean);
  68373. /**
  68374. * @returns the validity of the predicate condition
  68375. */
  68376. isValid(): boolean;
  68377. }
  68378. /**
  68379. * Defines a state condition as an extension of Condition
  68380. */
  68381. export class StateCondition extends Condition {
  68382. /** Value to compare with target state */
  68383. value: string;
  68384. /**
  68385. * Internal only - manager for action
  68386. * @hidden
  68387. */
  68388. _actionManager: ActionManager;
  68389. /**
  68390. * Internal only
  68391. * @hidden
  68392. */
  68393. private _target;
  68394. /**
  68395. * Creates a new StateCondition
  68396. * @param actionManager manager for the action the condition applies to
  68397. * @param target of the condition
  68398. * @param value to compare with target state
  68399. */
  68400. constructor(actionManager: ActionManager, target: any,
  68401. /** Value to compare with target state */
  68402. value: string);
  68403. /**
  68404. * Gets a boolean indicating if the current condition is met
  68405. * @returns the validity of the state
  68406. */
  68407. isValid(): boolean;
  68408. /**
  68409. * Serialize the StateCondition into a JSON compatible object
  68410. * @returns serialization object
  68411. */
  68412. serialize(): any;
  68413. }
  68414. }
  68415. declare module BABYLON {
  68416. /**
  68417. * This defines an action responsible to toggle a boolean once triggered.
  68418. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68419. */
  68420. export class SwitchBooleanAction extends Action {
  68421. /**
  68422. * The path to the boolean property in the target object
  68423. */
  68424. propertyPath: string;
  68425. private _target;
  68426. private _effectiveTarget;
  68427. private _property;
  68428. /**
  68429. * Instantiate the action
  68430. * @param triggerOptions defines the trigger options
  68431. * @param target defines the object containing the boolean
  68432. * @param propertyPath defines the path to the boolean property in the target object
  68433. * @param condition defines the trigger related conditions
  68434. */
  68435. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  68436. /** @hidden */
  68437. _prepare(): void;
  68438. /**
  68439. * Execute the action toggle the boolean value.
  68440. */
  68441. execute(): void;
  68442. /**
  68443. * Serializes the actions and its related information.
  68444. * @param parent defines the object to serialize in
  68445. * @returns the serialized object
  68446. */
  68447. serialize(parent: any): any;
  68448. }
  68449. /**
  68450. * This defines an action responsible to set a the state field of the target
  68451. * to a desired value once triggered.
  68452. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68453. */
  68454. export class SetStateAction extends Action {
  68455. /**
  68456. * The value to store in the state field.
  68457. */
  68458. value: string;
  68459. private _target;
  68460. /**
  68461. * Instantiate the action
  68462. * @param triggerOptions defines the trigger options
  68463. * @param target defines the object containing the state property
  68464. * @param value defines the value to store in the state field
  68465. * @param condition defines the trigger related conditions
  68466. */
  68467. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  68468. /**
  68469. * Execute the action and store the value on the target state property.
  68470. */
  68471. execute(): void;
  68472. /**
  68473. * Serializes the actions and its related information.
  68474. * @param parent defines the object to serialize in
  68475. * @returns the serialized object
  68476. */
  68477. serialize(parent: any): any;
  68478. }
  68479. /**
  68480. * This defines an action responsible to set a property of the target
  68481. * to a desired value once triggered.
  68482. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68483. */
  68484. export class SetValueAction extends Action {
  68485. /**
  68486. * The path of the property to set in the target.
  68487. */
  68488. propertyPath: string;
  68489. /**
  68490. * The value to set in the property
  68491. */
  68492. value: any;
  68493. private _target;
  68494. private _effectiveTarget;
  68495. private _property;
  68496. /**
  68497. * Instantiate the action
  68498. * @param triggerOptions defines the trigger options
  68499. * @param target defines the object containing the property
  68500. * @param propertyPath defines the path of the property to set in the target
  68501. * @param value defines the value to set in the property
  68502. * @param condition defines the trigger related conditions
  68503. */
  68504. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  68505. /** @hidden */
  68506. _prepare(): void;
  68507. /**
  68508. * Execute the action and set the targetted property to the desired value.
  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. * This defines an action responsible to increment the target value
  68520. * to a desired value once triggered.
  68521. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68522. */
  68523. export class IncrementValueAction extends Action {
  68524. /**
  68525. * The path of the property to increment in the target.
  68526. */
  68527. propertyPath: string;
  68528. /**
  68529. * The value we should increment the property by.
  68530. */
  68531. value: any;
  68532. private _target;
  68533. private _effectiveTarget;
  68534. private _property;
  68535. /**
  68536. * Instantiate the action
  68537. * @param triggerOptions defines the trigger options
  68538. * @param target defines the object containing the property
  68539. * @param propertyPath defines the path of the property to increment in the target
  68540. * @param value defines the value value we should increment the property by
  68541. * @param condition defines the trigger related conditions
  68542. */
  68543. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  68544. /** @hidden */
  68545. _prepare(): void;
  68546. /**
  68547. * Execute the action and increment the target of the value amount.
  68548. */
  68549. execute(): void;
  68550. /**
  68551. * Serializes the actions and its related information.
  68552. * @param parent defines the object to serialize in
  68553. * @returns the serialized object
  68554. */
  68555. serialize(parent: any): any;
  68556. }
  68557. /**
  68558. * This defines an action responsible to start an animation once triggered.
  68559. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68560. */
  68561. export class PlayAnimationAction extends Action {
  68562. /**
  68563. * Where the animation should start (animation frame)
  68564. */
  68565. from: number;
  68566. /**
  68567. * Where the animation should stop (animation frame)
  68568. */
  68569. to: number;
  68570. /**
  68571. * Define if the animation should loop or stop after the first play.
  68572. */
  68573. loop?: boolean;
  68574. private _target;
  68575. /**
  68576. * Instantiate the action
  68577. * @param triggerOptions defines the trigger options
  68578. * @param target defines the target animation or animation name
  68579. * @param from defines from where the animation should start (animation frame)
  68580. * @param end defines where the animation should stop (animation frame)
  68581. * @param loop defines if the animation should loop or stop after the first play
  68582. * @param condition defines the trigger related conditions
  68583. */
  68584. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  68585. /** @hidden */
  68586. _prepare(): void;
  68587. /**
  68588. * Execute the action and play the animation.
  68589. */
  68590. execute(): void;
  68591. /**
  68592. * Serializes the actions and its related information.
  68593. * @param parent defines the object to serialize in
  68594. * @returns the serialized object
  68595. */
  68596. serialize(parent: any): any;
  68597. }
  68598. /**
  68599. * This defines an action responsible to stop an animation once triggered.
  68600. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68601. */
  68602. export class StopAnimationAction extends Action {
  68603. private _target;
  68604. /**
  68605. * Instantiate the action
  68606. * @param triggerOptions defines the trigger options
  68607. * @param target defines the target animation or animation name
  68608. * @param condition defines the trigger related conditions
  68609. */
  68610. constructor(triggerOptions: any, target: any, condition?: Condition);
  68611. /** @hidden */
  68612. _prepare(): void;
  68613. /**
  68614. * Execute the action and stop the animation.
  68615. */
  68616. execute(): void;
  68617. /**
  68618. * Serializes the actions and its related information.
  68619. * @param parent defines the object to serialize in
  68620. * @returns the serialized object
  68621. */
  68622. serialize(parent: any): any;
  68623. }
  68624. /**
  68625. * This defines an action responsible that does nothing once triggered.
  68626. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68627. */
  68628. export class DoNothingAction extends Action {
  68629. /**
  68630. * Instantiate the action
  68631. * @param triggerOptions defines the trigger options
  68632. * @param condition defines the trigger related conditions
  68633. */
  68634. constructor(triggerOptions?: any, condition?: Condition);
  68635. /**
  68636. * Execute the action and do nothing.
  68637. */
  68638. execute(): void;
  68639. /**
  68640. * Serializes the actions and its related information.
  68641. * @param parent defines the object to serialize in
  68642. * @returns the serialized object
  68643. */
  68644. serialize(parent: any): any;
  68645. }
  68646. /**
  68647. * This defines an action responsible to trigger several actions once triggered.
  68648. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68649. */
  68650. export class CombineAction extends Action {
  68651. /**
  68652. * The list of aggregated animations to run.
  68653. */
  68654. children: Action[];
  68655. /**
  68656. * Instantiate the action
  68657. * @param triggerOptions defines the trigger options
  68658. * @param children defines the list of aggregated animations to run
  68659. * @param condition defines the trigger related conditions
  68660. */
  68661. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  68662. /** @hidden */
  68663. _prepare(): void;
  68664. /**
  68665. * Execute the action and executes all the aggregated actions.
  68666. */
  68667. execute(evt: ActionEvent): void;
  68668. /**
  68669. * Serializes the actions and its related information.
  68670. * @param parent defines the object to serialize in
  68671. * @returns the serialized object
  68672. */
  68673. serialize(parent: any): any;
  68674. }
  68675. /**
  68676. * This defines an action responsible to run code (external event) once triggered.
  68677. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68678. */
  68679. export class ExecuteCodeAction extends Action {
  68680. /**
  68681. * The callback function to run.
  68682. */
  68683. func: (evt: ActionEvent) => void;
  68684. /**
  68685. * Instantiate the action
  68686. * @param triggerOptions defines the trigger options
  68687. * @param func defines the callback function to run
  68688. * @param condition defines the trigger related conditions
  68689. */
  68690. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  68691. /**
  68692. * Execute the action and run the attached code.
  68693. */
  68694. execute(evt: ActionEvent): void;
  68695. }
  68696. /**
  68697. * This defines an action responsible to set the parent property of the target once triggered.
  68698. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68699. */
  68700. export class SetParentAction extends Action {
  68701. private _parent;
  68702. private _target;
  68703. /**
  68704. * Instantiate the action
  68705. * @param triggerOptions defines the trigger options
  68706. * @param target defines the target containing the parent property
  68707. * @param parent defines from where the animation should start (animation frame)
  68708. * @param condition defines the trigger related conditions
  68709. */
  68710. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  68711. /** @hidden */
  68712. _prepare(): void;
  68713. /**
  68714. * Execute the action and set the parent property.
  68715. */
  68716. execute(): void;
  68717. /**
  68718. * Serializes the actions and its related information.
  68719. * @param parent defines the object to serialize in
  68720. * @returns the serialized object
  68721. */
  68722. serialize(parent: any): any;
  68723. }
  68724. }
  68725. declare module BABYLON {
  68726. /**
  68727. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  68728. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  68729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68730. */
  68731. export class ActionManager extends AbstractActionManager {
  68732. /**
  68733. * Nothing
  68734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68735. */
  68736. static readonly NothingTrigger: number;
  68737. /**
  68738. * On pick
  68739. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68740. */
  68741. static readonly OnPickTrigger: number;
  68742. /**
  68743. * On left pick
  68744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68745. */
  68746. static readonly OnLeftPickTrigger: number;
  68747. /**
  68748. * On right pick
  68749. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68750. */
  68751. static readonly OnRightPickTrigger: number;
  68752. /**
  68753. * On center pick
  68754. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68755. */
  68756. static readonly OnCenterPickTrigger: number;
  68757. /**
  68758. * On pick down
  68759. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68760. */
  68761. static readonly OnPickDownTrigger: number;
  68762. /**
  68763. * On double pick
  68764. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68765. */
  68766. static readonly OnDoublePickTrigger: number;
  68767. /**
  68768. * On pick up
  68769. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68770. */
  68771. static readonly OnPickUpTrigger: number;
  68772. /**
  68773. * On pick out.
  68774. * This trigger will only be raised if you also declared a OnPickDown
  68775. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68776. */
  68777. static readonly OnPickOutTrigger: number;
  68778. /**
  68779. * On long press
  68780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68781. */
  68782. static readonly OnLongPressTrigger: number;
  68783. /**
  68784. * On pointer over
  68785. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68786. */
  68787. static readonly OnPointerOverTrigger: number;
  68788. /**
  68789. * On pointer out
  68790. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68791. */
  68792. static readonly OnPointerOutTrigger: number;
  68793. /**
  68794. * On every frame
  68795. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68796. */
  68797. static readonly OnEveryFrameTrigger: number;
  68798. /**
  68799. * On intersection enter
  68800. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68801. */
  68802. static readonly OnIntersectionEnterTrigger: number;
  68803. /**
  68804. * On intersection exit
  68805. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68806. */
  68807. static readonly OnIntersectionExitTrigger: number;
  68808. /**
  68809. * On key down
  68810. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68811. */
  68812. static readonly OnKeyDownTrigger: number;
  68813. /**
  68814. * On key up
  68815. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68816. */
  68817. static readonly OnKeyUpTrigger: number;
  68818. private _scene;
  68819. /**
  68820. * Creates a new action manager
  68821. * @param scene defines the hosting scene
  68822. */
  68823. constructor(scene: Scene);
  68824. /**
  68825. * Releases all associated resources
  68826. */
  68827. dispose(): void;
  68828. /**
  68829. * Gets hosting scene
  68830. * @returns the hosting scene
  68831. */
  68832. getScene(): Scene;
  68833. /**
  68834. * Does this action manager handles actions of any of the given triggers
  68835. * @param triggers defines the triggers to be tested
  68836. * @return a boolean indicating whether one (or more) of the triggers is handled
  68837. */
  68838. hasSpecificTriggers(triggers: number[]): boolean;
  68839. /**
  68840. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  68841. * speed.
  68842. * @param triggerA defines the trigger to be tested
  68843. * @param triggerB defines the trigger to be tested
  68844. * @return a boolean indicating whether one (or more) of the triggers is handled
  68845. */
  68846. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  68847. /**
  68848. * Does this action manager handles actions of a given trigger
  68849. * @param trigger defines the trigger to be tested
  68850. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  68851. * @return whether the trigger is handled
  68852. */
  68853. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  68854. /**
  68855. * Does this action manager has pointer triggers
  68856. */
  68857. readonly hasPointerTriggers: boolean;
  68858. /**
  68859. * Does this action manager has pick triggers
  68860. */
  68861. readonly hasPickTriggers: boolean;
  68862. /**
  68863. * Registers an action to this action manager
  68864. * @param action defines the action to be registered
  68865. * @return the action amended (prepared) after registration
  68866. */
  68867. registerAction(action: IAction): Nullable<IAction>;
  68868. /**
  68869. * Unregisters an action to this action manager
  68870. * @param action defines the action to be unregistered
  68871. * @return a boolean indicating whether the action has been unregistered
  68872. */
  68873. unregisterAction(action: IAction): Boolean;
  68874. /**
  68875. * Process a specific trigger
  68876. * @param trigger defines the trigger to process
  68877. * @param evt defines the event details to be processed
  68878. */
  68879. processTrigger(trigger: number, evt?: IActionEvent): void;
  68880. /** @hidden */
  68881. _getEffectiveTarget(target: any, propertyPath: string): any;
  68882. /** @hidden */
  68883. _getProperty(propertyPath: string): string;
  68884. /**
  68885. * Serialize this manager to a JSON object
  68886. * @param name defines the property name to store this manager
  68887. * @returns a JSON representation of this manager
  68888. */
  68889. serialize(name: string): any;
  68890. /**
  68891. * Creates a new ActionManager from a JSON data
  68892. * @param parsedActions defines the JSON data to read from
  68893. * @param object defines the hosting mesh
  68894. * @param scene defines the hosting scene
  68895. */
  68896. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  68897. /**
  68898. * Get a trigger name by index
  68899. * @param trigger defines the trigger index
  68900. * @returns a trigger name
  68901. */
  68902. static GetTriggerName(trigger: number): string;
  68903. }
  68904. }
  68905. declare module BABYLON {
  68906. /**
  68907. * Class representing a ray with position and direction
  68908. */
  68909. export class Ray {
  68910. /** origin point */
  68911. origin: Vector3;
  68912. /** direction */
  68913. direction: Vector3;
  68914. /** length of the ray */
  68915. length: number;
  68916. private static readonly TmpVector3;
  68917. private _tmpRay;
  68918. /**
  68919. * Creates a new ray
  68920. * @param origin origin point
  68921. * @param direction direction
  68922. * @param length length of the ray
  68923. */
  68924. constructor(
  68925. /** origin point */
  68926. origin: Vector3,
  68927. /** direction */
  68928. direction: Vector3,
  68929. /** length of the ray */
  68930. length?: number);
  68931. /**
  68932. * Checks if the ray intersects a box
  68933. * @param minimum bound of the box
  68934. * @param maximum bound of the box
  68935. * @param intersectionTreshold extra extend to be added to the box in all direction
  68936. * @returns if the box was hit
  68937. */
  68938. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  68939. /**
  68940. * Checks if the ray intersects a box
  68941. * @param box the bounding box to check
  68942. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  68943. * @returns if the box was hit
  68944. */
  68945. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  68946. /**
  68947. * If the ray hits a sphere
  68948. * @param sphere the bounding sphere to check
  68949. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  68950. * @returns true if it hits the sphere
  68951. */
  68952. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  68953. /**
  68954. * If the ray hits a triange
  68955. * @param vertex0 triangle vertex
  68956. * @param vertex1 triangle vertex
  68957. * @param vertex2 triangle vertex
  68958. * @returns intersection information if hit
  68959. */
  68960. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  68961. /**
  68962. * Checks if ray intersects a plane
  68963. * @param plane the plane to check
  68964. * @returns the distance away it was hit
  68965. */
  68966. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  68967. /**
  68968. * Checks if ray intersects a mesh
  68969. * @param mesh the mesh to check
  68970. * @param fastCheck if only the bounding box should checked
  68971. * @returns picking info of the intersecton
  68972. */
  68973. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  68974. /**
  68975. * Checks if ray intersects a mesh
  68976. * @param meshes the meshes to check
  68977. * @param fastCheck if only the bounding box should checked
  68978. * @param results array to store result in
  68979. * @returns Array of picking infos
  68980. */
  68981. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  68982. private _comparePickingInfo;
  68983. private static smallnum;
  68984. private static rayl;
  68985. /**
  68986. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  68987. * @param sega the first point of the segment to test the intersection against
  68988. * @param segb the second point of the segment to test the intersection against
  68989. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  68990. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  68991. */
  68992. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  68993. /**
  68994. * Update the ray from viewport position
  68995. * @param x position
  68996. * @param y y position
  68997. * @param viewportWidth viewport width
  68998. * @param viewportHeight viewport height
  68999. * @param world world matrix
  69000. * @param view view matrix
  69001. * @param projection projection matrix
  69002. * @returns this ray updated
  69003. */
  69004. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  69005. /**
  69006. * Creates a ray with origin and direction of 0,0,0
  69007. * @returns the new ray
  69008. */
  69009. static Zero(): Ray;
  69010. /**
  69011. * Creates a new ray from screen space and viewport
  69012. * @param x position
  69013. * @param y y position
  69014. * @param viewportWidth viewport width
  69015. * @param viewportHeight viewport height
  69016. * @param world world matrix
  69017. * @param view view matrix
  69018. * @param projection projection matrix
  69019. * @returns new ray
  69020. */
  69021. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  69022. /**
  69023. * 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
  69024. * transformed to the given world matrix.
  69025. * @param origin The origin point
  69026. * @param end The end point
  69027. * @param world a matrix to transform the ray to. Default is the identity matrix.
  69028. * @returns the new ray
  69029. */
  69030. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  69031. /**
  69032. * Transforms a ray by a matrix
  69033. * @param ray ray to transform
  69034. * @param matrix matrix to apply
  69035. * @returns the resulting new ray
  69036. */
  69037. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  69038. /**
  69039. * Transforms a ray by a matrix
  69040. * @param ray ray to transform
  69041. * @param matrix matrix to apply
  69042. * @param result ray to store result in
  69043. */
  69044. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  69045. /**
  69046. * Unproject a ray from screen space to object space
  69047. * @param sourceX defines the screen space x coordinate to use
  69048. * @param sourceY defines the screen space y coordinate to use
  69049. * @param viewportWidth defines the current width of the viewport
  69050. * @param viewportHeight defines the current height of the viewport
  69051. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69052. * @param view defines the view matrix to use
  69053. * @param projection defines the projection matrix to use
  69054. */
  69055. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  69056. }
  69057. /**
  69058. * Type used to define predicate used to select faces when a mesh intersection is detected
  69059. */
  69060. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  69061. interface Scene {
  69062. /** @hidden */
  69063. _tempPickingRay: Nullable<Ray>;
  69064. /** @hidden */
  69065. _cachedRayForTransform: Ray;
  69066. /** @hidden */
  69067. _pickWithRayInverseMatrix: Matrix;
  69068. /** @hidden */
  69069. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  69070. /** @hidden */
  69071. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  69072. }
  69073. }
  69074. declare module BABYLON {
  69075. /**
  69076. * Groups all the scene component constants in one place to ease maintenance.
  69077. * @hidden
  69078. */
  69079. export class SceneComponentConstants {
  69080. static readonly NAME_EFFECTLAYER: string;
  69081. static readonly NAME_LAYER: string;
  69082. static readonly NAME_LENSFLARESYSTEM: string;
  69083. static readonly NAME_BOUNDINGBOXRENDERER: string;
  69084. static readonly NAME_PARTICLESYSTEM: string;
  69085. static readonly NAME_GAMEPAD: string;
  69086. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  69087. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  69088. static readonly NAME_DEPTHRENDERER: string;
  69089. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  69090. static readonly NAME_SPRITE: string;
  69091. static readonly NAME_OUTLINERENDERER: string;
  69092. static readonly NAME_PROCEDURALTEXTURE: string;
  69093. static readonly NAME_SHADOWGENERATOR: string;
  69094. static readonly NAME_OCTREE: string;
  69095. static readonly NAME_PHYSICSENGINE: string;
  69096. static readonly NAME_AUDIO: string;
  69097. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  69098. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  69099. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  69100. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  69101. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  69102. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  69103. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  69104. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  69105. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  69106. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  69107. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  69108. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  69109. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  69110. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  69111. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  69112. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  69113. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  69114. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  69115. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  69116. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  69117. static readonly STEP_AFTERRENDER_AUDIO: number;
  69118. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  69119. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  69120. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  69121. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  69122. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  69123. static readonly STEP_POINTERMOVE_SPRITE: number;
  69124. static readonly STEP_POINTERDOWN_SPRITE: number;
  69125. static readonly STEP_POINTERUP_SPRITE: number;
  69126. }
  69127. /**
  69128. * This represents a scene component.
  69129. *
  69130. * This is used to decouple the dependency the scene is having on the different workloads like
  69131. * layers, post processes...
  69132. */
  69133. export interface ISceneComponent {
  69134. /**
  69135. * The name of the component. Each component must have a unique name.
  69136. */
  69137. name: string;
  69138. /**
  69139. * The scene the component belongs to.
  69140. */
  69141. scene: Scene;
  69142. /**
  69143. * Register the component to one instance of a scene.
  69144. */
  69145. register(): void;
  69146. /**
  69147. * Rebuilds the elements related to this component in case of
  69148. * context lost for instance.
  69149. */
  69150. rebuild(): void;
  69151. /**
  69152. * Disposes the component and the associated ressources.
  69153. */
  69154. dispose(): void;
  69155. }
  69156. /**
  69157. * This represents a SERIALIZABLE scene component.
  69158. *
  69159. * This extends Scene Component to add Serialization methods on top.
  69160. */
  69161. export interface ISceneSerializableComponent extends ISceneComponent {
  69162. /**
  69163. * Adds all the element from the container to the scene
  69164. * @param container the container holding the elements
  69165. */
  69166. addFromContainer(container: AbstractScene): void;
  69167. /**
  69168. * Removes all the elements in the container from the scene
  69169. * @param container contains the elements to remove
  69170. */
  69171. removeFromContainer(container: AbstractScene): void;
  69172. /**
  69173. * Serializes the component data to the specified json object
  69174. * @param serializationObject The object to serialize to
  69175. */
  69176. serialize(serializationObject: any): void;
  69177. }
  69178. /**
  69179. * Strong typing of a Mesh related stage step action
  69180. */
  69181. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  69182. /**
  69183. * Strong typing of a Evaluate Sub Mesh related stage step action
  69184. */
  69185. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  69186. /**
  69187. * Strong typing of a Active Mesh related stage step action
  69188. */
  69189. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  69190. /**
  69191. * Strong typing of a Camera related stage step action
  69192. */
  69193. export type CameraStageAction = (camera: Camera) => void;
  69194. /**
  69195. * Strong typing of a Render Target related stage step action
  69196. */
  69197. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  69198. /**
  69199. * Strong typing of a RenderingGroup related stage step action
  69200. */
  69201. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  69202. /**
  69203. * Strong typing of a Mesh Render related stage step action
  69204. */
  69205. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  69206. /**
  69207. * Strong typing of a simple stage step action
  69208. */
  69209. export type SimpleStageAction = () => void;
  69210. /**
  69211. * Strong typing of a render target action.
  69212. */
  69213. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  69214. /**
  69215. * Strong typing of a pointer move action.
  69216. */
  69217. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  69218. /**
  69219. * Strong typing of a pointer up/down action.
  69220. */
  69221. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  69222. /**
  69223. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  69224. * @hidden
  69225. */
  69226. export class Stage<T extends Function> extends Array<{
  69227. index: number;
  69228. component: ISceneComponent;
  69229. action: T;
  69230. }> {
  69231. /**
  69232. * Hide ctor from the rest of the world.
  69233. * @param items The items to add.
  69234. */
  69235. private constructor();
  69236. /**
  69237. * Creates a new Stage.
  69238. * @returns A new instance of a Stage
  69239. */
  69240. static Create<T extends Function>(): Stage<T>;
  69241. /**
  69242. * Registers a step in an ordered way in the targeted stage.
  69243. * @param index Defines the position to register the step in
  69244. * @param component Defines the component attached to the step
  69245. * @param action Defines the action to launch during the step
  69246. */
  69247. registerStep(index: number, component: ISceneComponent, action: T): void;
  69248. /**
  69249. * Clears all the steps from the stage.
  69250. */
  69251. clear(): void;
  69252. }
  69253. }
  69254. declare module BABYLON {
  69255. interface Scene {
  69256. /** @hidden */
  69257. _pointerOverSprite: Nullable<Sprite>;
  69258. /** @hidden */
  69259. _pickedDownSprite: Nullable<Sprite>;
  69260. /** @hidden */
  69261. _tempSpritePickingRay: Nullable<Ray>;
  69262. /**
  69263. * All of the sprite managers added to this scene
  69264. * @see http://doc.babylonjs.com/babylon101/sprites
  69265. */
  69266. spriteManagers: Array<ISpriteManager>;
  69267. /**
  69268. * An event triggered when sprites rendering is about to start
  69269. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  69270. */
  69271. onBeforeSpritesRenderingObservable: Observable<Scene>;
  69272. /**
  69273. * An event triggered when sprites rendering is done
  69274. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  69275. */
  69276. onAfterSpritesRenderingObservable: Observable<Scene>;
  69277. /** @hidden */
  69278. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  69279. /** Launch a ray to try to pick a sprite in the scene
  69280. * @param x position on screen
  69281. * @param y position on screen
  69282. * @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
  69283. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  69284. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  69285. * @returns a PickingInfo
  69286. */
  69287. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  69288. /** Use the given ray to pick a sprite in the scene
  69289. * @param ray The ray (in world space) to use to pick meshes
  69290. * @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
  69291. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  69292. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  69293. * @returns a PickingInfo
  69294. */
  69295. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  69296. /**
  69297. * Force the sprite under the pointer
  69298. * @param sprite defines the sprite to use
  69299. */
  69300. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  69301. /**
  69302. * Gets the sprite under the pointer
  69303. * @returns a Sprite or null if no sprite is under the pointer
  69304. */
  69305. getPointerOverSprite(): Nullable<Sprite>;
  69306. }
  69307. /**
  69308. * Defines the sprite scene component responsible to manage sprites
  69309. * in a given scene.
  69310. */
  69311. export class SpriteSceneComponent implements ISceneComponent {
  69312. /**
  69313. * The component name helpfull to identify the component in the list of scene components.
  69314. */
  69315. readonly name: string;
  69316. /**
  69317. * The scene the component belongs to.
  69318. */
  69319. scene: Scene;
  69320. /** @hidden */
  69321. private _spritePredicate;
  69322. /**
  69323. * Creates a new instance of the component for the given scene
  69324. * @param scene Defines the scene to register the component in
  69325. */
  69326. constructor(scene: Scene);
  69327. /**
  69328. * Registers the component in a given scene
  69329. */
  69330. register(): void;
  69331. /**
  69332. * Rebuilds the elements related to this component in case of
  69333. * context lost for instance.
  69334. */
  69335. rebuild(): void;
  69336. /**
  69337. * Disposes the component and the associated ressources.
  69338. */
  69339. dispose(): void;
  69340. private _pickSpriteButKeepRay;
  69341. private _pointerMove;
  69342. private _pointerDown;
  69343. private _pointerUp;
  69344. }
  69345. }
  69346. declare module BABYLON {
  69347. /** @hidden */
  69348. export var fogFragmentDeclaration: {
  69349. name: string;
  69350. shader: string;
  69351. };
  69352. }
  69353. declare module BABYLON {
  69354. /** @hidden */
  69355. export var fogFragment: {
  69356. name: string;
  69357. shader: string;
  69358. };
  69359. }
  69360. declare module BABYLON {
  69361. /** @hidden */
  69362. export var spritesPixelShader: {
  69363. name: string;
  69364. shader: string;
  69365. };
  69366. }
  69367. declare module BABYLON {
  69368. /** @hidden */
  69369. export var fogVertexDeclaration: {
  69370. name: string;
  69371. shader: string;
  69372. };
  69373. }
  69374. declare module BABYLON {
  69375. /** @hidden */
  69376. export var spritesVertexShader: {
  69377. name: string;
  69378. shader: string;
  69379. };
  69380. }
  69381. declare module BABYLON {
  69382. /**
  69383. * Defines the minimum interface to fullfil in order to be a sprite manager.
  69384. */
  69385. export interface ISpriteManager extends IDisposable {
  69386. /**
  69387. * Restricts the camera to viewing objects with the same layerMask.
  69388. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  69389. */
  69390. layerMask: number;
  69391. /**
  69392. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  69393. */
  69394. isPickable: boolean;
  69395. /**
  69396. * Specifies the rendering group id for this mesh (0 by default)
  69397. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  69398. */
  69399. renderingGroupId: number;
  69400. /**
  69401. * Defines the list of sprites managed by the manager.
  69402. */
  69403. sprites: Array<Sprite>;
  69404. /**
  69405. * Tests the intersection of a sprite with a specific ray.
  69406. * @param ray The ray we are sending to test the collision
  69407. * @param camera The camera space we are sending rays in
  69408. * @param predicate A predicate allowing excluding sprites from the list of object to test
  69409. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  69410. * @returns picking info or null.
  69411. */
  69412. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  69413. /**
  69414. * Renders the list of sprites on screen.
  69415. */
  69416. render(): void;
  69417. }
  69418. /**
  69419. * Class used to manage multiple sprites on the same spritesheet
  69420. * @see http://doc.babylonjs.com/babylon101/sprites
  69421. */
  69422. export class SpriteManager implements ISpriteManager {
  69423. /** defines the manager's name */
  69424. name: string;
  69425. /** Gets the list of sprites */
  69426. sprites: Sprite[];
  69427. /** Gets or sets the rendering group id (0 by default) */
  69428. renderingGroupId: number;
  69429. /** Gets or sets camera layer mask */
  69430. layerMask: number;
  69431. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  69432. fogEnabled: boolean;
  69433. /** Gets or sets a boolean indicating if the sprites are pickable */
  69434. isPickable: boolean;
  69435. /** Defines the default width of a cell in the spritesheet */
  69436. cellWidth: number;
  69437. /** Defines the default height of a cell in the spritesheet */
  69438. cellHeight: number;
  69439. /**
  69440. * An event triggered when the manager is disposed.
  69441. */
  69442. onDisposeObservable: Observable<SpriteManager>;
  69443. private _onDisposeObserver;
  69444. /**
  69445. * Callback called when the manager is disposed
  69446. */
  69447. onDispose: () => void;
  69448. private _capacity;
  69449. private _spriteTexture;
  69450. private _epsilon;
  69451. private _scene;
  69452. private _vertexData;
  69453. private _buffer;
  69454. private _vertexBuffers;
  69455. private _indexBuffer;
  69456. private _effectBase;
  69457. private _effectFog;
  69458. /**
  69459. * Gets or sets the spritesheet texture
  69460. */
  69461. texture: Texture;
  69462. /**
  69463. * Creates a new sprite manager
  69464. * @param name defines the manager's name
  69465. * @param imgUrl defines the sprite sheet url
  69466. * @param capacity defines the maximum allowed number of sprites
  69467. * @param cellSize defines the size of a sprite cell
  69468. * @param scene defines the hosting scene
  69469. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  69470. * @param samplingMode defines the smapling mode to use with spritesheet
  69471. */
  69472. constructor(
  69473. /** defines the manager's name */
  69474. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  69475. private _appendSpriteVertex;
  69476. /**
  69477. * Intersects the sprites with a ray
  69478. * @param ray defines the ray to intersect with
  69479. * @param camera defines the current active camera
  69480. * @param predicate defines a predicate used to select candidate sprites
  69481. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  69482. * @returns null if no hit or a PickingInfo
  69483. */
  69484. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  69485. /**
  69486. * Render all child sprites
  69487. */
  69488. render(): void;
  69489. /**
  69490. * Release associated resources
  69491. */
  69492. dispose(): void;
  69493. }
  69494. }
  69495. declare module BABYLON {
  69496. /**
  69497. * Class used to represent a sprite
  69498. * @see http://doc.babylonjs.com/babylon101/sprites
  69499. */
  69500. export class Sprite {
  69501. /** defines the name */
  69502. name: string;
  69503. /** Gets or sets the current world position */
  69504. position: Vector3;
  69505. /** Gets or sets the main color */
  69506. color: Color4;
  69507. /** Gets or sets the width */
  69508. width: number;
  69509. /** Gets or sets the height */
  69510. height: number;
  69511. /** Gets or sets rotation angle */
  69512. angle: number;
  69513. /** Gets or sets the cell index in the sprite sheet */
  69514. cellIndex: number;
  69515. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  69516. invertU: number;
  69517. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  69518. invertV: number;
  69519. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  69520. disposeWhenFinishedAnimating: boolean;
  69521. /** Gets the list of attached animations */
  69522. animations: Animation[];
  69523. /** Gets or sets a boolean indicating if the sprite can be picked */
  69524. isPickable: boolean;
  69525. /**
  69526. * Gets or sets the associated action manager
  69527. */
  69528. actionManager: Nullable<ActionManager>;
  69529. private _animationStarted;
  69530. private _loopAnimation;
  69531. private _fromIndex;
  69532. private _toIndex;
  69533. private _delay;
  69534. private _direction;
  69535. private _manager;
  69536. private _time;
  69537. private _onAnimationEnd;
  69538. /**
  69539. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  69540. */
  69541. isVisible: boolean;
  69542. /**
  69543. * Gets or sets the sprite size
  69544. */
  69545. size: number;
  69546. /**
  69547. * Creates a new Sprite
  69548. * @param name defines the name
  69549. * @param manager defines the manager
  69550. */
  69551. constructor(
  69552. /** defines the name */
  69553. name: string, manager: ISpriteManager);
  69554. /**
  69555. * Starts an animation
  69556. * @param from defines the initial key
  69557. * @param to defines the end key
  69558. * @param loop defines if the animation must loop
  69559. * @param delay defines the start delay (in ms)
  69560. * @param onAnimationEnd defines a callback to call when animation ends
  69561. */
  69562. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  69563. /** Stops current animation (if any) */
  69564. stopAnimation(): void;
  69565. /** @hidden */
  69566. _animate(deltaTime: number): void;
  69567. /** Release associated resources */
  69568. dispose(): void;
  69569. }
  69570. }
  69571. declare module BABYLON {
  69572. /**
  69573. * Information about the result of picking within a scene
  69574. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  69575. */
  69576. export class PickingInfo {
  69577. /** @hidden */
  69578. _pickingUnavailable: boolean;
  69579. /**
  69580. * If the pick collided with an object
  69581. */
  69582. hit: boolean;
  69583. /**
  69584. * Distance away where the pick collided
  69585. */
  69586. distance: number;
  69587. /**
  69588. * The location of pick collision
  69589. */
  69590. pickedPoint: Nullable<Vector3>;
  69591. /**
  69592. * The mesh corresponding the the pick collision
  69593. */
  69594. pickedMesh: Nullable<AbstractMesh>;
  69595. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  69596. bu: number;
  69597. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  69598. bv: number;
  69599. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  69600. faceId: number;
  69601. /** Id of the the submesh that was picked */
  69602. subMeshId: number;
  69603. /** If a sprite was picked, this will be the sprite the pick collided with */
  69604. pickedSprite: Nullable<Sprite>;
  69605. /**
  69606. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  69607. */
  69608. originMesh: Nullable<AbstractMesh>;
  69609. /**
  69610. * The ray that was used to perform the picking.
  69611. */
  69612. ray: Nullable<Ray>;
  69613. /**
  69614. * Gets the normal correspodning to the face the pick collided with
  69615. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  69616. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  69617. * @returns The normal correspodning to the face the pick collided with
  69618. */
  69619. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  69620. /**
  69621. * Gets the texture coordinates of where the pick occured
  69622. * @returns the vector containing the coordnates of the texture
  69623. */
  69624. getTextureCoordinates(): Nullable<Vector2>;
  69625. }
  69626. }
  69627. declare module BABYLON {
  69628. /**
  69629. * Gather the list of pointer event types as constants.
  69630. */
  69631. export class PointerEventTypes {
  69632. /**
  69633. * 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.
  69634. */
  69635. static readonly POINTERDOWN: number;
  69636. /**
  69637. * The pointerup event is fired when a pointer is no longer active.
  69638. */
  69639. static readonly POINTERUP: number;
  69640. /**
  69641. * The pointermove event is fired when a pointer changes coordinates.
  69642. */
  69643. static readonly POINTERMOVE: number;
  69644. /**
  69645. * The pointerwheel event is fired when a mouse wheel has been rotated.
  69646. */
  69647. static readonly POINTERWHEEL: number;
  69648. /**
  69649. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  69650. */
  69651. static readonly POINTERPICK: number;
  69652. /**
  69653. * The pointertap event is fired when a the object has been touched and released without drag.
  69654. */
  69655. static readonly POINTERTAP: number;
  69656. /**
  69657. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  69658. */
  69659. static readonly POINTERDOUBLETAP: number;
  69660. }
  69661. /**
  69662. * Base class of pointer info types.
  69663. */
  69664. export class PointerInfoBase {
  69665. /**
  69666. * Defines the type of event (PointerEventTypes)
  69667. */
  69668. type: number;
  69669. /**
  69670. * Defines the related dom event
  69671. */
  69672. event: PointerEvent | MouseWheelEvent;
  69673. /**
  69674. * Instantiates the base class of pointers info.
  69675. * @param type Defines the type of event (PointerEventTypes)
  69676. * @param event Defines the related dom event
  69677. */
  69678. constructor(
  69679. /**
  69680. * Defines the type of event (PointerEventTypes)
  69681. */
  69682. type: number,
  69683. /**
  69684. * Defines the related dom event
  69685. */
  69686. event: PointerEvent | MouseWheelEvent);
  69687. }
  69688. /**
  69689. * This class is used to store pointer related info for the onPrePointerObservable event.
  69690. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  69691. */
  69692. export class PointerInfoPre extends PointerInfoBase {
  69693. /**
  69694. * Ray from a pointer if availible (eg. 6dof controller)
  69695. */
  69696. ray: Nullable<Ray>;
  69697. /**
  69698. * Defines the local position of the pointer on the canvas.
  69699. */
  69700. localPosition: Vector2;
  69701. /**
  69702. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  69703. */
  69704. skipOnPointerObservable: boolean;
  69705. /**
  69706. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  69707. * @param type Defines the type of event (PointerEventTypes)
  69708. * @param event Defines the related dom event
  69709. * @param localX Defines the local x coordinates of the pointer when the event occured
  69710. * @param localY Defines the local y coordinates of the pointer when the event occured
  69711. */
  69712. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  69713. }
  69714. /**
  69715. * This type contains all the data related to a pointer event in Babylon.js.
  69716. * 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.
  69717. */
  69718. export class PointerInfo extends PointerInfoBase {
  69719. /**
  69720. * Defines the picking info associated to the info (if any)\
  69721. */
  69722. pickInfo: Nullable<PickingInfo>;
  69723. /**
  69724. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  69725. * @param type Defines the type of event (PointerEventTypes)
  69726. * @param event Defines the related dom event
  69727. * @param pickInfo Defines the picking info associated to the info (if any)\
  69728. */
  69729. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  69730. /**
  69731. * Defines the picking info associated to the info (if any)\
  69732. */
  69733. pickInfo: Nullable<PickingInfo>);
  69734. }
  69735. /**
  69736. * Data relating to a touch event on the screen.
  69737. */
  69738. export interface PointerTouch {
  69739. /**
  69740. * X coordinate of touch.
  69741. */
  69742. x: number;
  69743. /**
  69744. * Y coordinate of touch.
  69745. */
  69746. y: number;
  69747. /**
  69748. * Id of touch. Unique for each finger.
  69749. */
  69750. pointerId: number;
  69751. /**
  69752. * Event type passed from DOM.
  69753. */
  69754. type: any;
  69755. }
  69756. }
  69757. declare module BABYLON {
  69758. /**
  69759. * Manage the mouse inputs to control the movement of a free camera.
  69760. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69761. */
  69762. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  69763. /**
  69764. * Define if touch is enabled in the mouse input
  69765. */
  69766. touchEnabled: boolean;
  69767. /**
  69768. * Defines the camera the input is attached to.
  69769. */
  69770. camera: FreeCamera;
  69771. /**
  69772. * Defines the buttons associated with the input to handle camera move.
  69773. */
  69774. buttons: number[];
  69775. /**
  69776. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  69777. */
  69778. angularSensibility: number;
  69779. private _pointerInput;
  69780. private _onMouseMove;
  69781. private _observer;
  69782. private previousPosition;
  69783. /**
  69784. * Manage the mouse inputs to control the movement of a free camera.
  69785. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69786. * @param touchEnabled Defines if touch is enabled or not
  69787. */
  69788. constructor(
  69789. /**
  69790. * Define if touch is enabled in the mouse input
  69791. */
  69792. touchEnabled?: boolean);
  69793. /**
  69794. * Attach the input controls to a specific dom element to get the input from.
  69795. * @param element Defines the element the controls should be listened from
  69796. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69797. */
  69798. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69799. /**
  69800. * Called on JS contextmenu event.
  69801. * Override this method to provide functionality.
  69802. */
  69803. protected onContextMenu(evt: PointerEvent): void;
  69804. /**
  69805. * Detach the current controls from the specified dom element.
  69806. * @param element Defines the element to stop listening the inputs from
  69807. */
  69808. detachControl(element: Nullable<HTMLElement>): void;
  69809. /**
  69810. * Gets the class name of the current intput.
  69811. * @returns the class name
  69812. */
  69813. getClassName(): string;
  69814. /**
  69815. * Get the friendly name associated with the input class.
  69816. * @returns the input friendly name
  69817. */
  69818. getSimpleName(): string;
  69819. }
  69820. }
  69821. declare module BABYLON {
  69822. /**
  69823. * Manage the touch inputs to control the movement of a free camera.
  69824. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69825. */
  69826. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  69827. /**
  69828. * Defines the camera the input is attached to.
  69829. */
  69830. camera: FreeCamera;
  69831. /**
  69832. * Defines the touch sensibility for rotation.
  69833. * The higher the faster.
  69834. */
  69835. touchAngularSensibility: number;
  69836. /**
  69837. * Defines the touch sensibility for move.
  69838. * The higher the faster.
  69839. */
  69840. touchMoveSensibility: number;
  69841. private _offsetX;
  69842. private _offsetY;
  69843. private _pointerPressed;
  69844. private _pointerInput;
  69845. private _observer;
  69846. private _onLostFocus;
  69847. /**
  69848. * Attach the input controls to a specific dom element to get the input from.
  69849. * @param element Defines the element the controls should be listened from
  69850. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69851. */
  69852. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69853. /**
  69854. * Detach the current controls from the specified dom element.
  69855. * @param element Defines the element to stop listening the inputs from
  69856. */
  69857. detachControl(element: Nullable<HTMLElement>): void;
  69858. /**
  69859. * Update the current camera state depending on the inputs that have been used this frame.
  69860. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  69861. */
  69862. checkInputs(): void;
  69863. /**
  69864. * Gets the class name of the current intput.
  69865. * @returns the class name
  69866. */
  69867. getClassName(): string;
  69868. /**
  69869. * Get the friendly name associated with the input class.
  69870. * @returns the input friendly name
  69871. */
  69872. getSimpleName(): string;
  69873. }
  69874. }
  69875. declare module BABYLON {
  69876. /**
  69877. * Default Inputs manager for the FreeCamera.
  69878. * It groups all the default supported inputs for ease of use.
  69879. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69880. */
  69881. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  69882. /**
  69883. * Instantiates a new FreeCameraInputsManager.
  69884. * @param camera Defines the camera the inputs belong to
  69885. */
  69886. constructor(camera: FreeCamera);
  69887. /**
  69888. * Add keyboard input support to the input manager.
  69889. * @returns the current input manager
  69890. */
  69891. addKeyboard(): FreeCameraInputsManager;
  69892. /**
  69893. * Add mouse input support to the input manager.
  69894. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  69895. * @returns the current input manager
  69896. */
  69897. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  69898. /**
  69899. * Add touch input support to the input manager.
  69900. * @returns the current input manager
  69901. */
  69902. addTouch(): FreeCameraInputsManager;
  69903. }
  69904. }
  69905. declare module BABYLON {
  69906. /**
  69907. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  69908. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  69909. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  69910. */
  69911. export class FreeCamera extends TargetCamera {
  69912. /**
  69913. * Define the collision ellipsoid of the camera.
  69914. * This is helpful to simulate a camera body like the player body around the camera
  69915. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  69916. */
  69917. ellipsoid: Vector3;
  69918. /**
  69919. * Define an offset for the position of the ellipsoid around the camera.
  69920. * This can be helpful to determine the center of the body near the gravity center of the body
  69921. * instead of its head.
  69922. */
  69923. ellipsoidOffset: Vector3;
  69924. /**
  69925. * Enable or disable collisions of the camera with the rest of the scene objects.
  69926. */
  69927. checkCollisions: boolean;
  69928. /**
  69929. * Enable or disable gravity on the camera.
  69930. */
  69931. applyGravity: boolean;
  69932. /**
  69933. * Define the input manager associated to the camera.
  69934. */
  69935. inputs: FreeCameraInputsManager;
  69936. /**
  69937. * Gets the input sensibility for a mouse input. (default is 2000.0)
  69938. * Higher values reduce sensitivity.
  69939. */
  69940. /**
  69941. * Sets the input sensibility for a mouse input. (default is 2000.0)
  69942. * Higher values reduce sensitivity.
  69943. */
  69944. angularSensibility: number;
  69945. /**
  69946. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  69947. */
  69948. keysUp: number[];
  69949. /**
  69950. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  69951. */
  69952. keysDown: number[];
  69953. /**
  69954. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  69955. */
  69956. keysLeft: number[];
  69957. /**
  69958. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  69959. */
  69960. keysRight: number[];
  69961. /**
  69962. * Event raised when the camera collide with a mesh in the scene.
  69963. */
  69964. onCollide: (collidedMesh: AbstractMesh) => void;
  69965. private _collider;
  69966. private _needMoveForGravity;
  69967. private _oldPosition;
  69968. private _diffPosition;
  69969. private _newPosition;
  69970. /** @hidden */
  69971. _localDirection: Vector3;
  69972. /** @hidden */
  69973. _transformedDirection: Vector3;
  69974. /**
  69975. * Instantiates a Free Camera.
  69976. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  69977. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  69978. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  69979. * @param name Define the name of the camera in the scene
  69980. * @param position Define the start position of the camera in the scene
  69981. * @param scene Define the scene the camera belongs to
  69982. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  69983. */
  69984. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  69985. /**
  69986. * Attached controls to the current camera.
  69987. * @param element Defines the element the controls should be listened from
  69988. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69989. */
  69990. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69991. /**
  69992. * Detach the current controls from the camera.
  69993. * The camera will stop reacting to inputs.
  69994. * @param element Defines the element to stop listening the inputs from
  69995. */
  69996. detachControl(element: HTMLElement): void;
  69997. private _collisionMask;
  69998. /**
  69999. * Define a collision mask to limit the list of object the camera can collide with
  70000. */
  70001. collisionMask: number;
  70002. /** @hidden */
  70003. _collideWithWorld(displacement: Vector3): void;
  70004. private _onCollisionPositionChange;
  70005. /** @hidden */
  70006. _checkInputs(): void;
  70007. /** @hidden */
  70008. _decideIfNeedsToMove(): boolean;
  70009. /** @hidden */
  70010. _updatePosition(): void;
  70011. /**
  70012. * Destroy the camera and release the current resources hold by it.
  70013. */
  70014. dispose(): void;
  70015. /**
  70016. * Gets the current object class name.
  70017. * @return the class name
  70018. */
  70019. getClassName(): string;
  70020. }
  70021. }
  70022. declare module BABYLON {
  70023. /**
  70024. * Represents a gamepad control stick position
  70025. */
  70026. export class StickValues {
  70027. /**
  70028. * The x component of the control stick
  70029. */
  70030. x: number;
  70031. /**
  70032. * The y component of the control stick
  70033. */
  70034. y: number;
  70035. /**
  70036. * Initializes the gamepad x and y control stick values
  70037. * @param x The x component of the gamepad control stick value
  70038. * @param y The y component of the gamepad control stick value
  70039. */
  70040. constructor(
  70041. /**
  70042. * The x component of the control stick
  70043. */
  70044. x: number,
  70045. /**
  70046. * The y component of the control stick
  70047. */
  70048. y: number);
  70049. }
  70050. /**
  70051. * An interface which manages callbacks for gamepad button changes
  70052. */
  70053. export interface GamepadButtonChanges {
  70054. /**
  70055. * Called when a gamepad has been changed
  70056. */
  70057. changed: boolean;
  70058. /**
  70059. * Called when a gamepad press event has been triggered
  70060. */
  70061. pressChanged: boolean;
  70062. /**
  70063. * Called when a touch event has been triggered
  70064. */
  70065. touchChanged: boolean;
  70066. /**
  70067. * Called when a value has changed
  70068. */
  70069. valueChanged: boolean;
  70070. }
  70071. /**
  70072. * Represents a gamepad
  70073. */
  70074. export class Gamepad {
  70075. /**
  70076. * The id of the gamepad
  70077. */
  70078. id: string;
  70079. /**
  70080. * The index of the gamepad
  70081. */
  70082. index: number;
  70083. /**
  70084. * The browser gamepad
  70085. */
  70086. browserGamepad: any;
  70087. /**
  70088. * Specifies what type of gamepad this represents
  70089. */
  70090. type: number;
  70091. private _leftStick;
  70092. private _rightStick;
  70093. /** @hidden */
  70094. _isConnected: boolean;
  70095. private _leftStickAxisX;
  70096. private _leftStickAxisY;
  70097. private _rightStickAxisX;
  70098. private _rightStickAxisY;
  70099. /**
  70100. * Triggered when the left control stick has been changed
  70101. */
  70102. private _onleftstickchanged;
  70103. /**
  70104. * Triggered when the right control stick has been changed
  70105. */
  70106. private _onrightstickchanged;
  70107. /**
  70108. * Represents a gamepad controller
  70109. */
  70110. static GAMEPAD: number;
  70111. /**
  70112. * Represents a generic controller
  70113. */
  70114. static GENERIC: number;
  70115. /**
  70116. * Represents an XBox controller
  70117. */
  70118. static XBOX: number;
  70119. /**
  70120. * Represents a pose-enabled controller
  70121. */
  70122. static POSE_ENABLED: number;
  70123. /**
  70124. * Specifies whether the left control stick should be Y-inverted
  70125. */
  70126. protected _invertLeftStickY: boolean;
  70127. /**
  70128. * Specifies if the gamepad has been connected
  70129. */
  70130. readonly isConnected: boolean;
  70131. /**
  70132. * Initializes the gamepad
  70133. * @param id The id of the gamepad
  70134. * @param index The index of the gamepad
  70135. * @param browserGamepad The browser gamepad
  70136. * @param leftStickX The x component of the left joystick
  70137. * @param leftStickY The y component of the left joystick
  70138. * @param rightStickX The x component of the right joystick
  70139. * @param rightStickY The y component of the right joystick
  70140. */
  70141. constructor(
  70142. /**
  70143. * The id of the gamepad
  70144. */
  70145. id: string,
  70146. /**
  70147. * The index of the gamepad
  70148. */
  70149. index: number,
  70150. /**
  70151. * The browser gamepad
  70152. */
  70153. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  70154. /**
  70155. * Callback triggered when the left joystick has changed
  70156. * @param callback
  70157. */
  70158. onleftstickchanged(callback: (values: StickValues) => void): void;
  70159. /**
  70160. * Callback triggered when the right joystick has changed
  70161. * @param callback
  70162. */
  70163. onrightstickchanged(callback: (values: StickValues) => void): void;
  70164. /**
  70165. * Gets the left joystick
  70166. */
  70167. /**
  70168. * Sets the left joystick values
  70169. */
  70170. leftStick: StickValues;
  70171. /**
  70172. * Gets the right joystick
  70173. */
  70174. /**
  70175. * Sets the right joystick value
  70176. */
  70177. rightStick: StickValues;
  70178. /**
  70179. * Updates the gamepad joystick positions
  70180. */
  70181. update(): void;
  70182. /**
  70183. * Disposes the gamepad
  70184. */
  70185. dispose(): void;
  70186. }
  70187. /**
  70188. * Represents a generic gamepad
  70189. */
  70190. export class GenericPad extends Gamepad {
  70191. private _buttons;
  70192. private _onbuttondown;
  70193. private _onbuttonup;
  70194. /**
  70195. * Observable triggered when a button has been pressed
  70196. */
  70197. onButtonDownObservable: Observable<number>;
  70198. /**
  70199. * Observable triggered when a button has been released
  70200. */
  70201. onButtonUpObservable: Observable<number>;
  70202. /**
  70203. * Callback triggered when a button has been pressed
  70204. * @param callback Called when a button has been pressed
  70205. */
  70206. onbuttondown(callback: (buttonPressed: number) => void): void;
  70207. /**
  70208. * Callback triggered when a button has been released
  70209. * @param callback Called when a button has been released
  70210. */
  70211. onbuttonup(callback: (buttonReleased: number) => void): void;
  70212. /**
  70213. * Initializes the generic gamepad
  70214. * @param id The id of the generic gamepad
  70215. * @param index The index of the generic gamepad
  70216. * @param browserGamepad The browser gamepad
  70217. */
  70218. constructor(id: string, index: number, browserGamepad: any);
  70219. private _setButtonValue;
  70220. /**
  70221. * Updates the generic gamepad
  70222. */
  70223. update(): void;
  70224. /**
  70225. * Disposes the generic gamepad
  70226. */
  70227. dispose(): void;
  70228. }
  70229. }
  70230. declare module BABYLON {
  70231. /**
  70232. * Defines the types of pose enabled controllers that are supported
  70233. */
  70234. export enum PoseEnabledControllerType {
  70235. /**
  70236. * HTC Vive
  70237. */
  70238. VIVE = 0,
  70239. /**
  70240. * Oculus Rift
  70241. */
  70242. OCULUS = 1,
  70243. /**
  70244. * Windows mixed reality
  70245. */
  70246. WINDOWS = 2,
  70247. /**
  70248. * Samsung gear VR
  70249. */
  70250. GEAR_VR = 3,
  70251. /**
  70252. * Google Daydream
  70253. */
  70254. DAYDREAM = 4,
  70255. /**
  70256. * Generic
  70257. */
  70258. GENERIC = 5
  70259. }
  70260. /**
  70261. * Defines the MutableGamepadButton interface for the state of a gamepad button
  70262. */
  70263. export interface MutableGamepadButton {
  70264. /**
  70265. * Value of the button/trigger
  70266. */
  70267. value: number;
  70268. /**
  70269. * If the button/trigger is currently touched
  70270. */
  70271. touched: boolean;
  70272. /**
  70273. * If the button/trigger is currently pressed
  70274. */
  70275. pressed: boolean;
  70276. }
  70277. /**
  70278. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  70279. * @hidden
  70280. */
  70281. export interface ExtendedGamepadButton extends GamepadButton {
  70282. /**
  70283. * If the button/trigger is currently pressed
  70284. */
  70285. readonly pressed: boolean;
  70286. /**
  70287. * If the button/trigger is currently touched
  70288. */
  70289. readonly touched: boolean;
  70290. /**
  70291. * Value of the button/trigger
  70292. */
  70293. readonly value: number;
  70294. }
  70295. /** @hidden */
  70296. export interface _GamePadFactory {
  70297. /**
  70298. * Returns wether or not the current gamepad can be created for this type of controller.
  70299. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  70300. * @returns true if it can be created, otherwise false
  70301. */
  70302. canCreate(gamepadInfo: any): boolean;
  70303. /**
  70304. * Creates a new instance of the Gamepad.
  70305. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  70306. * @returns the new gamepad instance
  70307. */
  70308. create(gamepadInfo: any): Gamepad;
  70309. }
  70310. /**
  70311. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  70312. */
  70313. export class PoseEnabledControllerHelper {
  70314. /** @hidden */
  70315. static _ControllerFactories: _GamePadFactory[];
  70316. /** @hidden */
  70317. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  70318. /**
  70319. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  70320. * @param vrGamepad the gamepad to initialized
  70321. * @returns a vr controller of the type the gamepad identified as
  70322. */
  70323. static InitiateController(vrGamepad: any): Gamepad;
  70324. }
  70325. /**
  70326. * Defines the PoseEnabledController object that contains state of a vr capable controller
  70327. */
  70328. export class PoseEnabledController extends Gamepad implements PoseControlled {
  70329. private _deviceRoomPosition;
  70330. private _deviceRoomRotationQuaternion;
  70331. /**
  70332. * The device position in babylon space
  70333. */
  70334. devicePosition: Vector3;
  70335. /**
  70336. * The device rotation in babylon space
  70337. */
  70338. deviceRotationQuaternion: Quaternion;
  70339. /**
  70340. * The scale factor of the device in babylon space
  70341. */
  70342. deviceScaleFactor: number;
  70343. /**
  70344. * (Likely devicePosition should be used instead) The device position in its room space
  70345. */
  70346. position: Vector3;
  70347. /**
  70348. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  70349. */
  70350. rotationQuaternion: Quaternion;
  70351. /**
  70352. * The type of controller (Eg. Windows mixed reality)
  70353. */
  70354. controllerType: PoseEnabledControllerType;
  70355. protected _calculatedPosition: Vector3;
  70356. private _calculatedRotation;
  70357. /**
  70358. * The raw pose from the device
  70359. */
  70360. rawPose: DevicePose;
  70361. private _trackPosition;
  70362. private _maxRotationDistFromHeadset;
  70363. private _draggedRoomRotation;
  70364. /**
  70365. * @hidden
  70366. */
  70367. _disableTrackPosition(fixedPosition: Vector3): void;
  70368. /**
  70369. * Internal, the mesh attached to the controller
  70370. * @hidden
  70371. */
  70372. _mesh: Nullable<AbstractMesh>;
  70373. private _poseControlledCamera;
  70374. private _leftHandSystemQuaternion;
  70375. /**
  70376. * Internal, matrix used to convert room space to babylon space
  70377. * @hidden
  70378. */
  70379. _deviceToWorld: Matrix;
  70380. /**
  70381. * Node to be used when casting a ray from the controller
  70382. * @hidden
  70383. */
  70384. _pointingPoseNode: Nullable<TransformNode>;
  70385. /**
  70386. * Name of the child mesh that can be used to cast a ray from the controller
  70387. */
  70388. static readonly POINTING_POSE: string;
  70389. /**
  70390. * Creates a new PoseEnabledController from a gamepad
  70391. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  70392. */
  70393. constructor(browserGamepad: any);
  70394. private _workingMatrix;
  70395. /**
  70396. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  70397. */
  70398. update(): void;
  70399. /**
  70400. * Updates only the pose device and mesh without doing any button event checking
  70401. */
  70402. protected _updatePoseAndMesh(): void;
  70403. /**
  70404. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  70405. * @param poseData raw pose fromthe device
  70406. */
  70407. updateFromDevice(poseData: DevicePose): void;
  70408. /**
  70409. * @hidden
  70410. */
  70411. _meshAttachedObservable: Observable<AbstractMesh>;
  70412. /**
  70413. * Attaches a mesh to the controller
  70414. * @param mesh the mesh to be attached
  70415. */
  70416. attachToMesh(mesh: AbstractMesh): void;
  70417. /**
  70418. * Attaches the controllers mesh to a camera
  70419. * @param camera the camera the mesh should be attached to
  70420. */
  70421. attachToPoseControlledCamera(camera: TargetCamera): void;
  70422. /**
  70423. * Disposes of the controller
  70424. */
  70425. dispose(): void;
  70426. /**
  70427. * The mesh that is attached to the controller
  70428. */
  70429. readonly mesh: Nullable<AbstractMesh>;
  70430. /**
  70431. * Gets the ray of the controller in the direction the controller is pointing
  70432. * @param length the length the resulting ray should be
  70433. * @returns a ray in the direction the controller is pointing
  70434. */
  70435. getForwardRay(length?: number): Ray;
  70436. }
  70437. }
  70438. declare module BABYLON {
  70439. /**
  70440. * Defines the WebVRController object that represents controllers tracked in 3D space
  70441. */
  70442. export abstract class WebVRController extends PoseEnabledController {
  70443. /**
  70444. * Internal, the default controller model for the controller
  70445. */
  70446. protected _defaultModel: AbstractMesh;
  70447. /**
  70448. * Fired when the trigger state has changed
  70449. */
  70450. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  70451. /**
  70452. * Fired when the main button state has changed
  70453. */
  70454. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  70455. /**
  70456. * Fired when the secondary button state has changed
  70457. */
  70458. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  70459. /**
  70460. * Fired when the pad state has changed
  70461. */
  70462. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  70463. /**
  70464. * Fired when controllers stick values have changed
  70465. */
  70466. onPadValuesChangedObservable: Observable<StickValues>;
  70467. /**
  70468. * Array of button availible on the controller
  70469. */
  70470. protected _buttons: Array<MutableGamepadButton>;
  70471. private _onButtonStateChange;
  70472. /**
  70473. * Fired when a controller button's state has changed
  70474. * @param callback the callback containing the button that was modified
  70475. */
  70476. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  70477. /**
  70478. * X and Y axis corrisponding to the controllers joystick
  70479. */
  70480. pad: StickValues;
  70481. /**
  70482. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  70483. */
  70484. hand: string;
  70485. /**
  70486. * The default controller model for the controller
  70487. */
  70488. readonly defaultModel: AbstractMesh;
  70489. /**
  70490. * Creates a new WebVRController from a gamepad
  70491. * @param vrGamepad the gamepad that the WebVRController should be created from
  70492. */
  70493. constructor(vrGamepad: any);
  70494. /**
  70495. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  70496. */
  70497. update(): void;
  70498. /**
  70499. * Function to be called when a button is modified
  70500. */
  70501. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  70502. /**
  70503. * Loads a mesh and attaches it to the controller
  70504. * @param scene the scene the mesh should be added to
  70505. * @param meshLoaded callback for when the mesh has been loaded
  70506. */
  70507. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  70508. private _setButtonValue;
  70509. private _changes;
  70510. private _checkChanges;
  70511. /**
  70512. * Disposes of th webVRCOntroller
  70513. */
  70514. dispose(): void;
  70515. }
  70516. }
  70517. declare module BABYLON {
  70518. /**
  70519. * The HemisphericLight simulates the ambient environment light,
  70520. * so the passed direction is the light reflection direction, not the incoming direction.
  70521. */
  70522. export class HemisphericLight extends Light {
  70523. /**
  70524. * The groundColor is the light in the opposite direction to the one specified during creation.
  70525. * 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.
  70526. */
  70527. groundColor: Color3;
  70528. /**
  70529. * The light reflection direction, not the incoming direction.
  70530. */
  70531. direction: Vector3;
  70532. /**
  70533. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  70534. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  70535. * The HemisphericLight can't cast shadows.
  70536. * Documentation : https://doc.babylonjs.com/babylon101/lights
  70537. * @param name The friendly name of the light
  70538. * @param direction The direction of the light reflection
  70539. * @param scene The scene the light belongs to
  70540. */
  70541. constructor(name: string, direction: Vector3, scene: Scene);
  70542. protected _buildUniformLayout(): void;
  70543. /**
  70544. * Returns the string "HemisphericLight".
  70545. * @return The class name
  70546. */
  70547. getClassName(): string;
  70548. /**
  70549. * Sets the HemisphericLight direction towards the passed target (Vector3).
  70550. * Returns the updated direction.
  70551. * @param target The target the direction should point to
  70552. * @return The computed direction
  70553. */
  70554. setDirectionToTarget(target: Vector3): Vector3;
  70555. /**
  70556. * Returns the shadow generator associated to the light.
  70557. * @returns Always null for hemispheric lights because it does not support shadows.
  70558. */
  70559. getShadowGenerator(): Nullable<IShadowGenerator>;
  70560. /**
  70561. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  70562. * @param effect The effect to update
  70563. * @param lightIndex The index of the light in the effect to update
  70564. * @returns The hemispheric light
  70565. */
  70566. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  70567. /**
  70568. * Computes the world matrix of the node
  70569. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  70570. * @param useWasUpdatedFlag defines a reserved property
  70571. * @returns the world matrix
  70572. */
  70573. computeWorldMatrix(): Matrix;
  70574. /**
  70575. * Returns the integer 3.
  70576. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  70577. */
  70578. getTypeID(): number;
  70579. /**
  70580. * Prepares the list of defines specific to the light type.
  70581. * @param defines the list of defines
  70582. * @param lightIndex defines the index of the light for the effect
  70583. */
  70584. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  70585. }
  70586. }
  70587. declare module BABYLON {
  70588. /**
  70589. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  70590. * IMPORTANT!! The data is right-hand data.
  70591. * @export
  70592. * @interface DevicePose
  70593. */
  70594. export interface DevicePose {
  70595. /**
  70596. * The position of the device, values in array are [x,y,z].
  70597. */
  70598. readonly position: Nullable<Float32Array>;
  70599. /**
  70600. * The linearVelocity of the device, values in array are [x,y,z].
  70601. */
  70602. readonly linearVelocity: Nullable<Float32Array>;
  70603. /**
  70604. * The linearAcceleration of the device, values in array are [x,y,z].
  70605. */
  70606. readonly linearAcceleration: Nullable<Float32Array>;
  70607. /**
  70608. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  70609. */
  70610. readonly orientation: Nullable<Float32Array>;
  70611. /**
  70612. * The angularVelocity of the device, values in array are [x,y,z].
  70613. */
  70614. readonly angularVelocity: Nullable<Float32Array>;
  70615. /**
  70616. * The angularAcceleration of the device, values in array are [x,y,z].
  70617. */
  70618. readonly angularAcceleration: Nullable<Float32Array>;
  70619. }
  70620. /**
  70621. * Interface representing a pose controlled object in Babylon.
  70622. * A pose controlled object has both regular pose values as well as pose values
  70623. * from an external device such as a VR head mounted display
  70624. */
  70625. export interface PoseControlled {
  70626. /**
  70627. * The position of the object in babylon space.
  70628. */
  70629. position: Vector3;
  70630. /**
  70631. * The rotation quaternion of the object in babylon space.
  70632. */
  70633. rotationQuaternion: Quaternion;
  70634. /**
  70635. * The position of the device in babylon space.
  70636. */
  70637. devicePosition?: Vector3;
  70638. /**
  70639. * The rotation quaternion of the device in babylon space.
  70640. */
  70641. deviceRotationQuaternion: Quaternion;
  70642. /**
  70643. * The raw pose coming from the device.
  70644. */
  70645. rawPose: Nullable<DevicePose>;
  70646. /**
  70647. * The scale of the device to be used when translating from device space to babylon space.
  70648. */
  70649. deviceScaleFactor: number;
  70650. /**
  70651. * Updates the poseControlled values based on the input device pose.
  70652. * @param poseData the pose data to update the object with
  70653. */
  70654. updateFromDevice(poseData: DevicePose): void;
  70655. }
  70656. /**
  70657. * Set of options to customize the webVRCamera
  70658. */
  70659. export interface WebVROptions {
  70660. /**
  70661. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  70662. */
  70663. trackPosition?: boolean;
  70664. /**
  70665. * Sets the scale of the vrDevice in babylon space. (default: 1)
  70666. */
  70667. positionScale?: number;
  70668. /**
  70669. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  70670. */
  70671. displayName?: string;
  70672. /**
  70673. * Should the native controller meshes be initialized. (default: true)
  70674. */
  70675. controllerMeshes?: boolean;
  70676. /**
  70677. * Creating a default HemiLight only on controllers. (default: true)
  70678. */
  70679. defaultLightingOnControllers?: boolean;
  70680. /**
  70681. * If you don't want to use the default VR button of the helper. (default: false)
  70682. */
  70683. useCustomVRButton?: boolean;
  70684. /**
  70685. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  70686. */
  70687. customVRButton?: HTMLButtonElement;
  70688. /**
  70689. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  70690. */
  70691. rayLength?: number;
  70692. /**
  70693. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  70694. */
  70695. defaultHeight?: number;
  70696. }
  70697. /**
  70698. * This represents a WebVR camera.
  70699. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  70700. * @example http://doc.babylonjs.com/how_to/webvr_camera
  70701. */
  70702. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  70703. private webVROptions;
  70704. /**
  70705. * @hidden
  70706. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  70707. */
  70708. _vrDevice: any;
  70709. /**
  70710. * The rawPose of the vrDevice.
  70711. */
  70712. rawPose: Nullable<DevicePose>;
  70713. private _onVREnabled;
  70714. private _specsVersion;
  70715. private _attached;
  70716. private _frameData;
  70717. protected _descendants: Array<Node>;
  70718. private _deviceRoomPosition;
  70719. /** @hidden */
  70720. _deviceRoomRotationQuaternion: Quaternion;
  70721. private _standingMatrix;
  70722. /**
  70723. * Represents device position in babylon space.
  70724. */
  70725. devicePosition: Vector3;
  70726. /**
  70727. * Represents device rotation in babylon space.
  70728. */
  70729. deviceRotationQuaternion: Quaternion;
  70730. /**
  70731. * The scale of the device to be used when translating from device space to babylon space.
  70732. */
  70733. deviceScaleFactor: number;
  70734. private _deviceToWorld;
  70735. private _worldToDevice;
  70736. /**
  70737. * References to the webVR controllers for the vrDevice.
  70738. */
  70739. controllers: Array<WebVRController>;
  70740. /**
  70741. * Emits an event when a controller is attached.
  70742. */
  70743. onControllersAttachedObservable: Observable<WebVRController[]>;
  70744. /**
  70745. * Emits an event when a controller's mesh has been loaded;
  70746. */
  70747. onControllerMeshLoadedObservable: Observable<WebVRController>;
  70748. /**
  70749. * Emits an event when the HMD's pose has been updated.
  70750. */
  70751. onPoseUpdatedFromDeviceObservable: Observable<any>;
  70752. private _poseSet;
  70753. /**
  70754. * If the rig cameras be used as parent instead of this camera.
  70755. */
  70756. rigParenting: boolean;
  70757. private _lightOnControllers;
  70758. private _defaultHeight?;
  70759. /**
  70760. * Instantiates a WebVRFreeCamera.
  70761. * @param name The name of the WebVRFreeCamera
  70762. * @param position The starting anchor position for the camera
  70763. * @param scene The scene the camera belongs to
  70764. * @param webVROptions a set of customizable options for the webVRCamera
  70765. */
  70766. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  70767. /**
  70768. * Gets the device distance from the ground in meters.
  70769. * @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.
  70770. */
  70771. deviceDistanceToRoomGround(): number;
  70772. /**
  70773. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  70774. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  70775. */
  70776. useStandingMatrix(callback?: (bool: boolean) => void): void;
  70777. /**
  70778. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  70779. * @returns A promise with a boolean set to if the standing matrix is supported.
  70780. */
  70781. useStandingMatrixAsync(): Promise<boolean>;
  70782. /**
  70783. * Disposes the camera
  70784. */
  70785. dispose(): void;
  70786. /**
  70787. * Gets a vrController by name.
  70788. * @param name The name of the controller to retreive
  70789. * @returns the controller matching the name specified or null if not found
  70790. */
  70791. getControllerByName(name: string): Nullable<WebVRController>;
  70792. private _leftController;
  70793. /**
  70794. * The controller corrisponding to the users left hand.
  70795. */
  70796. readonly leftController: Nullable<WebVRController>;
  70797. private _rightController;
  70798. /**
  70799. * The controller corrisponding to the users right hand.
  70800. */
  70801. readonly rightController: Nullable<WebVRController>;
  70802. /**
  70803. * Casts a ray forward from the vrCamera's gaze.
  70804. * @param length Length of the ray (default: 100)
  70805. * @returns the ray corrisponding to the gaze
  70806. */
  70807. getForwardRay(length?: number): Ray;
  70808. /**
  70809. * @hidden
  70810. * Updates the camera based on device's frame data
  70811. */
  70812. _checkInputs(): void;
  70813. /**
  70814. * Updates the poseControlled values based on the input device pose.
  70815. * @param poseData Pose coming from the device
  70816. */
  70817. updateFromDevice(poseData: DevicePose): void;
  70818. private _htmlElementAttached;
  70819. private _detachIfAttached;
  70820. /**
  70821. * WebVR's attach control will start broadcasting frames to the device.
  70822. * Note that in certain browsers (chrome for example) this function must be called
  70823. * within a user-interaction callback. Example:
  70824. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  70825. *
  70826. * @param element html element to attach the vrDevice to
  70827. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  70828. */
  70829. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70830. /**
  70831. * Detaches the camera from the html element and disables VR
  70832. *
  70833. * @param element html element to detach from
  70834. */
  70835. detachControl(element: HTMLElement): void;
  70836. /**
  70837. * @returns the name of this class
  70838. */
  70839. getClassName(): string;
  70840. /**
  70841. * Calls resetPose on the vrDisplay
  70842. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  70843. */
  70844. resetToCurrentRotation(): void;
  70845. /**
  70846. * @hidden
  70847. * Updates the rig cameras (left and right eye)
  70848. */
  70849. _updateRigCameras(): void;
  70850. private _workingVector;
  70851. private _oneVector;
  70852. private _workingMatrix;
  70853. private updateCacheCalled;
  70854. private _correctPositionIfNotTrackPosition;
  70855. /**
  70856. * @hidden
  70857. * Updates the cached values of the camera
  70858. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  70859. */
  70860. _updateCache(ignoreParentClass?: boolean): void;
  70861. /**
  70862. * @hidden
  70863. * Get current device position in babylon world
  70864. */
  70865. _computeDevicePosition(): void;
  70866. /**
  70867. * Updates the current device position and rotation in the babylon world
  70868. */
  70869. update(): void;
  70870. /**
  70871. * @hidden
  70872. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  70873. * @returns an identity matrix
  70874. */
  70875. _getViewMatrix(): Matrix;
  70876. private _tmpMatrix;
  70877. /**
  70878. * This function is called by the two RIG cameras.
  70879. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  70880. * @hidden
  70881. */
  70882. _getWebVRViewMatrix(): Matrix;
  70883. /** @hidden */
  70884. _getWebVRProjectionMatrix(): Matrix;
  70885. private _onGamepadConnectedObserver;
  70886. private _onGamepadDisconnectedObserver;
  70887. private _updateCacheWhenTrackingDisabledObserver;
  70888. /**
  70889. * Initializes the controllers and their meshes
  70890. */
  70891. initControllers(): void;
  70892. }
  70893. }
  70894. declare module BABYLON {
  70895. /**
  70896. * Size options for a post process
  70897. */
  70898. export type PostProcessOptions = {
  70899. width: number;
  70900. height: number;
  70901. };
  70902. /**
  70903. * PostProcess can be used to apply a shader to a texture after it has been rendered
  70904. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70905. */
  70906. export class PostProcess {
  70907. /** Name of the PostProcess. */
  70908. name: string;
  70909. /**
  70910. * Gets or sets the unique id of the post process
  70911. */
  70912. uniqueId: number;
  70913. /**
  70914. * Width of the texture to apply the post process on
  70915. */
  70916. width: number;
  70917. /**
  70918. * Height of the texture to apply the post process on
  70919. */
  70920. height: number;
  70921. /**
  70922. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  70923. * @hidden
  70924. */
  70925. _outputTexture: Nullable<InternalTexture>;
  70926. /**
  70927. * Sampling mode used by the shader
  70928. * See https://doc.babylonjs.com/classes/3.1/texture
  70929. */
  70930. renderTargetSamplingMode: number;
  70931. /**
  70932. * Clear color to use when screen clearing
  70933. */
  70934. clearColor: Color4;
  70935. /**
  70936. * If the buffer needs to be cleared before applying the post process. (default: true)
  70937. * Should be set to false if shader will overwrite all previous pixels.
  70938. */
  70939. autoClear: boolean;
  70940. /**
  70941. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  70942. */
  70943. alphaMode: number;
  70944. /**
  70945. * Sets the setAlphaBlendConstants of the babylon engine
  70946. */
  70947. alphaConstants: Color4;
  70948. /**
  70949. * Animations to be used for the post processing
  70950. */
  70951. animations: Animation[];
  70952. /**
  70953. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  70954. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  70955. */
  70956. enablePixelPerfectMode: boolean;
  70957. /**
  70958. * Force the postprocess to be applied without taking in account viewport
  70959. */
  70960. forceFullscreenViewport: boolean;
  70961. /**
  70962. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  70963. *
  70964. * | Value | Type | Description |
  70965. * | ----- | ----------------------------------- | ----------- |
  70966. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  70967. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  70968. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  70969. *
  70970. */
  70971. scaleMode: number;
  70972. /**
  70973. * Force textures to be a power of two (default: false)
  70974. */
  70975. alwaysForcePOT: boolean;
  70976. private _samples;
  70977. /**
  70978. * Number of sample textures (default: 1)
  70979. */
  70980. samples: number;
  70981. /**
  70982. * Modify the scale of the post process to be the same as the viewport (default: false)
  70983. */
  70984. adaptScaleToCurrentViewport: boolean;
  70985. private _camera;
  70986. private _scene;
  70987. private _engine;
  70988. private _options;
  70989. private _reusable;
  70990. private _textureType;
  70991. /**
  70992. * Smart array of input and output textures for the post process.
  70993. * @hidden
  70994. */
  70995. _textures: SmartArray<InternalTexture>;
  70996. /**
  70997. * The index in _textures that corresponds to the output texture.
  70998. * @hidden
  70999. */
  71000. _currentRenderTextureInd: number;
  71001. private _effect;
  71002. private _samplers;
  71003. private _fragmentUrl;
  71004. private _vertexUrl;
  71005. private _parameters;
  71006. private _scaleRatio;
  71007. protected _indexParameters: any;
  71008. private _shareOutputWithPostProcess;
  71009. private _texelSize;
  71010. private _forcedOutputTexture;
  71011. /**
  71012. * Returns the fragment url or shader name used in the post process.
  71013. * @returns the fragment url or name in the shader store.
  71014. */
  71015. getEffectName(): string;
  71016. /**
  71017. * An event triggered when the postprocess is activated.
  71018. */
  71019. onActivateObservable: Observable<Camera>;
  71020. private _onActivateObserver;
  71021. /**
  71022. * A function that is added to the onActivateObservable
  71023. */
  71024. onActivate: Nullable<(camera: Camera) => void>;
  71025. /**
  71026. * An event triggered when the postprocess changes its size.
  71027. */
  71028. onSizeChangedObservable: Observable<PostProcess>;
  71029. private _onSizeChangedObserver;
  71030. /**
  71031. * A function that is added to the onSizeChangedObservable
  71032. */
  71033. onSizeChanged: (postProcess: PostProcess) => void;
  71034. /**
  71035. * An event triggered when the postprocess applies its effect.
  71036. */
  71037. onApplyObservable: Observable<Effect>;
  71038. private _onApplyObserver;
  71039. /**
  71040. * A function that is added to the onApplyObservable
  71041. */
  71042. onApply: (effect: Effect) => void;
  71043. /**
  71044. * An event triggered before rendering the postprocess
  71045. */
  71046. onBeforeRenderObservable: Observable<Effect>;
  71047. private _onBeforeRenderObserver;
  71048. /**
  71049. * A function that is added to the onBeforeRenderObservable
  71050. */
  71051. onBeforeRender: (effect: Effect) => void;
  71052. /**
  71053. * An event triggered after rendering the postprocess
  71054. */
  71055. onAfterRenderObservable: Observable<Effect>;
  71056. private _onAfterRenderObserver;
  71057. /**
  71058. * A function that is added to the onAfterRenderObservable
  71059. */
  71060. onAfterRender: (efect: Effect) => void;
  71061. /**
  71062. * 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
  71063. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  71064. */
  71065. inputTexture: InternalTexture;
  71066. /**
  71067. * Gets the camera which post process is applied to.
  71068. * @returns The camera the post process is applied to.
  71069. */
  71070. getCamera(): Camera;
  71071. /**
  71072. * Gets the texel size of the postprocess.
  71073. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  71074. */
  71075. readonly texelSize: Vector2;
  71076. /**
  71077. * Creates a new instance PostProcess
  71078. * @param name The name of the PostProcess.
  71079. * @param fragmentUrl The url of the fragment shader to be used.
  71080. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  71081. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  71082. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  71083. * @param camera The camera to apply the render pass to.
  71084. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71085. * @param engine The engine which the post process will be applied. (default: current engine)
  71086. * @param reusable If the post process can be reused on the same frame. (default: false)
  71087. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  71088. * @param textureType Type of textures used when performing the post process. (default: 0)
  71089. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  71090. * @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
  71091. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  71092. */
  71093. constructor(
  71094. /** Name of the PostProcess. */
  71095. 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);
  71096. /**
  71097. * Gets a string idenfifying the name of the class
  71098. * @returns "PostProcess" string
  71099. */
  71100. getClassName(): string;
  71101. /**
  71102. * Gets the engine which this post process belongs to.
  71103. * @returns The engine the post process was enabled with.
  71104. */
  71105. getEngine(): Engine;
  71106. /**
  71107. * The effect that is created when initializing the post process.
  71108. * @returns The created effect corrisponding the the postprocess.
  71109. */
  71110. getEffect(): Effect;
  71111. /**
  71112. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  71113. * @param postProcess The post process to share the output with.
  71114. * @returns This post process.
  71115. */
  71116. shareOutputWith(postProcess: PostProcess): PostProcess;
  71117. /**
  71118. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  71119. * This should be called if the post process that shares output with this post process is disabled/disposed.
  71120. */
  71121. useOwnOutput(): void;
  71122. /**
  71123. * Updates the effect with the current post process compile time values and recompiles the shader.
  71124. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  71125. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  71126. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  71127. * @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
  71128. * @param onCompiled Called when the shader has been compiled.
  71129. * @param onError Called if there is an error when compiling a shader.
  71130. */
  71131. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  71132. /**
  71133. * The post process is reusable if it can be used multiple times within one frame.
  71134. * @returns If the post process is reusable
  71135. */
  71136. isReusable(): boolean;
  71137. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  71138. markTextureDirty(): void;
  71139. /**
  71140. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  71141. * 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.
  71142. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  71143. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  71144. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  71145. * @returns The target texture that was bound to be written to.
  71146. */
  71147. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  71148. /**
  71149. * If the post process is supported.
  71150. */
  71151. readonly isSupported: boolean;
  71152. /**
  71153. * The aspect ratio of the output texture.
  71154. */
  71155. readonly aspectRatio: number;
  71156. /**
  71157. * Get a value indicating if the post-process is ready to be used
  71158. * @returns true if the post-process is ready (shader is compiled)
  71159. */
  71160. isReady(): boolean;
  71161. /**
  71162. * Binds all textures and uniforms to the shader, this will be run on every pass.
  71163. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  71164. */
  71165. apply(): Nullable<Effect>;
  71166. private _disposeTextures;
  71167. /**
  71168. * Disposes the post process.
  71169. * @param camera The camera to dispose the post process on.
  71170. */
  71171. dispose(camera?: Camera): void;
  71172. }
  71173. }
  71174. declare module BABYLON {
  71175. /**
  71176. * PostProcessManager is used to manage one or more post processes or post process pipelines
  71177. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71178. */
  71179. export class PostProcessManager {
  71180. private _scene;
  71181. private _indexBuffer;
  71182. private _vertexBuffers;
  71183. /**
  71184. * Creates a new instance PostProcess
  71185. * @param scene The scene that the post process is associated with.
  71186. */
  71187. constructor(scene: Scene);
  71188. private _prepareBuffers;
  71189. private _buildIndexBuffer;
  71190. /**
  71191. * Rebuilds the vertex buffers of the manager.
  71192. * @hidden
  71193. */
  71194. _rebuild(): void;
  71195. /**
  71196. * Prepares a frame to be run through a post process.
  71197. * @param sourceTexture The input texture to the post procesess. (default: null)
  71198. * @param postProcesses An array of post processes to be run. (default: null)
  71199. * @returns True if the post processes were able to be run.
  71200. * @hidden
  71201. */
  71202. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  71203. /**
  71204. * Manually render a set of post processes to a texture.
  71205. * @param postProcesses An array of post processes to be run.
  71206. * @param targetTexture The target texture to render to.
  71207. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  71208. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  71209. * @param lodLevel defines which lod of the texture to render to
  71210. */
  71211. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  71212. /**
  71213. * Finalize the result of the output of the postprocesses.
  71214. * @param doNotPresent If true the result will not be displayed to the screen.
  71215. * @param targetTexture The target texture to render to.
  71216. * @param faceIndex The index of the face to bind the target texture to.
  71217. * @param postProcesses The array of post processes to render.
  71218. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  71219. * @hidden
  71220. */
  71221. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  71222. /**
  71223. * Disposes of the post process manager.
  71224. */
  71225. dispose(): void;
  71226. }
  71227. }
  71228. declare module BABYLON {
  71229. interface AbstractScene {
  71230. /**
  71231. * The list of layers (background and foreground) of the scene
  71232. */
  71233. layers: Array<Layer>;
  71234. }
  71235. /**
  71236. * Defines the layer scene component responsible to manage any layers
  71237. * in a given scene.
  71238. */
  71239. export class LayerSceneComponent implements ISceneComponent {
  71240. /**
  71241. * The component name helpfull to identify the component in the list of scene components.
  71242. */
  71243. readonly name: string;
  71244. /**
  71245. * The scene the component belongs to.
  71246. */
  71247. scene: Scene;
  71248. private _engine;
  71249. /**
  71250. * Creates a new instance of the component for the given scene
  71251. * @param scene Defines the scene to register the component in
  71252. */
  71253. constructor(scene: Scene);
  71254. /**
  71255. * Registers the component in a given scene
  71256. */
  71257. register(): void;
  71258. /**
  71259. * Rebuilds the elements related to this component in case of
  71260. * context lost for instance.
  71261. */
  71262. rebuild(): void;
  71263. /**
  71264. * Disposes the component and the associated ressources.
  71265. */
  71266. dispose(): void;
  71267. private _draw;
  71268. private _drawCameraPredicate;
  71269. private _drawCameraBackground;
  71270. private _drawCameraForeground;
  71271. private _drawRenderTargetPredicate;
  71272. private _drawRenderTargetBackground;
  71273. private _drawRenderTargetForeground;
  71274. }
  71275. }
  71276. declare module BABYLON {
  71277. /** @hidden */
  71278. export var layerPixelShader: {
  71279. name: string;
  71280. shader: string;
  71281. };
  71282. }
  71283. declare module BABYLON {
  71284. /** @hidden */
  71285. export var layerVertexShader: {
  71286. name: string;
  71287. shader: string;
  71288. };
  71289. }
  71290. declare module BABYLON {
  71291. /**
  71292. * This represents a full screen 2d layer.
  71293. * This can be useful to display a picture in the background of your scene for instance.
  71294. * @see https://www.babylonjs-playground.com/#08A2BS#1
  71295. */
  71296. export class Layer {
  71297. /**
  71298. * Define the name of the layer.
  71299. */
  71300. name: string;
  71301. /**
  71302. * Define the texture the layer should display.
  71303. */
  71304. texture: Nullable<Texture>;
  71305. /**
  71306. * Is the layer in background or foreground.
  71307. */
  71308. isBackground: boolean;
  71309. /**
  71310. * Define the color of the layer (instead of texture).
  71311. */
  71312. color: Color4;
  71313. /**
  71314. * Define the scale of the layer in order to zoom in out of the texture.
  71315. */
  71316. scale: Vector2;
  71317. /**
  71318. * Define an offset for the layer in order to shift the texture.
  71319. */
  71320. offset: Vector2;
  71321. /**
  71322. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  71323. */
  71324. alphaBlendingMode: number;
  71325. /**
  71326. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  71327. * Alpha test will not mix with the background color in case of transparency.
  71328. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  71329. */
  71330. alphaTest: boolean;
  71331. /**
  71332. * Define a mask to restrict the layer to only some of the scene cameras.
  71333. */
  71334. layerMask: number;
  71335. /**
  71336. * Define the list of render target the layer is visible into.
  71337. */
  71338. renderTargetTextures: RenderTargetTexture[];
  71339. /**
  71340. * Define if the layer is only used in renderTarget or if it also
  71341. * renders in the main frame buffer of the canvas.
  71342. */
  71343. renderOnlyInRenderTargetTextures: boolean;
  71344. private _scene;
  71345. private _vertexBuffers;
  71346. private _indexBuffer;
  71347. private _effect;
  71348. private _alphaTestEffect;
  71349. /**
  71350. * An event triggered when the layer is disposed.
  71351. */
  71352. onDisposeObservable: Observable<Layer>;
  71353. private _onDisposeObserver;
  71354. /**
  71355. * Back compatibility with callback before the onDisposeObservable existed.
  71356. * The set callback will be triggered when the layer has been disposed.
  71357. */
  71358. onDispose: () => void;
  71359. /**
  71360. * An event triggered before rendering the scene
  71361. */
  71362. onBeforeRenderObservable: Observable<Layer>;
  71363. private _onBeforeRenderObserver;
  71364. /**
  71365. * Back compatibility with callback before the onBeforeRenderObservable existed.
  71366. * The set callback will be triggered just before rendering the layer.
  71367. */
  71368. onBeforeRender: () => void;
  71369. /**
  71370. * An event triggered after rendering the scene
  71371. */
  71372. onAfterRenderObservable: Observable<Layer>;
  71373. private _onAfterRenderObserver;
  71374. /**
  71375. * Back compatibility with callback before the onAfterRenderObservable existed.
  71376. * The set callback will be triggered just after rendering the layer.
  71377. */
  71378. onAfterRender: () => void;
  71379. /**
  71380. * Instantiates a new layer.
  71381. * This represents a full screen 2d layer.
  71382. * This can be useful to display a picture in the background of your scene for instance.
  71383. * @see https://www.babylonjs-playground.com/#08A2BS#1
  71384. * @param name Define the name of the layer in the scene
  71385. * @param imgUrl Define the url of the texture to display in the layer
  71386. * @param scene Define the scene the layer belongs to
  71387. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  71388. * @param color Defines a color for the layer
  71389. */
  71390. constructor(
  71391. /**
  71392. * Define the name of the layer.
  71393. */
  71394. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  71395. private _createIndexBuffer;
  71396. /** @hidden */
  71397. _rebuild(): void;
  71398. /**
  71399. * Renders the layer in the scene.
  71400. */
  71401. render(): void;
  71402. /**
  71403. * Disposes and releases the associated ressources.
  71404. */
  71405. dispose(): void;
  71406. }
  71407. }
  71408. declare module BABYLON {
  71409. interface AbstractScene {
  71410. /**
  71411. * The list of procedural textures added to the scene
  71412. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  71413. */
  71414. proceduralTextures: Array<ProceduralTexture>;
  71415. }
  71416. /**
  71417. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  71418. * in a given scene.
  71419. */
  71420. export class ProceduralTextureSceneComponent implements ISceneComponent {
  71421. /**
  71422. * The component name helpfull to identify the component in the list of scene components.
  71423. */
  71424. readonly name: string;
  71425. /**
  71426. * The scene the component belongs to.
  71427. */
  71428. scene: Scene;
  71429. /**
  71430. * Creates a new instance of the component for the given scene
  71431. * @param scene Defines the scene to register the component in
  71432. */
  71433. constructor(scene: Scene);
  71434. /**
  71435. * Registers the component in a given scene
  71436. */
  71437. register(): void;
  71438. /**
  71439. * Rebuilds the elements related to this component in case of
  71440. * context lost for instance.
  71441. */
  71442. rebuild(): void;
  71443. /**
  71444. * Disposes the component and the associated ressources.
  71445. */
  71446. dispose(): void;
  71447. private _beforeClear;
  71448. }
  71449. }
  71450. declare module BABYLON {
  71451. /** @hidden */
  71452. export var proceduralVertexShader: {
  71453. name: string;
  71454. shader: string;
  71455. };
  71456. }
  71457. declare module BABYLON {
  71458. /**
  71459. * 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.
  71460. * This is the base class of any Procedural texture and contains most of the shareable code.
  71461. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  71462. */
  71463. export class ProceduralTexture extends Texture {
  71464. isCube: boolean;
  71465. /**
  71466. * Define if the texture is enabled or not (disabled texture will not render)
  71467. */
  71468. isEnabled: boolean;
  71469. /**
  71470. * Define if the texture must be cleared before rendering (default is true)
  71471. */
  71472. autoClear: boolean;
  71473. /**
  71474. * Callback called when the texture is generated
  71475. */
  71476. onGenerated: () => void;
  71477. /**
  71478. * Event raised when the texture is generated
  71479. */
  71480. onGeneratedObservable: Observable<ProceduralTexture>;
  71481. /** @hidden */
  71482. _generateMipMaps: boolean;
  71483. /** @hidden **/
  71484. _effect: Effect;
  71485. /** @hidden */
  71486. _textures: {
  71487. [key: string]: Texture;
  71488. };
  71489. private _size;
  71490. private _currentRefreshId;
  71491. private _refreshRate;
  71492. private _vertexBuffers;
  71493. private _indexBuffer;
  71494. private _uniforms;
  71495. private _samplers;
  71496. private _fragment;
  71497. private _floats;
  71498. private _ints;
  71499. private _floatsArrays;
  71500. private _colors3;
  71501. private _colors4;
  71502. private _vectors2;
  71503. private _vectors3;
  71504. private _matrices;
  71505. private _fallbackTexture;
  71506. private _fallbackTextureUsed;
  71507. private _engine;
  71508. private _cachedDefines;
  71509. private _contentUpdateId;
  71510. private _contentData;
  71511. /**
  71512. * Instantiates a new procedural texture.
  71513. * 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.
  71514. * This is the base class of any Procedural texture and contains most of the shareable code.
  71515. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  71516. * @param name Define the name of the texture
  71517. * @param size Define the size of the texture to create
  71518. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  71519. * @param scene Define the scene the texture belongs to
  71520. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  71521. * @param generateMipMaps Define if the texture should creates mip maps or not
  71522. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  71523. */
  71524. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  71525. /**
  71526. * The effect that is created when initializing the post process.
  71527. * @returns The created effect corrisponding the the postprocess.
  71528. */
  71529. getEffect(): Effect;
  71530. /**
  71531. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  71532. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  71533. */
  71534. getContent(): Nullable<ArrayBufferView>;
  71535. private _createIndexBuffer;
  71536. /** @hidden */
  71537. _rebuild(): void;
  71538. /**
  71539. * Resets the texture in order to recreate its associated resources.
  71540. * This can be called in case of context loss
  71541. */
  71542. reset(): void;
  71543. protected _getDefines(): string;
  71544. /**
  71545. * Is the texture ready to be used ? (rendered at least once)
  71546. * @returns true if ready, otherwise, false.
  71547. */
  71548. isReady(): boolean;
  71549. /**
  71550. * Resets the refresh counter of the texture and start bak from scratch.
  71551. * Could be useful to regenerate the texture if it is setup to render only once.
  71552. */
  71553. resetRefreshCounter(): void;
  71554. /**
  71555. * Set the fragment shader to use in order to render the texture.
  71556. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  71557. */
  71558. setFragment(fragment: any): void;
  71559. /**
  71560. * Define the refresh rate of the texture or the rendering frequency.
  71561. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  71562. */
  71563. refreshRate: number;
  71564. /** @hidden */
  71565. _shouldRender(): boolean;
  71566. /**
  71567. * Get the size the texture is rendering at.
  71568. * @returns the size (texture is always squared)
  71569. */
  71570. getRenderSize(): number;
  71571. /**
  71572. * Resize the texture to new value.
  71573. * @param size Define the new size the texture should have
  71574. * @param generateMipMaps Define whether the new texture should create mip maps
  71575. */
  71576. resize(size: number, generateMipMaps: boolean): void;
  71577. private _checkUniform;
  71578. /**
  71579. * Set a texture in the shader program used to render.
  71580. * @param name Define the name of the uniform samplers as defined in the shader
  71581. * @param texture Define the texture to bind to this sampler
  71582. * @return the texture itself allowing "fluent" like uniform updates
  71583. */
  71584. setTexture(name: string, texture: Texture): ProceduralTexture;
  71585. /**
  71586. * Set a float in the shader.
  71587. * @param name Define the name of the uniform as defined in the shader
  71588. * @param value Define the value to give to the uniform
  71589. * @return the texture itself allowing "fluent" like uniform updates
  71590. */
  71591. setFloat(name: string, value: number): ProceduralTexture;
  71592. /**
  71593. * Set a int in the shader.
  71594. * @param name Define the name of the uniform as defined in the shader
  71595. * @param value Define the value to give to the uniform
  71596. * @return the texture itself allowing "fluent" like uniform updates
  71597. */
  71598. setInt(name: string, value: number): ProceduralTexture;
  71599. /**
  71600. * Set an array of floats in the shader.
  71601. * @param name Define the name of the uniform as defined in the shader
  71602. * @param value Define the value to give to the uniform
  71603. * @return the texture itself allowing "fluent" like uniform updates
  71604. */
  71605. setFloats(name: string, value: number[]): ProceduralTexture;
  71606. /**
  71607. * Set a vec3 in the shader from a Color3.
  71608. * @param name Define the name of the uniform as defined in the shader
  71609. * @param value Define the value to give to the uniform
  71610. * @return the texture itself allowing "fluent" like uniform updates
  71611. */
  71612. setColor3(name: string, value: Color3): ProceduralTexture;
  71613. /**
  71614. * Set a vec4 in the shader from a Color4.
  71615. * @param name Define the name of the uniform as defined in the shader
  71616. * @param value Define the value to give to the uniform
  71617. * @return the texture itself allowing "fluent" like uniform updates
  71618. */
  71619. setColor4(name: string, value: Color4): ProceduralTexture;
  71620. /**
  71621. * Set a vec2 in the shader from a Vector2.
  71622. * @param name Define the name of the uniform as defined in the shader
  71623. * @param value Define the value to give to the uniform
  71624. * @return the texture itself allowing "fluent" like uniform updates
  71625. */
  71626. setVector2(name: string, value: Vector2): ProceduralTexture;
  71627. /**
  71628. * Set a vec3 in the shader from a Vector3.
  71629. * @param name Define the name of the uniform as defined in the shader
  71630. * @param value Define the value to give to the uniform
  71631. * @return the texture itself allowing "fluent" like uniform updates
  71632. */
  71633. setVector3(name: string, value: Vector3): ProceduralTexture;
  71634. /**
  71635. * Set a mat4 in the shader from a MAtrix.
  71636. * @param name Define the name of the uniform as defined in the shader
  71637. * @param value Define the value to give to the uniform
  71638. * @return the texture itself allowing "fluent" like uniform updates
  71639. */
  71640. setMatrix(name: string, value: Matrix): ProceduralTexture;
  71641. /**
  71642. * Render the texture to its associated render target.
  71643. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  71644. */
  71645. render(useCameraPostProcess?: boolean): void;
  71646. /**
  71647. * Clone the texture.
  71648. * @returns the cloned texture
  71649. */
  71650. clone(): ProceduralTexture;
  71651. /**
  71652. * Dispose the texture and release its asoociated resources.
  71653. */
  71654. dispose(): void;
  71655. }
  71656. }
  71657. declare module BABYLON {
  71658. /**
  71659. * This represents the base class for particle system in Babylon.
  71660. * 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.
  71661. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  71662. * @example https://doc.babylonjs.com/babylon101/particles
  71663. */
  71664. export class BaseParticleSystem {
  71665. /**
  71666. * Source color is added to the destination color without alpha affecting the result
  71667. */
  71668. static BLENDMODE_ONEONE: number;
  71669. /**
  71670. * Blend current color and particle color using particle’s alpha
  71671. */
  71672. static BLENDMODE_STANDARD: number;
  71673. /**
  71674. * Add current color and particle color multiplied by particle’s alpha
  71675. */
  71676. static BLENDMODE_ADD: number;
  71677. /**
  71678. * Multiply current color with particle color
  71679. */
  71680. static BLENDMODE_MULTIPLY: number;
  71681. /**
  71682. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  71683. */
  71684. static BLENDMODE_MULTIPLYADD: number;
  71685. /**
  71686. * List of animations used by the particle system.
  71687. */
  71688. animations: Animation[];
  71689. /**
  71690. * The id of the Particle system.
  71691. */
  71692. id: string;
  71693. /**
  71694. * The friendly name of the Particle system.
  71695. */
  71696. name: string;
  71697. /**
  71698. * The rendering group used by the Particle system to chose when to render.
  71699. */
  71700. renderingGroupId: number;
  71701. /**
  71702. * The emitter represents the Mesh or position we are attaching the particle system to.
  71703. */
  71704. emitter: Nullable<AbstractMesh | Vector3>;
  71705. /**
  71706. * The maximum number of particles to emit per frame
  71707. */
  71708. emitRate: number;
  71709. /**
  71710. * If you want to launch only a few particles at once, that can be done, as well.
  71711. */
  71712. manualEmitCount: number;
  71713. /**
  71714. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  71715. */
  71716. updateSpeed: number;
  71717. /**
  71718. * The amount of time the particle system is running (depends of the overall update speed).
  71719. */
  71720. targetStopDuration: number;
  71721. /**
  71722. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  71723. */
  71724. disposeOnStop: boolean;
  71725. /**
  71726. * Minimum power of emitting particles.
  71727. */
  71728. minEmitPower: number;
  71729. /**
  71730. * Maximum power of emitting particles.
  71731. */
  71732. maxEmitPower: number;
  71733. /**
  71734. * Minimum life time of emitting particles.
  71735. */
  71736. minLifeTime: number;
  71737. /**
  71738. * Maximum life time of emitting particles.
  71739. */
  71740. maxLifeTime: number;
  71741. /**
  71742. * Minimum Size of emitting particles.
  71743. */
  71744. minSize: number;
  71745. /**
  71746. * Maximum Size of emitting particles.
  71747. */
  71748. maxSize: number;
  71749. /**
  71750. * Minimum scale of emitting particles on X axis.
  71751. */
  71752. minScaleX: number;
  71753. /**
  71754. * Maximum scale of emitting particles on X axis.
  71755. */
  71756. maxScaleX: number;
  71757. /**
  71758. * Minimum scale of emitting particles on Y axis.
  71759. */
  71760. minScaleY: number;
  71761. /**
  71762. * Maximum scale of emitting particles on Y axis.
  71763. */
  71764. maxScaleY: number;
  71765. /**
  71766. * Gets or sets the minimal initial rotation in radians.
  71767. */
  71768. minInitialRotation: number;
  71769. /**
  71770. * Gets or sets the maximal initial rotation in radians.
  71771. */
  71772. maxInitialRotation: number;
  71773. /**
  71774. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  71775. */
  71776. minAngularSpeed: number;
  71777. /**
  71778. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  71779. */
  71780. maxAngularSpeed: number;
  71781. /**
  71782. * The texture used to render each particle. (this can be a spritesheet)
  71783. */
  71784. particleTexture: Nullable<Texture>;
  71785. /**
  71786. * The layer mask we are rendering the particles through.
  71787. */
  71788. layerMask: number;
  71789. /**
  71790. * This can help using your own shader to render the particle system.
  71791. * The according effect will be created
  71792. */
  71793. customShader: any;
  71794. /**
  71795. * By default particle system starts as soon as they are created. This prevents the
  71796. * automatic start to happen and let you decide when to start emitting particles.
  71797. */
  71798. preventAutoStart: boolean;
  71799. private _noiseTexture;
  71800. /**
  71801. * Gets or sets a texture used to add random noise to particle positions
  71802. */
  71803. noiseTexture: Nullable<ProceduralTexture>;
  71804. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  71805. noiseStrength: Vector3;
  71806. /**
  71807. * Callback triggered when the particle animation is ending.
  71808. */
  71809. onAnimationEnd: Nullable<() => void>;
  71810. /**
  71811. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  71812. */
  71813. blendMode: number;
  71814. /**
  71815. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  71816. * to override the particles.
  71817. */
  71818. forceDepthWrite: boolean;
  71819. /** 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 */
  71820. preWarmCycles: number;
  71821. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  71822. preWarmStepOffset: number;
  71823. /**
  71824. * 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)
  71825. */
  71826. spriteCellChangeSpeed: number;
  71827. /**
  71828. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  71829. */
  71830. startSpriteCellID: number;
  71831. /**
  71832. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  71833. */
  71834. endSpriteCellID: number;
  71835. /**
  71836. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  71837. */
  71838. spriteCellWidth: number;
  71839. /**
  71840. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  71841. */
  71842. spriteCellHeight: number;
  71843. /**
  71844. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  71845. */
  71846. spriteRandomStartCell: boolean;
  71847. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  71848. translationPivot: Vector2;
  71849. /** @hidden */
  71850. protected _isAnimationSheetEnabled: boolean;
  71851. /**
  71852. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  71853. */
  71854. beginAnimationOnStart: boolean;
  71855. /**
  71856. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  71857. */
  71858. beginAnimationFrom: number;
  71859. /**
  71860. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  71861. */
  71862. beginAnimationTo: number;
  71863. /**
  71864. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  71865. */
  71866. beginAnimationLoop: boolean;
  71867. /**
  71868. * Gets or sets a world offset applied to all particles
  71869. */
  71870. worldOffset: Vector3;
  71871. /**
  71872. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  71873. */
  71874. isAnimationSheetEnabled: boolean;
  71875. /**
  71876. * Get hosting scene
  71877. * @returns the scene
  71878. */
  71879. getScene(): Scene;
  71880. /**
  71881. * You can use gravity if you want to give an orientation to your particles.
  71882. */
  71883. gravity: Vector3;
  71884. protected _colorGradients: Nullable<Array<ColorGradient>>;
  71885. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  71886. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  71887. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  71888. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  71889. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  71890. protected _dragGradients: Nullable<Array<FactorGradient>>;
  71891. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  71892. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  71893. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  71894. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  71895. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  71896. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  71897. /**
  71898. * Defines the delay in milliseconds before starting the system (0 by default)
  71899. */
  71900. startDelay: number;
  71901. /**
  71902. * Gets the current list of drag gradients.
  71903. * You must use addDragGradient and removeDragGradient to udpate this list
  71904. * @returns the list of drag gradients
  71905. */
  71906. getDragGradients(): Nullable<Array<FactorGradient>>;
  71907. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  71908. limitVelocityDamping: number;
  71909. /**
  71910. * Gets the current list of limit velocity gradients.
  71911. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  71912. * @returns the list of limit velocity gradients
  71913. */
  71914. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  71915. /**
  71916. * Gets the current list of color gradients.
  71917. * You must use addColorGradient and removeColorGradient to udpate this list
  71918. * @returns the list of color gradients
  71919. */
  71920. getColorGradients(): Nullable<Array<ColorGradient>>;
  71921. /**
  71922. * Gets the current list of size gradients.
  71923. * You must use addSizeGradient and removeSizeGradient to udpate this list
  71924. * @returns the list of size gradients
  71925. */
  71926. getSizeGradients(): Nullable<Array<FactorGradient>>;
  71927. /**
  71928. * Gets the current list of color remap gradients.
  71929. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  71930. * @returns the list of color remap gradients
  71931. */
  71932. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  71933. /**
  71934. * Gets the current list of alpha remap gradients.
  71935. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  71936. * @returns the list of alpha remap gradients
  71937. */
  71938. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  71939. /**
  71940. * Gets the current list of life time gradients.
  71941. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  71942. * @returns the list of life time gradients
  71943. */
  71944. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  71945. /**
  71946. * Gets the current list of angular speed gradients.
  71947. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  71948. * @returns the list of angular speed gradients
  71949. */
  71950. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  71951. /**
  71952. * Gets the current list of velocity gradients.
  71953. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  71954. * @returns the list of velocity gradients
  71955. */
  71956. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  71957. /**
  71958. * Gets the current list of start size gradients.
  71959. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  71960. * @returns the list of start size gradients
  71961. */
  71962. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  71963. /**
  71964. * Gets the current list of emit rate gradients.
  71965. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  71966. * @returns the list of emit rate gradients
  71967. */
  71968. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  71969. /**
  71970. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71971. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71972. */
  71973. direction1: Vector3;
  71974. /**
  71975. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71976. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71977. */
  71978. direction2: Vector3;
  71979. /**
  71980. * 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.
  71981. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71982. */
  71983. minEmitBox: Vector3;
  71984. /**
  71985. * 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.
  71986. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71987. */
  71988. maxEmitBox: Vector3;
  71989. /**
  71990. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  71991. */
  71992. color1: Color4;
  71993. /**
  71994. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  71995. */
  71996. color2: Color4;
  71997. /**
  71998. * Color the particle will have at the end of its lifetime
  71999. */
  72000. colorDead: Color4;
  72001. /**
  72002. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  72003. */
  72004. textureMask: Color4;
  72005. /**
  72006. * The particle emitter type defines the emitter used by the particle system.
  72007. * It can be for example box, sphere, or cone...
  72008. */
  72009. particleEmitterType: IParticleEmitterType;
  72010. /** @hidden */
  72011. _isSubEmitter: boolean;
  72012. /**
  72013. * Gets or sets the billboard mode to use when isBillboardBased = true.
  72014. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  72015. */
  72016. billboardMode: number;
  72017. protected _isBillboardBased: boolean;
  72018. /**
  72019. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  72020. */
  72021. isBillboardBased: boolean;
  72022. /**
  72023. * The scene the particle system belongs to.
  72024. */
  72025. protected _scene: Scene;
  72026. /**
  72027. * Local cache of defines for image processing.
  72028. */
  72029. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  72030. /**
  72031. * Default configuration related to image processing available in the standard Material.
  72032. */
  72033. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  72034. /**
  72035. * Gets the image processing configuration used either in this material.
  72036. */
  72037. /**
  72038. * Sets the Default image processing configuration used either in the this material.
  72039. *
  72040. * If sets to null, the scene one is in use.
  72041. */
  72042. imageProcessingConfiguration: ImageProcessingConfiguration;
  72043. /**
  72044. * Attaches a new image processing configuration to the Standard Material.
  72045. * @param configuration
  72046. */
  72047. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  72048. /** @hidden */
  72049. protected _reset(): void;
  72050. /** @hidden */
  72051. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  72052. /**
  72053. * Instantiates a particle system.
  72054. * 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.
  72055. * @param name The name of the particle system
  72056. */
  72057. constructor(name: string);
  72058. /**
  72059. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  72060. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  72061. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  72062. * @returns the emitter
  72063. */
  72064. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  72065. /**
  72066. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  72067. * @param radius The radius of the hemisphere to emit from
  72068. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  72069. * @returns the emitter
  72070. */
  72071. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  72072. /**
  72073. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  72074. * @param radius The radius of the sphere to emit from
  72075. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  72076. * @returns the emitter
  72077. */
  72078. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  72079. /**
  72080. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  72081. * @param radius The radius of the sphere to emit from
  72082. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  72083. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  72084. * @returns the emitter
  72085. */
  72086. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  72087. /**
  72088. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  72089. * @param radius The radius of the emission cylinder
  72090. * @param height The height of the emission cylinder
  72091. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  72092. * @param directionRandomizer How much to randomize the particle direction [0-1]
  72093. * @returns the emitter
  72094. */
  72095. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  72096. /**
  72097. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  72098. * @param radius The radius of the cylinder to emit from
  72099. * @param height The height of the emission cylinder
  72100. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72101. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  72102. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  72103. * @returns the emitter
  72104. */
  72105. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  72106. /**
  72107. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  72108. * @param radius The radius of the cone to emit from
  72109. * @param angle The base angle of the cone
  72110. * @returns the emitter
  72111. */
  72112. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  72113. /**
  72114. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  72115. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  72116. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  72117. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  72118. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  72119. * @returns the emitter
  72120. */
  72121. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  72122. }
  72123. }
  72124. declare module BABYLON {
  72125. /**
  72126. * Type of sub emitter
  72127. */
  72128. export enum SubEmitterType {
  72129. /**
  72130. * Attached to the particle over it's lifetime
  72131. */
  72132. ATTACHED = 0,
  72133. /**
  72134. * Created when the particle dies
  72135. */
  72136. END = 1
  72137. }
  72138. /**
  72139. * Sub emitter class used to emit particles from an existing particle
  72140. */
  72141. export class SubEmitter {
  72142. /**
  72143. * the particle system to be used by the sub emitter
  72144. */
  72145. particleSystem: ParticleSystem;
  72146. /**
  72147. * Type of the submitter (Default: END)
  72148. */
  72149. type: SubEmitterType;
  72150. /**
  72151. * 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)
  72152. * Note: This only is supported when using an emitter of type Mesh
  72153. */
  72154. inheritDirection: boolean;
  72155. /**
  72156. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  72157. */
  72158. inheritedVelocityAmount: number;
  72159. /**
  72160. * Creates a sub emitter
  72161. * @param particleSystem the particle system to be used by the sub emitter
  72162. */
  72163. constructor(
  72164. /**
  72165. * the particle system to be used by the sub emitter
  72166. */
  72167. particleSystem: ParticleSystem);
  72168. /**
  72169. * Clones the sub emitter
  72170. * @returns the cloned sub emitter
  72171. */
  72172. clone(): SubEmitter;
  72173. /**
  72174. * Serialize current object to a JSON object
  72175. * @returns the serialized object
  72176. */
  72177. serialize(): any;
  72178. /** @hidden */
  72179. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  72180. /**
  72181. * Creates a new SubEmitter from a serialized JSON version
  72182. * @param serializationObject defines the JSON object to read from
  72183. * @param scene defines the hosting scene
  72184. * @param rootUrl defines the rootUrl for data loading
  72185. * @returns a new SubEmitter
  72186. */
  72187. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  72188. /** Release associated resources */
  72189. dispose(): void;
  72190. }
  72191. }
  72192. declare module BABYLON {
  72193. /** @hidden */
  72194. export var clipPlaneFragmentDeclaration: {
  72195. name: string;
  72196. shader: string;
  72197. };
  72198. }
  72199. declare module BABYLON {
  72200. /** @hidden */
  72201. export var imageProcessingDeclaration: {
  72202. name: string;
  72203. shader: string;
  72204. };
  72205. }
  72206. declare module BABYLON {
  72207. /** @hidden */
  72208. export var imageProcessingFunctions: {
  72209. name: string;
  72210. shader: string;
  72211. };
  72212. }
  72213. declare module BABYLON {
  72214. /** @hidden */
  72215. export var clipPlaneFragment: {
  72216. name: string;
  72217. shader: string;
  72218. };
  72219. }
  72220. declare module BABYLON {
  72221. /** @hidden */
  72222. export var particlesPixelShader: {
  72223. name: string;
  72224. shader: string;
  72225. };
  72226. }
  72227. declare module BABYLON {
  72228. /** @hidden */
  72229. export var clipPlaneVertexDeclaration: {
  72230. name: string;
  72231. shader: string;
  72232. };
  72233. }
  72234. declare module BABYLON {
  72235. /** @hidden */
  72236. export var clipPlaneVertex: {
  72237. name: string;
  72238. shader: string;
  72239. };
  72240. }
  72241. declare module BABYLON {
  72242. /** @hidden */
  72243. export var particlesVertexShader: {
  72244. name: string;
  72245. shader: string;
  72246. };
  72247. }
  72248. declare module BABYLON {
  72249. /**
  72250. * This represents a particle system in Babylon.
  72251. * 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.
  72252. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  72253. * @example https://doc.babylonjs.com/babylon101/particles
  72254. */
  72255. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  72256. /**
  72257. * Billboard mode will only apply to Y axis
  72258. */
  72259. static readonly BILLBOARDMODE_Y: number;
  72260. /**
  72261. * Billboard mode will apply to all axes
  72262. */
  72263. static readonly BILLBOARDMODE_ALL: number;
  72264. /**
  72265. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  72266. */
  72267. static readonly BILLBOARDMODE_STRETCHED: number;
  72268. /**
  72269. * This function can be defined to provide custom update for active particles.
  72270. * This function will be called instead of regular update (age, position, color, etc.).
  72271. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  72272. */
  72273. updateFunction: (particles: Particle[]) => void;
  72274. private _emitterWorldMatrix;
  72275. /**
  72276. * This function can be defined to specify initial direction for every new particle.
  72277. * It by default use the emitterType defined function
  72278. */
  72279. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  72280. /**
  72281. * This function can be defined to specify initial position for every new particle.
  72282. * It by default use the emitterType defined function
  72283. */
  72284. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  72285. /**
  72286. * @hidden
  72287. */
  72288. _inheritedVelocityOffset: Vector3;
  72289. /**
  72290. * An event triggered when the system is disposed
  72291. */
  72292. onDisposeObservable: Observable<ParticleSystem>;
  72293. private _onDisposeObserver;
  72294. /**
  72295. * Sets a callback that will be triggered when the system is disposed
  72296. */
  72297. onDispose: () => void;
  72298. private _particles;
  72299. private _epsilon;
  72300. private _capacity;
  72301. private _stockParticles;
  72302. private _newPartsExcess;
  72303. private _vertexData;
  72304. private _vertexBuffer;
  72305. private _vertexBuffers;
  72306. private _spriteBuffer;
  72307. private _indexBuffer;
  72308. private _effect;
  72309. private _customEffect;
  72310. private _cachedDefines;
  72311. private _scaledColorStep;
  72312. private _colorDiff;
  72313. private _scaledDirection;
  72314. private _scaledGravity;
  72315. private _currentRenderId;
  72316. private _alive;
  72317. private _useInstancing;
  72318. private _started;
  72319. private _stopped;
  72320. private _actualFrame;
  72321. private _scaledUpdateSpeed;
  72322. private _vertexBufferSize;
  72323. /** @hidden */
  72324. _currentEmitRateGradient: Nullable<FactorGradient>;
  72325. /** @hidden */
  72326. _currentEmitRate1: number;
  72327. /** @hidden */
  72328. _currentEmitRate2: number;
  72329. /** @hidden */
  72330. _currentStartSizeGradient: Nullable<FactorGradient>;
  72331. /** @hidden */
  72332. _currentStartSize1: number;
  72333. /** @hidden */
  72334. _currentStartSize2: number;
  72335. private readonly _rawTextureWidth;
  72336. private _rampGradientsTexture;
  72337. private _useRampGradients;
  72338. /** Gets or sets a boolean indicating that ramp gradients must be used
  72339. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  72340. */
  72341. useRampGradients: boolean;
  72342. /**
  72343. * 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.
  72344. * 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: [])
  72345. */
  72346. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  72347. private _subEmitters;
  72348. /**
  72349. * @hidden
  72350. * If the particle systems emitter should be disposed when the particle system is disposed
  72351. */
  72352. _disposeEmitterOnDispose: boolean;
  72353. /**
  72354. * The current active Sub-systems, this property is used by the root particle system only.
  72355. */
  72356. activeSubSystems: Array<ParticleSystem>;
  72357. private _rootParticleSystem;
  72358. /**
  72359. * Gets the current list of active particles
  72360. */
  72361. readonly particles: Particle[];
  72362. /**
  72363. * Returns the string "ParticleSystem"
  72364. * @returns a string containing the class name
  72365. */
  72366. getClassName(): string;
  72367. /**
  72368. * Instantiates a particle system.
  72369. * 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.
  72370. * @param name The name of the particle system
  72371. * @param capacity The max number of particles alive at the same time
  72372. * @param scene The scene the particle system belongs to
  72373. * @param customEffect a custom effect used to change the way particles are rendered by default
  72374. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  72375. * @param epsilon Offset used to render the particles
  72376. */
  72377. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  72378. private _addFactorGradient;
  72379. private _removeFactorGradient;
  72380. /**
  72381. * Adds a new life time gradient
  72382. * @param gradient defines the gradient to use (between 0 and 1)
  72383. * @param factor defines the life time factor to affect to the specified gradient
  72384. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72385. * @returns the current particle system
  72386. */
  72387. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72388. /**
  72389. * Remove a specific life time gradient
  72390. * @param gradient defines the gradient to remove
  72391. * @returns the current particle system
  72392. */
  72393. removeLifeTimeGradient(gradient: number): IParticleSystem;
  72394. /**
  72395. * Adds a new size gradient
  72396. * @param gradient defines the gradient to use (between 0 and 1)
  72397. * @param factor defines the size factor to affect to the specified gradient
  72398. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72399. * @returns the current particle system
  72400. */
  72401. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72402. /**
  72403. * Remove a specific size gradient
  72404. * @param gradient defines the gradient to remove
  72405. * @returns the current particle system
  72406. */
  72407. removeSizeGradient(gradient: number): IParticleSystem;
  72408. /**
  72409. * Adds a new color remap gradient
  72410. * @param gradient defines the gradient to use (between 0 and 1)
  72411. * @param min defines the color remap minimal range
  72412. * @param max defines the color remap maximal range
  72413. * @returns the current particle system
  72414. */
  72415. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72416. /**
  72417. * Remove a specific color remap gradient
  72418. * @param gradient defines the gradient to remove
  72419. * @returns the current particle system
  72420. */
  72421. removeColorRemapGradient(gradient: number): IParticleSystem;
  72422. /**
  72423. * Adds a new alpha remap gradient
  72424. * @param gradient defines the gradient to use (between 0 and 1)
  72425. * @param min defines the alpha remap minimal range
  72426. * @param max defines the alpha remap maximal range
  72427. * @returns the current particle system
  72428. */
  72429. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72430. /**
  72431. * Remove a specific alpha remap gradient
  72432. * @param gradient defines the gradient to remove
  72433. * @returns the current particle system
  72434. */
  72435. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  72436. /**
  72437. * Adds a new angular speed gradient
  72438. * @param gradient defines the gradient to use (between 0 and 1)
  72439. * @param factor defines the angular speed to affect to the specified gradient
  72440. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72441. * @returns the current particle system
  72442. */
  72443. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72444. /**
  72445. * Remove a specific angular speed gradient
  72446. * @param gradient defines the gradient to remove
  72447. * @returns the current particle system
  72448. */
  72449. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  72450. /**
  72451. * Adds a new velocity gradient
  72452. * @param gradient defines the gradient to use (between 0 and 1)
  72453. * @param factor defines the velocity to affect to the specified gradient
  72454. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72455. * @returns the current particle system
  72456. */
  72457. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72458. /**
  72459. * Remove a specific velocity gradient
  72460. * @param gradient defines the gradient to remove
  72461. * @returns the current particle system
  72462. */
  72463. removeVelocityGradient(gradient: number): IParticleSystem;
  72464. /**
  72465. * Adds a new limit velocity gradient
  72466. * @param gradient defines the gradient to use (between 0 and 1)
  72467. * @param factor defines the limit velocity value to affect to the specified gradient
  72468. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72469. * @returns the current particle system
  72470. */
  72471. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72472. /**
  72473. * Remove a specific limit velocity gradient
  72474. * @param gradient defines the gradient to remove
  72475. * @returns the current particle system
  72476. */
  72477. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  72478. /**
  72479. * Adds a new drag gradient
  72480. * @param gradient defines the gradient to use (between 0 and 1)
  72481. * @param factor defines the drag value to affect to the specified gradient
  72482. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72483. * @returns the current particle system
  72484. */
  72485. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72486. /**
  72487. * Remove a specific drag gradient
  72488. * @param gradient defines the gradient to remove
  72489. * @returns the current particle system
  72490. */
  72491. removeDragGradient(gradient: number): IParticleSystem;
  72492. /**
  72493. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  72494. * @param gradient defines the gradient to use (between 0 and 1)
  72495. * @param factor defines the emit rate value to affect to the specified gradient
  72496. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72497. * @returns the current particle system
  72498. */
  72499. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72500. /**
  72501. * Remove a specific emit rate gradient
  72502. * @param gradient defines the gradient to remove
  72503. * @returns the current particle system
  72504. */
  72505. removeEmitRateGradient(gradient: number): IParticleSystem;
  72506. /**
  72507. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  72508. * @param gradient defines the gradient to use (between 0 and 1)
  72509. * @param factor defines the start size value to affect to the specified gradient
  72510. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72511. * @returns the current particle system
  72512. */
  72513. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72514. /**
  72515. * Remove a specific start size gradient
  72516. * @param gradient defines the gradient to remove
  72517. * @returns the current particle system
  72518. */
  72519. removeStartSizeGradient(gradient: number): IParticleSystem;
  72520. private _createRampGradientTexture;
  72521. /**
  72522. * Gets the current list of ramp gradients.
  72523. * You must use addRampGradient and removeRampGradient to udpate this list
  72524. * @returns the list of ramp gradients
  72525. */
  72526. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72527. /**
  72528. * Adds a new ramp gradient used to remap particle colors
  72529. * @param gradient defines the gradient to use (between 0 and 1)
  72530. * @param color defines the color to affect to the specified gradient
  72531. * @returns the current particle system
  72532. */
  72533. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  72534. /**
  72535. * Remove a specific ramp gradient
  72536. * @param gradient defines the gradient to remove
  72537. * @returns the current particle system
  72538. */
  72539. removeRampGradient(gradient: number): ParticleSystem;
  72540. /**
  72541. * Adds a new color gradient
  72542. * @param gradient defines the gradient to use (between 0 and 1)
  72543. * @param color1 defines the color to affect to the specified gradient
  72544. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  72545. * @returns this particle system
  72546. */
  72547. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  72548. /**
  72549. * Remove a specific color gradient
  72550. * @param gradient defines the gradient to remove
  72551. * @returns this particle system
  72552. */
  72553. removeColorGradient(gradient: number): IParticleSystem;
  72554. private _fetchR;
  72555. protected _reset(): void;
  72556. private _resetEffect;
  72557. private _createVertexBuffers;
  72558. private _createIndexBuffer;
  72559. /**
  72560. * Gets the maximum number of particles active at the same time.
  72561. * @returns The max number of active particles.
  72562. */
  72563. getCapacity(): number;
  72564. /**
  72565. * Gets whether there are still active particles in the system.
  72566. * @returns True if it is alive, otherwise false.
  72567. */
  72568. isAlive(): boolean;
  72569. /**
  72570. * Gets if the system has been started. (Note: this will still be true after stop is called)
  72571. * @returns True if it has been started, otherwise false.
  72572. */
  72573. isStarted(): boolean;
  72574. private _prepareSubEmitterInternalArray;
  72575. /**
  72576. * Starts the particle system and begins to emit
  72577. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  72578. */
  72579. start(delay?: number): void;
  72580. /**
  72581. * Stops the particle system.
  72582. * @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.
  72583. */
  72584. stop(stopSubEmitters?: boolean): void;
  72585. /**
  72586. * Remove all active particles
  72587. */
  72588. reset(): void;
  72589. /**
  72590. * @hidden (for internal use only)
  72591. */
  72592. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  72593. /**
  72594. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  72595. * Its lifetime will start back at 0.
  72596. */
  72597. recycleParticle: (particle: Particle) => void;
  72598. private _stopSubEmitters;
  72599. private _createParticle;
  72600. private _removeFromRoot;
  72601. private _emitFromParticle;
  72602. private _update;
  72603. /** @hidden */
  72604. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  72605. /** @hidden */
  72606. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  72607. /** @hidden */
  72608. private _getEffect;
  72609. /**
  72610. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  72611. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  72612. */
  72613. animate(preWarmOnly?: boolean): void;
  72614. private _appendParticleVertices;
  72615. /**
  72616. * Rebuilds the particle system.
  72617. */
  72618. rebuild(): void;
  72619. /**
  72620. * Is this system ready to be used/rendered
  72621. * @return true if the system is ready
  72622. */
  72623. isReady(): boolean;
  72624. private _render;
  72625. /**
  72626. * Renders the particle system in its current state.
  72627. * @returns the current number of particles
  72628. */
  72629. render(): number;
  72630. /**
  72631. * Disposes the particle system and free the associated resources
  72632. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72633. */
  72634. dispose(disposeTexture?: boolean): void;
  72635. /**
  72636. * Clones the particle system.
  72637. * @param name The name of the cloned object
  72638. * @param newEmitter The new emitter to use
  72639. * @returns the cloned particle system
  72640. */
  72641. clone(name: string, newEmitter: any): ParticleSystem;
  72642. /**
  72643. * Serializes the particle system to a JSON object.
  72644. * @returns the JSON object
  72645. */
  72646. serialize(): any;
  72647. /** @hidden */
  72648. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  72649. /** @hidden */
  72650. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  72651. /**
  72652. * Parses a JSON object to create a particle system.
  72653. * @param parsedParticleSystem The JSON object to parse
  72654. * @param scene The scene to create the particle system in
  72655. * @param rootUrl The root url to use to load external dependencies like texture
  72656. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  72657. * @returns the Parsed particle system
  72658. */
  72659. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  72660. }
  72661. }
  72662. declare module BABYLON {
  72663. /**
  72664. * A particle represents one of the element emitted by a particle system.
  72665. * This is mainly define by its coordinates, direction, velocity and age.
  72666. */
  72667. export class Particle {
  72668. /**
  72669. * The particle system the particle belongs to.
  72670. */
  72671. particleSystem: ParticleSystem;
  72672. private static _Count;
  72673. /**
  72674. * Unique ID of the particle
  72675. */
  72676. id: number;
  72677. /**
  72678. * The world position of the particle in the scene.
  72679. */
  72680. position: Vector3;
  72681. /**
  72682. * The world direction of the particle in the scene.
  72683. */
  72684. direction: Vector3;
  72685. /**
  72686. * The color of the particle.
  72687. */
  72688. color: Color4;
  72689. /**
  72690. * The color change of the particle per step.
  72691. */
  72692. colorStep: Color4;
  72693. /**
  72694. * Defines how long will the life of the particle be.
  72695. */
  72696. lifeTime: number;
  72697. /**
  72698. * The current age of the particle.
  72699. */
  72700. age: number;
  72701. /**
  72702. * The current size of the particle.
  72703. */
  72704. size: number;
  72705. /**
  72706. * The current scale of the particle.
  72707. */
  72708. scale: Vector2;
  72709. /**
  72710. * The current angle of the particle.
  72711. */
  72712. angle: number;
  72713. /**
  72714. * Defines how fast is the angle changing.
  72715. */
  72716. angularSpeed: number;
  72717. /**
  72718. * Defines the cell index used by the particle to be rendered from a sprite.
  72719. */
  72720. cellIndex: number;
  72721. /**
  72722. * The information required to support color remapping
  72723. */
  72724. remapData: Vector4;
  72725. /** @hidden */
  72726. _randomCellOffset?: number;
  72727. /** @hidden */
  72728. _initialDirection: Nullable<Vector3>;
  72729. /** @hidden */
  72730. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  72731. /** @hidden */
  72732. _initialStartSpriteCellID: number;
  72733. /** @hidden */
  72734. _initialEndSpriteCellID: number;
  72735. /** @hidden */
  72736. _currentColorGradient: Nullable<ColorGradient>;
  72737. /** @hidden */
  72738. _currentColor1: Color4;
  72739. /** @hidden */
  72740. _currentColor2: Color4;
  72741. /** @hidden */
  72742. _currentSizeGradient: Nullable<FactorGradient>;
  72743. /** @hidden */
  72744. _currentSize1: number;
  72745. /** @hidden */
  72746. _currentSize2: number;
  72747. /** @hidden */
  72748. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  72749. /** @hidden */
  72750. _currentAngularSpeed1: number;
  72751. /** @hidden */
  72752. _currentAngularSpeed2: number;
  72753. /** @hidden */
  72754. _currentVelocityGradient: Nullable<FactorGradient>;
  72755. /** @hidden */
  72756. _currentVelocity1: number;
  72757. /** @hidden */
  72758. _currentVelocity2: number;
  72759. /** @hidden */
  72760. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  72761. /** @hidden */
  72762. _currentLimitVelocity1: number;
  72763. /** @hidden */
  72764. _currentLimitVelocity2: number;
  72765. /** @hidden */
  72766. _currentDragGradient: Nullable<FactorGradient>;
  72767. /** @hidden */
  72768. _currentDrag1: number;
  72769. /** @hidden */
  72770. _currentDrag2: number;
  72771. /** @hidden */
  72772. _randomNoiseCoordinates1: Vector3;
  72773. /** @hidden */
  72774. _randomNoiseCoordinates2: Vector3;
  72775. /**
  72776. * Creates a new instance Particle
  72777. * @param particleSystem the particle system the particle belongs to
  72778. */
  72779. constructor(
  72780. /**
  72781. * The particle system the particle belongs to.
  72782. */
  72783. particleSystem: ParticleSystem);
  72784. private updateCellInfoFromSystem;
  72785. /**
  72786. * Defines how the sprite cell index is updated for the particle
  72787. */
  72788. updateCellIndex(): void;
  72789. /** @hidden */
  72790. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  72791. /** @hidden */
  72792. _inheritParticleInfoToSubEmitters(): void;
  72793. /** @hidden */
  72794. _reset(): void;
  72795. /**
  72796. * Copy the properties of particle to another one.
  72797. * @param other the particle to copy the information to.
  72798. */
  72799. copyTo(other: Particle): void;
  72800. }
  72801. }
  72802. declare module BABYLON {
  72803. /**
  72804. * Particle emitter represents a volume emitting particles.
  72805. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  72806. */
  72807. export interface IParticleEmitterType {
  72808. /**
  72809. * Called by the particle System when the direction is computed for the created particle.
  72810. * @param worldMatrix is the world matrix of the particle system
  72811. * @param directionToUpdate is the direction vector to update with the result
  72812. * @param particle is the particle we are computed the direction for
  72813. */
  72814. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72815. /**
  72816. * Called by the particle System when the position is computed for the created particle.
  72817. * @param worldMatrix is the world matrix of the particle system
  72818. * @param positionToUpdate is the position vector to update with the result
  72819. * @param particle is the particle we are computed the position for
  72820. */
  72821. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72822. /**
  72823. * Clones the current emitter and returns a copy of it
  72824. * @returns the new emitter
  72825. */
  72826. clone(): IParticleEmitterType;
  72827. /**
  72828. * Called by the GPUParticleSystem to setup the update shader
  72829. * @param effect defines the update shader
  72830. */
  72831. applyToShader(effect: Effect): void;
  72832. /**
  72833. * Returns a string to use to update the GPU particles update shader
  72834. * @returns the effect defines string
  72835. */
  72836. getEffectDefines(): string;
  72837. /**
  72838. * Returns a string representing the class name
  72839. * @returns a string containing the class name
  72840. */
  72841. getClassName(): string;
  72842. /**
  72843. * Serializes the particle system to a JSON object.
  72844. * @returns the JSON object
  72845. */
  72846. serialize(): any;
  72847. /**
  72848. * Parse properties from a JSON object
  72849. * @param serializationObject defines the JSON object
  72850. */
  72851. parse(serializationObject: any): void;
  72852. }
  72853. }
  72854. declare module BABYLON {
  72855. /**
  72856. * Particle emitter emitting particles from the inside of a box.
  72857. * It emits the particles randomly between 2 given directions.
  72858. */
  72859. export class BoxParticleEmitter implements IParticleEmitterType {
  72860. /**
  72861. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72862. */
  72863. direction1: Vector3;
  72864. /**
  72865. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72866. */
  72867. direction2: Vector3;
  72868. /**
  72869. * 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.
  72870. */
  72871. minEmitBox: Vector3;
  72872. /**
  72873. * 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.
  72874. */
  72875. maxEmitBox: Vector3;
  72876. /**
  72877. * Creates a new instance BoxParticleEmitter
  72878. */
  72879. constructor();
  72880. /**
  72881. * Called by the particle System when the direction is computed for the created particle.
  72882. * @param worldMatrix is the world matrix of the particle system
  72883. * @param directionToUpdate is the direction vector to update with the result
  72884. * @param particle is the particle we are computed the direction for
  72885. */
  72886. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72887. /**
  72888. * Called by the particle System when the position is computed for the created particle.
  72889. * @param worldMatrix is the world matrix of the particle system
  72890. * @param positionToUpdate is the position vector to update with the result
  72891. * @param particle is the particle we are computed the position for
  72892. */
  72893. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72894. /**
  72895. * Clones the current emitter and returns a copy of it
  72896. * @returns the new emitter
  72897. */
  72898. clone(): BoxParticleEmitter;
  72899. /**
  72900. * Called by the GPUParticleSystem to setup the update shader
  72901. * @param effect defines the update shader
  72902. */
  72903. applyToShader(effect: Effect): void;
  72904. /**
  72905. * Returns a string to use to update the GPU particles update shader
  72906. * @returns a string containng the defines string
  72907. */
  72908. getEffectDefines(): string;
  72909. /**
  72910. * Returns the string "BoxParticleEmitter"
  72911. * @returns a string containing the class name
  72912. */
  72913. getClassName(): string;
  72914. /**
  72915. * Serializes the particle system to a JSON object.
  72916. * @returns the JSON object
  72917. */
  72918. serialize(): any;
  72919. /**
  72920. * Parse properties from a JSON object
  72921. * @param serializationObject defines the JSON object
  72922. */
  72923. parse(serializationObject: any): void;
  72924. }
  72925. }
  72926. declare module BABYLON {
  72927. /**
  72928. * Particle emitter emitting particles from the inside of a cone.
  72929. * It emits the particles alongside the cone volume from the base to the particle.
  72930. * The emission direction might be randomized.
  72931. */
  72932. export class ConeParticleEmitter implements IParticleEmitterType {
  72933. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  72934. directionRandomizer: number;
  72935. private _radius;
  72936. private _angle;
  72937. private _height;
  72938. /**
  72939. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  72940. */
  72941. radiusRange: number;
  72942. /**
  72943. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  72944. */
  72945. heightRange: number;
  72946. /**
  72947. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  72948. */
  72949. emitFromSpawnPointOnly: boolean;
  72950. /**
  72951. * Gets or sets the radius of the emission cone
  72952. */
  72953. radius: number;
  72954. /**
  72955. * Gets or sets the angle of the emission cone
  72956. */
  72957. angle: number;
  72958. private _buildHeight;
  72959. /**
  72960. * Creates a new instance ConeParticleEmitter
  72961. * @param radius the radius of the emission cone (1 by default)
  72962. * @param angle the cone base angle (PI by default)
  72963. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  72964. */
  72965. constructor(radius?: number, angle?: number,
  72966. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  72967. directionRandomizer?: number);
  72968. /**
  72969. * Called by the particle System when the direction is computed for the created particle.
  72970. * @param worldMatrix is the world matrix of the particle system
  72971. * @param directionToUpdate is the direction vector to update with the result
  72972. * @param particle is the particle we are computed the direction for
  72973. */
  72974. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72975. /**
  72976. * Called by the particle System when the position is computed for the created particle.
  72977. * @param worldMatrix is the world matrix of the particle system
  72978. * @param positionToUpdate is the position vector to update with the result
  72979. * @param particle is the particle we are computed the position for
  72980. */
  72981. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72982. /**
  72983. * Clones the current emitter and returns a copy of it
  72984. * @returns the new emitter
  72985. */
  72986. clone(): ConeParticleEmitter;
  72987. /**
  72988. * Called by the GPUParticleSystem to setup the update shader
  72989. * @param effect defines the update shader
  72990. */
  72991. applyToShader(effect: Effect): void;
  72992. /**
  72993. * Returns a string to use to update the GPU particles update shader
  72994. * @returns a string containng the defines string
  72995. */
  72996. getEffectDefines(): string;
  72997. /**
  72998. * Returns the string "ConeParticleEmitter"
  72999. * @returns a string containing the class name
  73000. */
  73001. getClassName(): string;
  73002. /**
  73003. * Serializes the particle system to a JSON object.
  73004. * @returns the JSON object
  73005. */
  73006. serialize(): any;
  73007. /**
  73008. * Parse properties from a JSON object
  73009. * @param serializationObject defines the JSON object
  73010. */
  73011. parse(serializationObject: any): void;
  73012. }
  73013. }
  73014. declare module BABYLON {
  73015. /**
  73016. * Particle emitter emitting particles from the inside of a cylinder.
  73017. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  73018. */
  73019. export class CylinderParticleEmitter implements IParticleEmitterType {
  73020. /**
  73021. * The radius of the emission cylinder.
  73022. */
  73023. radius: number;
  73024. /**
  73025. * The height of the emission cylinder.
  73026. */
  73027. height: number;
  73028. /**
  73029. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73030. */
  73031. radiusRange: number;
  73032. /**
  73033. * How much to randomize the particle direction [0-1].
  73034. */
  73035. directionRandomizer: number;
  73036. /**
  73037. * Creates a new instance CylinderParticleEmitter
  73038. * @param radius the radius of the emission cylinder (1 by default)
  73039. * @param height the height of the emission cylinder (1 by default)
  73040. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73041. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  73042. */
  73043. constructor(
  73044. /**
  73045. * The radius of the emission cylinder.
  73046. */
  73047. radius?: number,
  73048. /**
  73049. * The height of the emission cylinder.
  73050. */
  73051. height?: number,
  73052. /**
  73053. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73054. */
  73055. radiusRange?: number,
  73056. /**
  73057. * How much to randomize the particle direction [0-1].
  73058. */
  73059. directionRandomizer?: number);
  73060. /**
  73061. * Called by the particle System when the direction is computed for the created particle.
  73062. * @param worldMatrix is the world matrix of the particle system
  73063. * @param directionToUpdate is the direction vector to update with the result
  73064. * @param particle is the particle we are computed the direction for
  73065. */
  73066. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73067. /**
  73068. * Called by the particle System when the position is computed for the created particle.
  73069. * @param worldMatrix is the world matrix of the particle system
  73070. * @param positionToUpdate is the position vector to update with the result
  73071. * @param particle is the particle we are computed the position for
  73072. */
  73073. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73074. /**
  73075. * Clones the current emitter and returns a copy of it
  73076. * @returns the new emitter
  73077. */
  73078. clone(): CylinderParticleEmitter;
  73079. /**
  73080. * Called by the GPUParticleSystem to setup the update shader
  73081. * @param effect defines the update shader
  73082. */
  73083. applyToShader(effect: Effect): void;
  73084. /**
  73085. * Returns a string to use to update the GPU particles update shader
  73086. * @returns a string containng the defines string
  73087. */
  73088. getEffectDefines(): string;
  73089. /**
  73090. * Returns the string "CylinderParticleEmitter"
  73091. * @returns a string containing the class name
  73092. */
  73093. getClassName(): string;
  73094. /**
  73095. * Serializes the particle system to a JSON object.
  73096. * @returns the JSON object
  73097. */
  73098. serialize(): any;
  73099. /**
  73100. * Parse properties from a JSON object
  73101. * @param serializationObject defines the JSON object
  73102. */
  73103. parse(serializationObject: any): void;
  73104. }
  73105. /**
  73106. * Particle emitter emitting particles from the inside of a cylinder.
  73107. * It emits the particles randomly between two vectors.
  73108. */
  73109. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  73110. /**
  73111. * The min limit of the emission direction.
  73112. */
  73113. direction1: Vector3;
  73114. /**
  73115. * The max limit of the emission direction.
  73116. */
  73117. direction2: Vector3;
  73118. /**
  73119. * Creates a new instance CylinderDirectedParticleEmitter
  73120. * @param radius the radius of the emission cylinder (1 by default)
  73121. * @param height the height of the emission cylinder (1 by default)
  73122. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73123. * @param direction1 the min limit of the emission direction (up vector by default)
  73124. * @param direction2 the max limit of the emission direction (up vector by default)
  73125. */
  73126. constructor(radius?: number, height?: number, radiusRange?: number,
  73127. /**
  73128. * The min limit of the emission direction.
  73129. */
  73130. direction1?: Vector3,
  73131. /**
  73132. * The max limit of the emission direction.
  73133. */
  73134. direction2?: Vector3);
  73135. /**
  73136. * Called by the particle System when the direction is computed for the created particle.
  73137. * @param worldMatrix is the world matrix of the particle system
  73138. * @param directionToUpdate is the direction vector to update with the result
  73139. * @param particle is the particle we are computed the direction for
  73140. */
  73141. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73142. /**
  73143. * Clones the current emitter and returns a copy of it
  73144. * @returns the new emitter
  73145. */
  73146. clone(): CylinderDirectedParticleEmitter;
  73147. /**
  73148. * Called by the GPUParticleSystem to setup the update shader
  73149. * @param effect defines the update shader
  73150. */
  73151. applyToShader(effect: Effect): void;
  73152. /**
  73153. * Returns a string to use to update the GPU particles update shader
  73154. * @returns a string containng the defines string
  73155. */
  73156. getEffectDefines(): string;
  73157. /**
  73158. * Returns the string "CylinderDirectedParticleEmitter"
  73159. * @returns a string containing the class name
  73160. */
  73161. getClassName(): string;
  73162. /**
  73163. * Serializes the particle system to a JSON object.
  73164. * @returns the JSON object
  73165. */
  73166. serialize(): any;
  73167. /**
  73168. * Parse properties from a JSON object
  73169. * @param serializationObject defines the JSON object
  73170. */
  73171. parse(serializationObject: any): void;
  73172. }
  73173. }
  73174. declare module BABYLON {
  73175. /**
  73176. * Particle emitter emitting particles from the inside of a hemisphere.
  73177. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  73178. */
  73179. export class HemisphericParticleEmitter implements IParticleEmitterType {
  73180. /**
  73181. * The radius of the emission hemisphere.
  73182. */
  73183. radius: number;
  73184. /**
  73185. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73186. */
  73187. radiusRange: number;
  73188. /**
  73189. * How much to randomize the particle direction [0-1].
  73190. */
  73191. directionRandomizer: number;
  73192. /**
  73193. * Creates a new instance HemisphericParticleEmitter
  73194. * @param radius the radius of the emission hemisphere (1 by default)
  73195. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73196. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  73197. */
  73198. constructor(
  73199. /**
  73200. * The radius of the emission hemisphere.
  73201. */
  73202. radius?: number,
  73203. /**
  73204. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73205. */
  73206. radiusRange?: number,
  73207. /**
  73208. * How much to randomize the particle direction [0-1].
  73209. */
  73210. directionRandomizer?: number);
  73211. /**
  73212. * Called by the particle System when the direction is computed for the created particle.
  73213. * @param worldMatrix is the world matrix of the particle system
  73214. * @param directionToUpdate is the direction vector to update with the result
  73215. * @param particle is the particle we are computed the direction for
  73216. */
  73217. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73218. /**
  73219. * Called by the particle System when the position is computed for the created particle.
  73220. * @param worldMatrix is the world matrix of the particle system
  73221. * @param positionToUpdate is the position vector to update with the result
  73222. * @param particle is the particle we are computed the position for
  73223. */
  73224. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73225. /**
  73226. * Clones the current emitter and returns a copy of it
  73227. * @returns the new emitter
  73228. */
  73229. clone(): HemisphericParticleEmitter;
  73230. /**
  73231. * Called by the GPUParticleSystem to setup the update shader
  73232. * @param effect defines the update shader
  73233. */
  73234. applyToShader(effect: Effect): void;
  73235. /**
  73236. * Returns a string to use to update the GPU particles update shader
  73237. * @returns a string containng the defines string
  73238. */
  73239. getEffectDefines(): string;
  73240. /**
  73241. * Returns the string "HemisphericParticleEmitter"
  73242. * @returns a string containing the class name
  73243. */
  73244. getClassName(): string;
  73245. /**
  73246. * Serializes the particle system to a JSON object.
  73247. * @returns the JSON object
  73248. */
  73249. serialize(): any;
  73250. /**
  73251. * Parse properties from a JSON object
  73252. * @param serializationObject defines the JSON object
  73253. */
  73254. parse(serializationObject: any): void;
  73255. }
  73256. }
  73257. declare module BABYLON {
  73258. /**
  73259. * Particle emitter emitting particles from a point.
  73260. * It emits the particles randomly between 2 given directions.
  73261. */
  73262. export class PointParticleEmitter implements IParticleEmitterType {
  73263. /**
  73264. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73265. */
  73266. direction1: Vector3;
  73267. /**
  73268. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73269. */
  73270. direction2: Vector3;
  73271. /**
  73272. * Creates a new instance PointParticleEmitter
  73273. */
  73274. constructor();
  73275. /**
  73276. * Called by the particle System when the direction is computed for the created particle.
  73277. * @param worldMatrix is the world matrix of the particle system
  73278. * @param directionToUpdate is the direction vector to update with the result
  73279. * @param particle is the particle we are computed the direction for
  73280. */
  73281. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73282. /**
  73283. * Called by the particle System when the position is computed for the created particle.
  73284. * @param worldMatrix is the world matrix of the particle system
  73285. * @param positionToUpdate is the position vector to update with the result
  73286. * @param particle is the particle we are computed the position for
  73287. */
  73288. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73289. /**
  73290. * Clones the current emitter and returns a copy of it
  73291. * @returns the new emitter
  73292. */
  73293. clone(): PointParticleEmitter;
  73294. /**
  73295. * Called by the GPUParticleSystem to setup the update shader
  73296. * @param effect defines the update shader
  73297. */
  73298. applyToShader(effect: Effect): void;
  73299. /**
  73300. * Returns a string to use to update the GPU particles update shader
  73301. * @returns a string containng the defines string
  73302. */
  73303. getEffectDefines(): string;
  73304. /**
  73305. * Returns the string "PointParticleEmitter"
  73306. * @returns a string containing the class name
  73307. */
  73308. getClassName(): string;
  73309. /**
  73310. * Serializes the particle system to a JSON object.
  73311. * @returns the JSON object
  73312. */
  73313. serialize(): any;
  73314. /**
  73315. * Parse properties from a JSON object
  73316. * @param serializationObject defines the JSON object
  73317. */
  73318. parse(serializationObject: any): void;
  73319. }
  73320. }
  73321. declare module BABYLON {
  73322. /**
  73323. * Particle emitter emitting particles from the inside of a sphere.
  73324. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  73325. */
  73326. export class SphereParticleEmitter implements IParticleEmitterType {
  73327. /**
  73328. * The radius of the emission sphere.
  73329. */
  73330. radius: number;
  73331. /**
  73332. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73333. */
  73334. radiusRange: number;
  73335. /**
  73336. * How much to randomize the particle direction [0-1].
  73337. */
  73338. directionRandomizer: number;
  73339. /**
  73340. * Creates a new instance SphereParticleEmitter
  73341. * @param radius the radius of the emission sphere (1 by default)
  73342. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73343. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  73344. */
  73345. constructor(
  73346. /**
  73347. * The radius of the emission sphere.
  73348. */
  73349. radius?: number,
  73350. /**
  73351. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73352. */
  73353. radiusRange?: number,
  73354. /**
  73355. * How much to randomize the particle direction [0-1].
  73356. */
  73357. directionRandomizer?: number);
  73358. /**
  73359. * Called by the particle System when the direction is computed for the created particle.
  73360. * @param worldMatrix is the world matrix of the particle system
  73361. * @param directionToUpdate is the direction vector to update with the result
  73362. * @param particle is the particle we are computed the direction for
  73363. */
  73364. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73365. /**
  73366. * Called by the particle System when the position is computed for the created particle.
  73367. * @param worldMatrix is the world matrix of the particle system
  73368. * @param positionToUpdate is the position vector to update with the result
  73369. * @param particle is the particle we are computed the position for
  73370. */
  73371. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73372. /**
  73373. * Clones the current emitter and returns a copy of it
  73374. * @returns the new emitter
  73375. */
  73376. clone(): SphereParticleEmitter;
  73377. /**
  73378. * Called by the GPUParticleSystem to setup the update shader
  73379. * @param effect defines the update shader
  73380. */
  73381. applyToShader(effect: Effect): void;
  73382. /**
  73383. * Returns a string to use to update the GPU particles update shader
  73384. * @returns a string containng the defines string
  73385. */
  73386. getEffectDefines(): string;
  73387. /**
  73388. * Returns the string "SphereParticleEmitter"
  73389. * @returns a string containing the class name
  73390. */
  73391. getClassName(): string;
  73392. /**
  73393. * Serializes the particle system to a JSON object.
  73394. * @returns the JSON object
  73395. */
  73396. serialize(): any;
  73397. /**
  73398. * Parse properties from a JSON object
  73399. * @param serializationObject defines the JSON object
  73400. */
  73401. parse(serializationObject: any): void;
  73402. }
  73403. /**
  73404. * Particle emitter emitting particles from the inside of a sphere.
  73405. * It emits the particles randomly between two vectors.
  73406. */
  73407. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  73408. /**
  73409. * The min limit of the emission direction.
  73410. */
  73411. direction1: Vector3;
  73412. /**
  73413. * The max limit of the emission direction.
  73414. */
  73415. direction2: Vector3;
  73416. /**
  73417. * Creates a new instance SphereDirectedParticleEmitter
  73418. * @param radius the radius of the emission sphere (1 by default)
  73419. * @param direction1 the min limit of the emission direction (up vector by default)
  73420. * @param direction2 the max limit of the emission direction (up vector by default)
  73421. */
  73422. constructor(radius?: number,
  73423. /**
  73424. * The min limit of the emission direction.
  73425. */
  73426. direction1?: Vector3,
  73427. /**
  73428. * The max limit of the emission direction.
  73429. */
  73430. direction2?: Vector3);
  73431. /**
  73432. * Called by the particle System when the direction is computed for the created particle.
  73433. * @param worldMatrix is the world matrix of the particle system
  73434. * @param directionToUpdate is the direction vector to update with the result
  73435. * @param particle is the particle we are computed the direction for
  73436. */
  73437. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73438. /**
  73439. * Clones the current emitter and returns a copy of it
  73440. * @returns the new emitter
  73441. */
  73442. clone(): SphereDirectedParticleEmitter;
  73443. /**
  73444. * Called by the GPUParticleSystem to setup the update shader
  73445. * @param effect defines the update shader
  73446. */
  73447. applyToShader(effect: Effect): void;
  73448. /**
  73449. * Returns a string to use to update the GPU particles update shader
  73450. * @returns a string containng the defines string
  73451. */
  73452. getEffectDefines(): string;
  73453. /**
  73454. * Returns the string "SphereDirectedParticleEmitter"
  73455. * @returns a string containing the class name
  73456. */
  73457. getClassName(): string;
  73458. /**
  73459. * Serializes the particle system to a JSON object.
  73460. * @returns the JSON object
  73461. */
  73462. serialize(): any;
  73463. /**
  73464. * Parse properties from a JSON object
  73465. * @param serializationObject defines the JSON object
  73466. */
  73467. parse(serializationObject: any): void;
  73468. }
  73469. }
  73470. declare module BABYLON {
  73471. /**
  73472. * Interface representing a particle system in Babylon.js.
  73473. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  73474. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  73475. */
  73476. export interface IParticleSystem {
  73477. /**
  73478. * List of animations used by the particle system.
  73479. */
  73480. animations: Animation[];
  73481. /**
  73482. * The id of the Particle system.
  73483. */
  73484. id: string;
  73485. /**
  73486. * The name of the Particle system.
  73487. */
  73488. name: string;
  73489. /**
  73490. * The emitter represents the Mesh or position we are attaching the particle system to.
  73491. */
  73492. emitter: Nullable<AbstractMesh | Vector3>;
  73493. /**
  73494. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  73495. */
  73496. isBillboardBased: boolean;
  73497. /**
  73498. * The rendering group used by the Particle system to chose when to render.
  73499. */
  73500. renderingGroupId: number;
  73501. /**
  73502. * The layer mask we are rendering the particles through.
  73503. */
  73504. layerMask: number;
  73505. /**
  73506. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  73507. */
  73508. updateSpeed: number;
  73509. /**
  73510. * The amount of time the particle system is running (depends of the overall update speed).
  73511. */
  73512. targetStopDuration: number;
  73513. /**
  73514. * The texture used to render each particle. (this can be a spritesheet)
  73515. */
  73516. particleTexture: Nullable<Texture>;
  73517. /**
  73518. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  73519. */
  73520. blendMode: number;
  73521. /**
  73522. * Minimum life time of emitting particles.
  73523. */
  73524. minLifeTime: number;
  73525. /**
  73526. * Maximum life time of emitting particles.
  73527. */
  73528. maxLifeTime: number;
  73529. /**
  73530. * Minimum Size of emitting particles.
  73531. */
  73532. minSize: number;
  73533. /**
  73534. * Maximum Size of emitting particles.
  73535. */
  73536. maxSize: number;
  73537. /**
  73538. * Minimum scale of emitting particles on X axis.
  73539. */
  73540. minScaleX: number;
  73541. /**
  73542. * Maximum scale of emitting particles on X axis.
  73543. */
  73544. maxScaleX: number;
  73545. /**
  73546. * Minimum scale of emitting particles on Y axis.
  73547. */
  73548. minScaleY: number;
  73549. /**
  73550. * Maximum scale of emitting particles on Y axis.
  73551. */
  73552. maxScaleY: number;
  73553. /**
  73554. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  73555. */
  73556. color1: Color4;
  73557. /**
  73558. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  73559. */
  73560. color2: Color4;
  73561. /**
  73562. * Color the particle will have at the end of its lifetime.
  73563. */
  73564. colorDead: Color4;
  73565. /**
  73566. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  73567. */
  73568. emitRate: number;
  73569. /**
  73570. * You can use gravity if you want to give an orientation to your particles.
  73571. */
  73572. gravity: Vector3;
  73573. /**
  73574. * Minimum power of emitting particles.
  73575. */
  73576. minEmitPower: number;
  73577. /**
  73578. * Maximum power of emitting particles.
  73579. */
  73580. maxEmitPower: number;
  73581. /**
  73582. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  73583. */
  73584. minAngularSpeed: number;
  73585. /**
  73586. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  73587. */
  73588. maxAngularSpeed: number;
  73589. /**
  73590. * Gets or sets the minimal initial rotation in radians.
  73591. */
  73592. minInitialRotation: number;
  73593. /**
  73594. * Gets or sets the maximal initial rotation in radians.
  73595. */
  73596. maxInitialRotation: number;
  73597. /**
  73598. * The particle emitter type defines the emitter used by the particle system.
  73599. * It can be for example box, sphere, or cone...
  73600. */
  73601. particleEmitterType: Nullable<IParticleEmitterType>;
  73602. /**
  73603. * Defines the delay in milliseconds before starting the system (0 by default)
  73604. */
  73605. startDelay: number;
  73606. /**
  73607. * 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
  73608. */
  73609. preWarmCycles: number;
  73610. /**
  73611. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  73612. */
  73613. preWarmStepOffset: number;
  73614. /**
  73615. * 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)
  73616. */
  73617. spriteCellChangeSpeed: number;
  73618. /**
  73619. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  73620. */
  73621. startSpriteCellID: number;
  73622. /**
  73623. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  73624. */
  73625. endSpriteCellID: number;
  73626. /**
  73627. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  73628. */
  73629. spriteCellWidth: number;
  73630. /**
  73631. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  73632. */
  73633. spriteCellHeight: number;
  73634. /**
  73635. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  73636. */
  73637. spriteRandomStartCell: boolean;
  73638. /**
  73639. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  73640. */
  73641. isAnimationSheetEnabled: boolean;
  73642. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  73643. translationPivot: Vector2;
  73644. /**
  73645. * Gets or sets a texture used to add random noise to particle positions
  73646. */
  73647. noiseTexture: Nullable<BaseTexture>;
  73648. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  73649. noiseStrength: Vector3;
  73650. /**
  73651. * Gets or sets the billboard mode to use when isBillboardBased = true.
  73652. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  73653. */
  73654. billboardMode: number;
  73655. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  73656. limitVelocityDamping: number;
  73657. /**
  73658. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  73659. */
  73660. beginAnimationOnStart: boolean;
  73661. /**
  73662. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  73663. */
  73664. beginAnimationFrom: number;
  73665. /**
  73666. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  73667. */
  73668. beginAnimationTo: number;
  73669. /**
  73670. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  73671. */
  73672. beginAnimationLoop: boolean;
  73673. /**
  73674. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  73675. */
  73676. disposeOnStop: boolean;
  73677. /**
  73678. * Gets the maximum number of particles active at the same time.
  73679. * @returns The max number of active particles.
  73680. */
  73681. getCapacity(): number;
  73682. /**
  73683. * Gets if the system has been started. (Note: this will still be true after stop is called)
  73684. * @returns True if it has been started, otherwise false.
  73685. */
  73686. isStarted(): boolean;
  73687. /**
  73688. * Animates the particle system for this frame.
  73689. */
  73690. animate(): void;
  73691. /**
  73692. * Renders the particle system in its current state.
  73693. * @returns the current number of particles
  73694. */
  73695. render(): number;
  73696. /**
  73697. * Dispose the particle system and frees its associated resources.
  73698. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  73699. */
  73700. dispose(disposeTexture?: boolean): void;
  73701. /**
  73702. * Clones the particle system.
  73703. * @param name The name of the cloned object
  73704. * @param newEmitter The new emitter to use
  73705. * @returns the cloned particle system
  73706. */
  73707. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  73708. /**
  73709. * Serializes the particle system to a JSON object.
  73710. * @returns the JSON object
  73711. */
  73712. serialize(): any;
  73713. /**
  73714. * Rebuild the particle system
  73715. */
  73716. rebuild(): void;
  73717. /**
  73718. * Starts the particle system and begins to emit
  73719. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  73720. */
  73721. start(delay?: number): void;
  73722. /**
  73723. * Stops the particle system.
  73724. */
  73725. stop(): void;
  73726. /**
  73727. * Remove all active particles
  73728. */
  73729. reset(): void;
  73730. /**
  73731. * Is this system ready to be used/rendered
  73732. * @return true if the system is ready
  73733. */
  73734. isReady(): boolean;
  73735. /**
  73736. * Adds a new color gradient
  73737. * @param gradient defines the gradient to use (between 0 and 1)
  73738. * @param color1 defines the color to affect to the specified gradient
  73739. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  73740. * @returns the current particle system
  73741. */
  73742. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  73743. /**
  73744. * Remove a specific color gradient
  73745. * @param gradient defines the gradient to remove
  73746. * @returns the current particle system
  73747. */
  73748. removeColorGradient(gradient: number): IParticleSystem;
  73749. /**
  73750. * Adds a new size gradient
  73751. * @param gradient defines the gradient to use (between 0 and 1)
  73752. * @param factor defines the size factor to affect to the specified gradient
  73753. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73754. * @returns the current particle system
  73755. */
  73756. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73757. /**
  73758. * Remove a specific size gradient
  73759. * @param gradient defines the gradient to remove
  73760. * @returns the current particle system
  73761. */
  73762. removeSizeGradient(gradient: number): IParticleSystem;
  73763. /**
  73764. * Gets the current list of color gradients.
  73765. * You must use addColorGradient and removeColorGradient to udpate this list
  73766. * @returns the list of color gradients
  73767. */
  73768. getColorGradients(): Nullable<Array<ColorGradient>>;
  73769. /**
  73770. * Gets the current list of size gradients.
  73771. * You must use addSizeGradient and removeSizeGradient to udpate this list
  73772. * @returns the list of size gradients
  73773. */
  73774. getSizeGradients(): Nullable<Array<FactorGradient>>;
  73775. /**
  73776. * Gets the current list of angular speed gradients.
  73777. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  73778. * @returns the list of angular speed gradients
  73779. */
  73780. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  73781. /**
  73782. * Adds a new angular speed gradient
  73783. * @param gradient defines the gradient to use (between 0 and 1)
  73784. * @param factor defines the angular speed to affect to the specified gradient
  73785. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73786. * @returns the current particle system
  73787. */
  73788. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73789. /**
  73790. * Remove a specific angular speed gradient
  73791. * @param gradient defines the gradient to remove
  73792. * @returns the current particle system
  73793. */
  73794. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  73795. /**
  73796. * Gets the current list of velocity gradients.
  73797. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  73798. * @returns the list of velocity gradients
  73799. */
  73800. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  73801. /**
  73802. * Adds a new velocity gradient
  73803. * @param gradient defines the gradient to use (between 0 and 1)
  73804. * @param factor defines the velocity to affect to the specified gradient
  73805. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73806. * @returns the current particle system
  73807. */
  73808. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73809. /**
  73810. * Remove a specific velocity gradient
  73811. * @param gradient defines the gradient to remove
  73812. * @returns the current particle system
  73813. */
  73814. removeVelocityGradient(gradient: number): IParticleSystem;
  73815. /**
  73816. * Gets the current list of limit velocity gradients.
  73817. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  73818. * @returns the list of limit velocity gradients
  73819. */
  73820. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  73821. /**
  73822. * Adds a new limit velocity gradient
  73823. * @param gradient defines the gradient to use (between 0 and 1)
  73824. * @param factor defines the limit velocity to affect to the specified gradient
  73825. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73826. * @returns the current particle system
  73827. */
  73828. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73829. /**
  73830. * Remove a specific limit velocity gradient
  73831. * @param gradient defines the gradient to remove
  73832. * @returns the current particle system
  73833. */
  73834. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  73835. /**
  73836. * Adds a new drag gradient
  73837. * @param gradient defines the gradient to use (between 0 and 1)
  73838. * @param factor defines the drag to affect to the specified gradient
  73839. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73840. * @returns the current particle system
  73841. */
  73842. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73843. /**
  73844. * Remove a specific drag gradient
  73845. * @param gradient defines the gradient to remove
  73846. * @returns the current particle system
  73847. */
  73848. removeDragGradient(gradient: number): IParticleSystem;
  73849. /**
  73850. * Gets the current list of drag gradients.
  73851. * You must use addDragGradient and removeDragGradient to udpate this list
  73852. * @returns the list of drag gradients
  73853. */
  73854. getDragGradients(): Nullable<Array<FactorGradient>>;
  73855. /**
  73856. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  73857. * @param gradient defines the gradient to use (between 0 and 1)
  73858. * @param factor defines the emit rate to affect to the specified gradient
  73859. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73860. * @returns the current particle system
  73861. */
  73862. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73863. /**
  73864. * Remove a specific emit rate gradient
  73865. * @param gradient defines the gradient to remove
  73866. * @returns the current particle system
  73867. */
  73868. removeEmitRateGradient(gradient: number): IParticleSystem;
  73869. /**
  73870. * Gets the current list of emit rate gradients.
  73871. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  73872. * @returns the list of emit rate gradients
  73873. */
  73874. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  73875. /**
  73876. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  73877. * @param gradient defines the gradient to use (between 0 and 1)
  73878. * @param factor defines the start size to affect to the specified gradient
  73879. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73880. * @returns the current particle system
  73881. */
  73882. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73883. /**
  73884. * Remove a specific start size gradient
  73885. * @param gradient defines the gradient to remove
  73886. * @returns the current particle system
  73887. */
  73888. removeStartSizeGradient(gradient: number): IParticleSystem;
  73889. /**
  73890. * Gets the current list of start size gradients.
  73891. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  73892. * @returns the list of start size gradients
  73893. */
  73894. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  73895. /**
  73896. * Adds a new life time gradient
  73897. * @param gradient defines the gradient to use (between 0 and 1)
  73898. * @param factor defines the life time factor to affect to the specified gradient
  73899. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73900. * @returns the current particle system
  73901. */
  73902. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73903. /**
  73904. * Remove a specific life time gradient
  73905. * @param gradient defines the gradient to remove
  73906. * @returns the current particle system
  73907. */
  73908. removeLifeTimeGradient(gradient: number): IParticleSystem;
  73909. /**
  73910. * Gets the current list of life time gradients.
  73911. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  73912. * @returns the list of life time gradients
  73913. */
  73914. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  73915. /**
  73916. * Gets the current list of color gradients.
  73917. * You must use addColorGradient and removeColorGradient to udpate this list
  73918. * @returns the list of color gradients
  73919. */
  73920. getColorGradients(): Nullable<Array<ColorGradient>>;
  73921. /**
  73922. * Adds a new ramp gradient used to remap particle colors
  73923. * @param gradient defines the gradient to use (between 0 and 1)
  73924. * @param color defines the color to affect to the specified gradient
  73925. * @returns the current particle system
  73926. */
  73927. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  73928. /**
  73929. * Gets the current list of ramp gradients.
  73930. * You must use addRampGradient and removeRampGradient to udpate this list
  73931. * @returns the list of ramp gradients
  73932. */
  73933. getRampGradients(): Nullable<Array<Color3Gradient>>;
  73934. /** Gets or sets a boolean indicating that ramp gradients must be used
  73935. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  73936. */
  73937. useRampGradients: boolean;
  73938. /**
  73939. * Adds a new color remap gradient
  73940. * @param gradient defines the gradient to use (between 0 and 1)
  73941. * @param min defines the color remap minimal range
  73942. * @param max defines the color remap maximal range
  73943. * @returns the current particle system
  73944. */
  73945. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73946. /**
  73947. * Gets the current list of color remap gradients.
  73948. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  73949. * @returns the list of color remap gradients
  73950. */
  73951. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  73952. /**
  73953. * Adds a new alpha remap gradient
  73954. * @param gradient defines the gradient to use (between 0 and 1)
  73955. * @param min defines the alpha remap minimal range
  73956. * @param max defines the alpha remap maximal range
  73957. * @returns the current particle system
  73958. */
  73959. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73960. /**
  73961. * Gets the current list of alpha remap gradients.
  73962. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  73963. * @returns the list of alpha remap gradients
  73964. */
  73965. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  73966. /**
  73967. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  73968. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73969. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73970. * @returns the emitter
  73971. */
  73972. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  73973. /**
  73974. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  73975. * @param radius The radius of the hemisphere to emit from
  73976. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73977. * @returns the emitter
  73978. */
  73979. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  73980. /**
  73981. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  73982. * @param radius The radius of the sphere to emit from
  73983. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73984. * @returns the emitter
  73985. */
  73986. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  73987. /**
  73988. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  73989. * @param radius The radius of the sphere to emit from
  73990. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  73991. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  73992. * @returns the emitter
  73993. */
  73994. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  73995. /**
  73996. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  73997. * @param radius The radius of the emission cylinder
  73998. * @param height The height of the emission cylinder
  73999. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  74000. * @param directionRandomizer How much to randomize the particle direction [0-1]
  74001. * @returns the emitter
  74002. */
  74003. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  74004. /**
  74005. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  74006. * @param radius The radius of the cylinder to emit from
  74007. * @param height The height of the emission cylinder
  74008. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74009. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  74010. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  74011. * @returns the emitter
  74012. */
  74013. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  74014. /**
  74015. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  74016. * @param radius The radius of the cone to emit from
  74017. * @param angle The base angle of the cone
  74018. * @returns the emitter
  74019. */
  74020. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  74021. /**
  74022. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  74023. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74024. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74025. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74026. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74027. * @returns the emitter
  74028. */
  74029. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  74030. /**
  74031. * Get hosting scene
  74032. * @returns the scene
  74033. */
  74034. getScene(): Scene;
  74035. }
  74036. }
  74037. declare module BABYLON {
  74038. /**
  74039. * Creates an instance based on a source mesh.
  74040. */
  74041. export class InstancedMesh extends AbstractMesh {
  74042. private _sourceMesh;
  74043. private _currentLOD;
  74044. /** @hidden */
  74045. _indexInSourceMeshInstanceArray: number;
  74046. constructor(name: string, source: Mesh);
  74047. /**
  74048. * Returns the string "InstancedMesh".
  74049. */
  74050. getClassName(): string;
  74051. /**
  74052. * If the source mesh receives shadows
  74053. */
  74054. readonly receiveShadows: boolean;
  74055. /**
  74056. * The material of the source mesh
  74057. */
  74058. readonly material: Nullable<Material>;
  74059. /**
  74060. * Visibility of the source mesh
  74061. */
  74062. readonly visibility: number;
  74063. /**
  74064. * Skeleton of the source mesh
  74065. */
  74066. readonly skeleton: Nullable<Skeleton>;
  74067. /**
  74068. * Rendering ground id of the source mesh
  74069. */
  74070. renderingGroupId: number;
  74071. /**
  74072. * Returns the total number of vertices (integer).
  74073. */
  74074. getTotalVertices(): number;
  74075. /**
  74076. * Returns a positive integer : the total number of indices in this mesh geometry.
  74077. * @returns the numner of indices or zero if the mesh has no geometry.
  74078. */
  74079. getTotalIndices(): number;
  74080. /**
  74081. * The source mesh of the instance
  74082. */
  74083. readonly sourceMesh: Mesh;
  74084. /**
  74085. * Is this node ready to be used/rendered
  74086. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  74087. * @return {boolean} is it ready
  74088. */
  74089. isReady(completeCheck?: boolean): boolean;
  74090. /**
  74091. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  74092. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  74093. * @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.
  74094. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  74095. */
  74096. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  74097. /**
  74098. * Sets the vertex data of the mesh geometry for the requested `kind`.
  74099. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  74100. * The `data` are either a numeric array either a Float32Array.
  74101. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  74102. * 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).
  74103. * Note that a new underlying VertexBuffer object is created each call.
  74104. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  74105. *
  74106. * Possible `kind` values :
  74107. * - VertexBuffer.PositionKind
  74108. * - VertexBuffer.UVKind
  74109. * - VertexBuffer.UV2Kind
  74110. * - VertexBuffer.UV3Kind
  74111. * - VertexBuffer.UV4Kind
  74112. * - VertexBuffer.UV5Kind
  74113. * - VertexBuffer.UV6Kind
  74114. * - VertexBuffer.ColorKind
  74115. * - VertexBuffer.MatricesIndicesKind
  74116. * - VertexBuffer.MatricesIndicesExtraKind
  74117. * - VertexBuffer.MatricesWeightsKind
  74118. * - VertexBuffer.MatricesWeightsExtraKind
  74119. *
  74120. * Returns the Mesh.
  74121. */
  74122. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  74123. /**
  74124. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  74125. * If the mesh has no geometry, it is simply returned as it is.
  74126. * The `data` are either a numeric array either a Float32Array.
  74127. * No new underlying VertexBuffer object is created.
  74128. * 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.
  74129. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  74130. *
  74131. * Possible `kind` values :
  74132. * - VertexBuffer.PositionKind
  74133. * - VertexBuffer.UVKind
  74134. * - VertexBuffer.UV2Kind
  74135. * - VertexBuffer.UV3Kind
  74136. * - VertexBuffer.UV4Kind
  74137. * - VertexBuffer.UV5Kind
  74138. * - VertexBuffer.UV6Kind
  74139. * - VertexBuffer.ColorKind
  74140. * - VertexBuffer.MatricesIndicesKind
  74141. * - VertexBuffer.MatricesIndicesExtraKind
  74142. * - VertexBuffer.MatricesWeightsKind
  74143. * - VertexBuffer.MatricesWeightsExtraKind
  74144. *
  74145. * Returns the Mesh.
  74146. */
  74147. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  74148. /**
  74149. * Sets the mesh indices.
  74150. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  74151. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  74152. * This method creates a new index buffer each call.
  74153. * Returns the Mesh.
  74154. */
  74155. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  74156. /**
  74157. * Boolean : True if the mesh owns the requested kind of data.
  74158. */
  74159. isVerticesDataPresent(kind: string): boolean;
  74160. /**
  74161. * Returns an array of indices (IndicesArray).
  74162. */
  74163. getIndices(): Nullable<IndicesArray>;
  74164. readonly _positions: Nullable<Vector3[]>;
  74165. /**
  74166. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  74167. * This means the mesh underlying bounding box and sphere are recomputed.
  74168. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  74169. * @returns the current mesh
  74170. */
  74171. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  74172. /** @hidden */
  74173. _preActivate(): InstancedMesh;
  74174. /** @hidden */
  74175. _activate(renderId: number): InstancedMesh;
  74176. /**
  74177. * Returns the current associated LOD AbstractMesh.
  74178. */
  74179. getLOD(camera: Camera): AbstractMesh;
  74180. /** @hidden */
  74181. _syncSubMeshes(): InstancedMesh;
  74182. /** @hidden */
  74183. _generatePointsArray(): boolean;
  74184. /**
  74185. * Creates a new InstancedMesh from the current mesh.
  74186. * - name (string) : the cloned mesh name
  74187. * - newParent (optional Node) : the optional Node to parent the clone to.
  74188. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  74189. *
  74190. * Returns the clone.
  74191. */
  74192. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  74193. /**
  74194. * Disposes the InstancedMesh.
  74195. * Returns nothing.
  74196. */
  74197. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  74198. }
  74199. }
  74200. declare module BABYLON {
  74201. /**
  74202. * Defines the options associated with the creation of a shader material.
  74203. */
  74204. export interface IShaderMaterialOptions {
  74205. /**
  74206. * Does the material work in alpha blend mode
  74207. */
  74208. needAlphaBlending: boolean;
  74209. /**
  74210. * Does the material work in alpha test mode
  74211. */
  74212. needAlphaTesting: boolean;
  74213. /**
  74214. * The list of attribute names used in the shader
  74215. */
  74216. attributes: string[];
  74217. /**
  74218. * The list of unifrom names used in the shader
  74219. */
  74220. uniforms: string[];
  74221. /**
  74222. * The list of UBO names used in the shader
  74223. */
  74224. uniformBuffers: string[];
  74225. /**
  74226. * The list of sampler names used in the shader
  74227. */
  74228. samplers: string[];
  74229. /**
  74230. * The list of defines used in the shader
  74231. */
  74232. defines: string[];
  74233. }
  74234. /**
  74235. * 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.
  74236. *
  74237. * This returned material effects how the mesh will look based on the code in the shaders.
  74238. *
  74239. * @see http://doc.babylonjs.com/how_to/shader_material
  74240. */
  74241. export class ShaderMaterial extends Material {
  74242. private _shaderPath;
  74243. private _options;
  74244. private _textures;
  74245. private _textureArrays;
  74246. private _floats;
  74247. private _ints;
  74248. private _floatsArrays;
  74249. private _colors3;
  74250. private _colors3Arrays;
  74251. private _colors4;
  74252. private _vectors2;
  74253. private _vectors3;
  74254. private _vectors4;
  74255. private _matrices;
  74256. private _matrices3x3;
  74257. private _matrices2x2;
  74258. private _vectors2Arrays;
  74259. private _vectors3Arrays;
  74260. private _cachedWorldViewMatrix;
  74261. private _renderId;
  74262. /**
  74263. * Instantiate a new shader material.
  74264. * 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.
  74265. * This returned material effects how the mesh will look based on the code in the shaders.
  74266. * @see http://doc.babylonjs.com/how_to/shader_material
  74267. * @param name Define the name of the material in the scene
  74268. * @param scene Define the scene the material belongs to
  74269. * @param shaderPath Defines the route to the shader code in one of three ways:
  74270. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  74271. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  74272. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  74273. * @param options Define the options used to create the shader
  74274. */
  74275. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  74276. /**
  74277. * Gets the options used to compile the shader.
  74278. * They can be modified to trigger a new compilation
  74279. */
  74280. readonly options: IShaderMaterialOptions;
  74281. /**
  74282. * Gets the current class name of the material e.g. "ShaderMaterial"
  74283. * Mainly use in serialization.
  74284. * @returns the class name
  74285. */
  74286. getClassName(): string;
  74287. /**
  74288. * Specifies if the material will require alpha blending
  74289. * @returns a boolean specifying if alpha blending is needed
  74290. */
  74291. needAlphaBlending(): boolean;
  74292. /**
  74293. * Specifies if this material should be rendered in alpha test mode
  74294. * @returns a boolean specifying if an alpha test is needed.
  74295. */
  74296. needAlphaTesting(): boolean;
  74297. private _checkUniform;
  74298. /**
  74299. * Set a texture in the shader.
  74300. * @param name Define the name of the uniform samplers as defined in the shader
  74301. * @param texture Define the texture to bind to this sampler
  74302. * @return the material itself allowing "fluent" like uniform updates
  74303. */
  74304. setTexture(name: string, texture: Texture): ShaderMaterial;
  74305. /**
  74306. * Set a texture array in the shader.
  74307. * @param name Define the name of the uniform sampler array as defined in the shader
  74308. * @param textures Define the list of textures to bind to this sampler
  74309. * @return the material itself allowing "fluent" like uniform updates
  74310. */
  74311. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  74312. /**
  74313. * Set a float in the shader.
  74314. * @param name Define the name of the uniform as defined in the shader
  74315. * @param value Define the value to give to the uniform
  74316. * @return the material itself allowing "fluent" like uniform updates
  74317. */
  74318. setFloat(name: string, value: number): ShaderMaterial;
  74319. /**
  74320. * Set a int in the shader.
  74321. * @param name Define the name of the uniform as defined in the shader
  74322. * @param value Define the value to give to the uniform
  74323. * @return the material itself allowing "fluent" like uniform updates
  74324. */
  74325. setInt(name: string, value: number): ShaderMaterial;
  74326. /**
  74327. * Set an array of floats in the shader.
  74328. * @param name Define the name of the uniform as defined in the shader
  74329. * @param value Define the value to give to the uniform
  74330. * @return the material itself allowing "fluent" like uniform updates
  74331. */
  74332. setFloats(name: string, value: number[]): ShaderMaterial;
  74333. /**
  74334. * Set a vec3 in the shader from a Color3.
  74335. * @param name Define the name of the uniform as defined in the shader
  74336. * @param value Define the value to give to the uniform
  74337. * @return the material itself allowing "fluent" like uniform updates
  74338. */
  74339. setColor3(name: string, value: Color3): ShaderMaterial;
  74340. /**
  74341. * Set a vec3 array in the shader from a Color3 array.
  74342. * @param name Define the name of the uniform as defined in the shader
  74343. * @param value Define the value to give to the uniform
  74344. * @return the material itself allowing "fluent" like uniform updates
  74345. */
  74346. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  74347. /**
  74348. * Set a vec4 in the shader from a Color4.
  74349. * @param name Define the name of the uniform as defined in the shader
  74350. * @param value Define the value to give to the uniform
  74351. * @return the material itself allowing "fluent" like uniform updates
  74352. */
  74353. setColor4(name: string, value: Color4): ShaderMaterial;
  74354. /**
  74355. * Set a vec2 in the shader from a Vector2.
  74356. * @param name Define the name of the uniform as defined in the shader
  74357. * @param value Define the value to give to the uniform
  74358. * @return the material itself allowing "fluent" like uniform updates
  74359. */
  74360. setVector2(name: string, value: Vector2): ShaderMaterial;
  74361. /**
  74362. * Set a vec3 in the shader from a Vector3.
  74363. * @param name Define the name of the uniform as defined in the shader
  74364. * @param value Define the value to give to the uniform
  74365. * @return the material itself allowing "fluent" like uniform updates
  74366. */
  74367. setVector3(name: string, value: Vector3): ShaderMaterial;
  74368. /**
  74369. * Set a vec4 in the shader from a Vector4.
  74370. * @param name Define the name of the uniform as defined in the shader
  74371. * @param value Define the value to give to the uniform
  74372. * @return the material itself allowing "fluent" like uniform updates
  74373. */
  74374. setVector4(name: string, value: Vector4): ShaderMaterial;
  74375. /**
  74376. * Set a mat4 in the shader from a Matrix.
  74377. * @param name Define the name of the uniform as defined in the shader
  74378. * @param value Define the value to give to the uniform
  74379. * @return the material itself allowing "fluent" like uniform updates
  74380. */
  74381. setMatrix(name: string, value: Matrix): ShaderMaterial;
  74382. /**
  74383. * Set a mat3 in the shader from a Float32Array.
  74384. * @param name Define the name of the uniform as defined in the shader
  74385. * @param value Define the value to give to the uniform
  74386. * @return the material itself allowing "fluent" like uniform updates
  74387. */
  74388. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  74389. /**
  74390. * Set a mat2 in the shader from a Float32Array.
  74391. * @param name Define the name of the uniform as defined in the shader
  74392. * @param value Define the value to give to the uniform
  74393. * @return the material itself allowing "fluent" like uniform updates
  74394. */
  74395. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  74396. /**
  74397. * Set a vec2 array in the shader from a number array.
  74398. * @param name Define the name of the uniform as defined in the shader
  74399. * @param value Define the value to give to the uniform
  74400. * @return the material itself allowing "fluent" like uniform updates
  74401. */
  74402. setArray2(name: string, value: number[]): ShaderMaterial;
  74403. /**
  74404. * Set a vec3 array in the shader from a number array.
  74405. * @param name Define the name of the uniform as defined in the shader
  74406. * @param value Define the value to give to the uniform
  74407. * @return the material itself allowing "fluent" like uniform updates
  74408. */
  74409. setArray3(name: string, value: number[]): ShaderMaterial;
  74410. private _checkCache;
  74411. /**
  74412. * Checks if the material is ready to render the requested mesh
  74413. * @param mesh Define the mesh to render
  74414. * @param useInstances Define whether or not the material is used with instances
  74415. * @returns true if ready, otherwise false
  74416. */
  74417. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  74418. /**
  74419. * Binds the world matrix to the material
  74420. * @param world defines the world transformation matrix
  74421. */
  74422. bindOnlyWorldMatrix(world: Matrix): void;
  74423. /**
  74424. * Binds the material to the mesh
  74425. * @param world defines the world transformation matrix
  74426. * @param mesh defines the mesh to bind the material to
  74427. */
  74428. bind(world: Matrix, mesh?: Mesh): void;
  74429. /**
  74430. * Gets the active textures from the material
  74431. * @returns an array of textures
  74432. */
  74433. getActiveTextures(): BaseTexture[];
  74434. /**
  74435. * Specifies if the material uses a texture
  74436. * @param texture defines the texture to check against the material
  74437. * @returns a boolean specifying if the material uses the texture
  74438. */
  74439. hasTexture(texture: BaseTexture): boolean;
  74440. /**
  74441. * Makes a duplicate of the material, and gives it a new name
  74442. * @param name defines the new name for the duplicated material
  74443. * @returns the cloned material
  74444. */
  74445. clone(name: string): ShaderMaterial;
  74446. /**
  74447. * Disposes the material
  74448. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  74449. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  74450. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  74451. */
  74452. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  74453. /**
  74454. * Serializes this material in a JSON representation
  74455. * @returns the serialized material object
  74456. */
  74457. serialize(): any;
  74458. /**
  74459. * Creates a shader material from parsed shader material data
  74460. * @param source defines the JSON represnetation of the material
  74461. * @param scene defines the hosting scene
  74462. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  74463. * @returns a new material
  74464. */
  74465. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  74466. }
  74467. }
  74468. declare module BABYLON {
  74469. /** @hidden */
  74470. export var colorPixelShader: {
  74471. name: string;
  74472. shader: string;
  74473. };
  74474. }
  74475. declare module BABYLON {
  74476. /** @hidden */
  74477. export var colorVertexShader: {
  74478. name: string;
  74479. shader: string;
  74480. };
  74481. }
  74482. declare module BABYLON {
  74483. /**
  74484. * Line mesh
  74485. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  74486. */
  74487. export class LinesMesh extends Mesh {
  74488. /**
  74489. * If vertex color should be applied to the mesh
  74490. */
  74491. useVertexColor?: boolean | undefined;
  74492. /**
  74493. * If vertex alpha should be applied to the mesh
  74494. */
  74495. useVertexAlpha?: boolean | undefined;
  74496. /**
  74497. * Color of the line (Default: White)
  74498. */
  74499. color: Color3;
  74500. /**
  74501. * Alpha of the line (Default: 1)
  74502. */
  74503. alpha: number;
  74504. /**
  74505. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  74506. * This margin is expressed in world space coordinates, so its value may vary.
  74507. * Default value is 0.1
  74508. */
  74509. intersectionThreshold: number;
  74510. private _colorShader;
  74511. /**
  74512. * Creates a new LinesMesh
  74513. * @param name defines the name
  74514. * @param scene defines the hosting scene
  74515. * @param parent defines the parent mesh if any
  74516. * @param source defines the optional source LinesMesh used to clone data from
  74517. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  74518. * When false, achieved by calling a clone(), also passing False.
  74519. * This will make creation of children, recursive.
  74520. * @param useVertexColor defines if this LinesMesh supports vertex color
  74521. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  74522. */
  74523. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  74524. /**
  74525. * If vertex color should be applied to the mesh
  74526. */
  74527. useVertexColor?: boolean | undefined,
  74528. /**
  74529. * If vertex alpha should be applied to the mesh
  74530. */
  74531. useVertexAlpha?: boolean | undefined);
  74532. private _addClipPlaneDefine;
  74533. private _removeClipPlaneDefine;
  74534. isReady(): boolean;
  74535. /**
  74536. * Returns the string "LineMesh"
  74537. */
  74538. getClassName(): string;
  74539. /**
  74540. * @hidden
  74541. */
  74542. /**
  74543. * @hidden
  74544. */
  74545. material: Material;
  74546. /**
  74547. * @hidden
  74548. */
  74549. readonly checkCollisions: boolean;
  74550. /** @hidden */
  74551. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  74552. /** @hidden */
  74553. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  74554. /**
  74555. * Disposes of the line mesh
  74556. * @param doNotRecurse If children should be disposed
  74557. */
  74558. dispose(doNotRecurse?: boolean): void;
  74559. /**
  74560. * Returns a new LineMesh object cloned from the current one.
  74561. */
  74562. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  74563. /**
  74564. * Creates a new InstancedLinesMesh object from the mesh model.
  74565. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  74566. * @param name defines the name of the new instance
  74567. * @returns a new InstancedLinesMesh
  74568. */
  74569. createInstance(name: string): InstancedLinesMesh;
  74570. }
  74571. /**
  74572. * Creates an instance based on a source LinesMesh
  74573. */
  74574. export class InstancedLinesMesh extends InstancedMesh {
  74575. /**
  74576. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  74577. * This margin is expressed in world space coordinates, so its value may vary.
  74578. * Initilized with the intersectionThreshold value of the source LinesMesh
  74579. */
  74580. intersectionThreshold: number;
  74581. constructor(name: string, source: LinesMesh);
  74582. /**
  74583. * Returns the string "InstancedLinesMesh".
  74584. */
  74585. getClassName(): string;
  74586. }
  74587. }
  74588. declare module BABYLON {
  74589. /** @hidden */
  74590. export var linePixelShader: {
  74591. name: string;
  74592. shader: string;
  74593. };
  74594. }
  74595. declare module BABYLON {
  74596. /** @hidden */
  74597. export var lineVertexShader: {
  74598. name: string;
  74599. shader: string;
  74600. };
  74601. }
  74602. declare module BABYLON {
  74603. interface AbstractMesh {
  74604. /**
  74605. * Disables the mesh edge rendering mode
  74606. * @returns the currentAbstractMesh
  74607. */
  74608. disableEdgesRendering(): AbstractMesh;
  74609. /**
  74610. * Enables the edge rendering mode on the mesh.
  74611. * This mode makes the mesh edges visible
  74612. * @param epsilon defines the maximal distance between two angles to detect a face
  74613. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  74614. * @returns the currentAbstractMesh
  74615. * @see https://www.babylonjs-playground.com/#19O9TU#0
  74616. */
  74617. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  74618. /**
  74619. * Gets the edgesRenderer associated with the mesh
  74620. */
  74621. edgesRenderer: Nullable<EdgesRenderer>;
  74622. }
  74623. interface LinesMesh {
  74624. /**
  74625. * Enables the edge rendering mode on the mesh.
  74626. * This mode makes the mesh edges visible
  74627. * @param epsilon defines the maximal distance between two angles to detect a face
  74628. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  74629. * @returns the currentAbstractMesh
  74630. * @see https://www.babylonjs-playground.com/#19O9TU#0
  74631. */
  74632. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  74633. }
  74634. interface InstancedLinesMesh {
  74635. /**
  74636. * Enables the edge rendering mode on the mesh.
  74637. * This mode makes the mesh edges visible
  74638. * @param epsilon defines the maximal distance between two angles to detect a face
  74639. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  74640. * @returns the current InstancedLinesMesh
  74641. * @see https://www.babylonjs-playground.com/#19O9TU#0
  74642. */
  74643. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  74644. }
  74645. /**
  74646. * Defines the minimum contract an Edges renderer should follow.
  74647. */
  74648. export interface IEdgesRenderer extends IDisposable {
  74649. /**
  74650. * Gets or sets a boolean indicating if the edgesRenderer is active
  74651. */
  74652. isEnabled: boolean;
  74653. /**
  74654. * Renders the edges of the attached mesh,
  74655. */
  74656. render(): void;
  74657. /**
  74658. * Checks wether or not the edges renderer is ready to render.
  74659. * @return true if ready, otherwise false.
  74660. */
  74661. isReady(): boolean;
  74662. }
  74663. /**
  74664. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  74665. */
  74666. export class EdgesRenderer implements IEdgesRenderer {
  74667. /**
  74668. * Define the size of the edges with an orthographic camera
  74669. */
  74670. edgesWidthScalerForOrthographic: number;
  74671. /**
  74672. * Define the size of the edges with a perspective camera
  74673. */
  74674. edgesWidthScalerForPerspective: number;
  74675. protected _source: AbstractMesh;
  74676. protected _linesPositions: number[];
  74677. protected _linesNormals: number[];
  74678. protected _linesIndices: number[];
  74679. protected _epsilon: number;
  74680. protected _indicesCount: number;
  74681. protected _lineShader: ShaderMaterial;
  74682. protected _ib: WebGLBuffer;
  74683. protected _buffers: {
  74684. [key: string]: Nullable<VertexBuffer>;
  74685. };
  74686. protected _checkVerticesInsteadOfIndices: boolean;
  74687. private _meshRebuildObserver;
  74688. private _meshDisposeObserver;
  74689. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  74690. isEnabled: boolean;
  74691. /**
  74692. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  74693. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  74694. * @param source Mesh used to create edges
  74695. * @param epsilon sum of angles in adjacency to check for edge
  74696. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  74697. * @param generateEdgesLines - should generate Lines or only prepare resources.
  74698. */
  74699. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  74700. protected _prepareRessources(): void;
  74701. /** @hidden */
  74702. _rebuild(): void;
  74703. /**
  74704. * Releases the required resources for the edges renderer
  74705. */
  74706. dispose(): void;
  74707. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  74708. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  74709. /**
  74710. * Checks if the pair of p0 and p1 is en edge
  74711. * @param faceIndex
  74712. * @param edge
  74713. * @param faceNormals
  74714. * @param p0
  74715. * @param p1
  74716. * @private
  74717. */
  74718. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  74719. /**
  74720. * push line into the position, normal and index buffer
  74721. * @protected
  74722. */
  74723. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  74724. /**
  74725. * Generates lines edges from adjacencjes
  74726. * @private
  74727. */
  74728. _generateEdgesLines(): void;
  74729. /**
  74730. * Checks wether or not the edges renderer is ready to render.
  74731. * @return true if ready, otherwise false.
  74732. */
  74733. isReady(): boolean;
  74734. /**
  74735. * Renders the edges of the attached mesh,
  74736. */
  74737. render(): void;
  74738. }
  74739. /**
  74740. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  74741. */
  74742. export class LineEdgesRenderer extends EdgesRenderer {
  74743. /**
  74744. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  74745. * @param source LineMesh used to generate edges
  74746. * @param epsilon not important (specified angle for edge detection)
  74747. * @param checkVerticesInsteadOfIndices not important for LineMesh
  74748. */
  74749. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  74750. /**
  74751. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  74752. */
  74753. _generateEdgesLines(): void;
  74754. }
  74755. }
  74756. declare module BABYLON {
  74757. /**
  74758. * This represents the object necessary to create a rendering group.
  74759. * This is exclusively used and created by the rendering manager.
  74760. * To modify the behavior, you use the available helpers in your scene or meshes.
  74761. * @hidden
  74762. */
  74763. export class RenderingGroup {
  74764. index: number;
  74765. private _scene;
  74766. private _opaqueSubMeshes;
  74767. private _transparentSubMeshes;
  74768. private _alphaTestSubMeshes;
  74769. private _depthOnlySubMeshes;
  74770. private _particleSystems;
  74771. private _spriteManagers;
  74772. private _opaqueSortCompareFn;
  74773. private _alphaTestSortCompareFn;
  74774. private _transparentSortCompareFn;
  74775. private _renderOpaque;
  74776. private _renderAlphaTest;
  74777. private _renderTransparent;
  74778. private _edgesRenderers;
  74779. onBeforeTransparentRendering: () => void;
  74780. /**
  74781. * Set the opaque sort comparison function.
  74782. * If null the sub meshes will be render in the order they were created
  74783. */
  74784. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  74785. /**
  74786. * Set the alpha test sort comparison function.
  74787. * If null the sub meshes will be render in the order they were created
  74788. */
  74789. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  74790. /**
  74791. * Set the transparent sort comparison function.
  74792. * If null the sub meshes will be render in the order they were created
  74793. */
  74794. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  74795. /**
  74796. * Creates a new rendering group.
  74797. * @param index The rendering group index
  74798. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  74799. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  74800. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  74801. */
  74802. 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>);
  74803. /**
  74804. * Render all the sub meshes contained in the group.
  74805. * @param customRenderFunction Used to override the default render behaviour of the group.
  74806. * @returns true if rendered some submeshes.
  74807. */
  74808. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  74809. /**
  74810. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  74811. * @param subMeshes The submeshes to render
  74812. */
  74813. private renderOpaqueSorted;
  74814. /**
  74815. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  74816. * @param subMeshes The submeshes to render
  74817. */
  74818. private renderAlphaTestSorted;
  74819. /**
  74820. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  74821. * @param subMeshes The submeshes to render
  74822. */
  74823. private renderTransparentSorted;
  74824. /**
  74825. * Renders the submeshes in a specified order.
  74826. * @param subMeshes The submeshes to sort before render
  74827. * @param sortCompareFn The comparison function use to sort
  74828. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  74829. * @param transparent Specifies to activate blending if true
  74830. */
  74831. private static renderSorted;
  74832. /**
  74833. * Renders the submeshes in the order they were dispatched (no sort applied).
  74834. * @param subMeshes The submeshes to render
  74835. */
  74836. private static renderUnsorted;
  74837. /**
  74838. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  74839. * are rendered back to front if in the same alpha index.
  74840. *
  74841. * @param a The first submesh
  74842. * @param b The second submesh
  74843. * @returns The result of the comparison
  74844. */
  74845. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  74846. /**
  74847. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  74848. * are rendered back to front.
  74849. *
  74850. * @param a The first submesh
  74851. * @param b The second submesh
  74852. * @returns The result of the comparison
  74853. */
  74854. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  74855. /**
  74856. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  74857. * are rendered front to back (prevent overdraw).
  74858. *
  74859. * @param a The first submesh
  74860. * @param b The second submesh
  74861. * @returns The result of the comparison
  74862. */
  74863. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  74864. /**
  74865. * Resets the different lists of submeshes to prepare a new frame.
  74866. */
  74867. prepare(): void;
  74868. dispose(): void;
  74869. /**
  74870. * Inserts the submesh in its correct queue depending on its material.
  74871. * @param subMesh The submesh to dispatch
  74872. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  74873. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  74874. */
  74875. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  74876. dispatchSprites(spriteManager: ISpriteManager): void;
  74877. dispatchParticles(particleSystem: IParticleSystem): void;
  74878. private _renderParticles;
  74879. private _renderSprites;
  74880. }
  74881. }
  74882. declare module BABYLON {
  74883. /**
  74884. * Interface describing the different options available in the rendering manager
  74885. * regarding Auto Clear between groups.
  74886. */
  74887. export interface IRenderingManagerAutoClearSetup {
  74888. /**
  74889. * Defines whether or not autoclear is enable.
  74890. */
  74891. autoClear: boolean;
  74892. /**
  74893. * Defines whether or not to autoclear the depth buffer.
  74894. */
  74895. depth: boolean;
  74896. /**
  74897. * Defines whether or not to autoclear the stencil buffer.
  74898. */
  74899. stencil: boolean;
  74900. }
  74901. /**
  74902. * This class is used by the onRenderingGroupObservable
  74903. */
  74904. export class RenderingGroupInfo {
  74905. /**
  74906. * The Scene that being rendered
  74907. */
  74908. scene: Scene;
  74909. /**
  74910. * The camera currently used for the rendering pass
  74911. */
  74912. camera: Nullable<Camera>;
  74913. /**
  74914. * The ID of the renderingGroup being processed
  74915. */
  74916. renderingGroupId: number;
  74917. }
  74918. /**
  74919. * This is the manager responsible of all the rendering for meshes sprites and particles.
  74920. * It is enable to manage the different groups as well as the different necessary sort functions.
  74921. * This should not be used directly aside of the few static configurations
  74922. */
  74923. export class RenderingManager {
  74924. /**
  74925. * The max id used for rendering groups (not included)
  74926. */
  74927. static MAX_RENDERINGGROUPS: number;
  74928. /**
  74929. * The min id used for rendering groups (included)
  74930. */
  74931. static MIN_RENDERINGGROUPS: number;
  74932. /**
  74933. * Used to globally prevent autoclearing scenes.
  74934. */
  74935. static AUTOCLEAR: boolean;
  74936. /**
  74937. * @hidden
  74938. */
  74939. _useSceneAutoClearSetup: boolean;
  74940. private _scene;
  74941. private _renderingGroups;
  74942. private _depthStencilBufferAlreadyCleaned;
  74943. private _autoClearDepthStencil;
  74944. private _customOpaqueSortCompareFn;
  74945. private _customAlphaTestSortCompareFn;
  74946. private _customTransparentSortCompareFn;
  74947. private _renderingGroupInfo;
  74948. /**
  74949. * Instantiates a new rendering group for a particular scene
  74950. * @param scene Defines the scene the groups belongs to
  74951. */
  74952. constructor(scene: Scene);
  74953. private _clearDepthStencilBuffer;
  74954. /**
  74955. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  74956. * @hidden
  74957. */
  74958. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  74959. /**
  74960. * Resets the different information of the group to prepare a new frame
  74961. * @hidden
  74962. */
  74963. reset(): void;
  74964. /**
  74965. * Dispose and release the group and its associated resources.
  74966. * @hidden
  74967. */
  74968. dispose(): void;
  74969. /**
  74970. * Clear the info related to rendering groups preventing retention points during dispose.
  74971. */
  74972. freeRenderingGroups(): void;
  74973. private _prepareRenderingGroup;
  74974. /**
  74975. * Add a sprite manager to the rendering manager in order to render it this frame.
  74976. * @param spriteManager Define the sprite manager to render
  74977. */
  74978. dispatchSprites(spriteManager: ISpriteManager): void;
  74979. /**
  74980. * Add a particle system to the rendering manager in order to render it this frame.
  74981. * @param particleSystem Define the particle system to render
  74982. */
  74983. dispatchParticles(particleSystem: IParticleSystem): void;
  74984. /**
  74985. * Add a submesh to the manager in order to render it this frame
  74986. * @param subMesh The submesh to dispatch
  74987. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  74988. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  74989. */
  74990. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  74991. /**
  74992. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  74993. * This allowed control for front to back rendering or reversly depending of the special needs.
  74994. *
  74995. * @param renderingGroupId The rendering group id corresponding to its index
  74996. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  74997. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  74998. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  74999. */
  75000. 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;
  75001. /**
  75002. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  75003. *
  75004. * @param renderingGroupId The rendering group id corresponding to its index
  75005. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  75006. * @param depth Automatically clears depth between groups if true and autoClear is true.
  75007. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  75008. */
  75009. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  75010. /**
  75011. * Gets the current auto clear configuration for one rendering group of the rendering
  75012. * manager.
  75013. * @param index the rendering group index to get the information for
  75014. * @returns The auto clear setup for the requested rendering group
  75015. */
  75016. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  75017. }
  75018. }
  75019. declare module BABYLON {
  75020. /**
  75021. * This Helps creating a texture that will be created from a camera in your scene.
  75022. * It is basically a dynamic texture that could be used to create special effects for instance.
  75023. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  75024. */
  75025. export class RenderTargetTexture extends Texture {
  75026. isCube: boolean;
  75027. /**
  75028. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  75029. */
  75030. static readonly REFRESHRATE_RENDER_ONCE: number;
  75031. /**
  75032. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  75033. */
  75034. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  75035. /**
  75036. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  75037. * the central point of your effect and can save a lot of performances.
  75038. */
  75039. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  75040. /**
  75041. * Use this predicate to dynamically define the list of mesh you want to render.
  75042. * If set, the renderList property will be overwritten.
  75043. */
  75044. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  75045. private _renderList;
  75046. /**
  75047. * Use this list to define the list of mesh you want to render.
  75048. */
  75049. renderList: Nullable<Array<AbstractMesh>>;
  75050. private _hookArray;
  75051. /**
  75052. * Define if particles should be rendered in your texture.
  75053. */
  75054. renderParticles: boolean;
  75055. /**
  75056. * Define if sprites should be rendered in your texture.
  75057. */
  75058. renderSprites: boolean;
  75059. /**
  75060. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  75061. */
  75062. coordinatesMode: number;
  75063. /**
  75064. * Define the camera used to render the texture.
  75065. */
  75066. activeCamera: Nullable<Camera>;
  75067. /**
  75068. * Override the render function of the texture with your own one.
  75069. */
  75070. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  75071. /**
  75072. * Define if camera post processes should be use while rendering the texture.
  75073. */
  75074. useCameraPostProcesses: boolean;
  75075. /**
  75076. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  75077. */
  75078. ignoreCameraViewport: boolean;
  75079. private _postProcessManager;
  75080. private _postProcesses;
  75081. private _resizeObserver;
  75082. /**
  75083. * An event triggered when the texture is unbind.
  75084. */
  75085. onBeforeBindObservable: Observable<RenderTargetTexture>;
  75086. /**
  75087. * An event triggered when the texture is unbind.
  75088. */
  75089. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  75090. private _onAfterUnbindObserver;
  75091. /**
  75092. * Set a after unbind callback in the texture.
  75093. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  75094. */
  75095. onAfterUnbind: () => void;
  75096. /**
  75097. * An event triggered before rendering the texture
  75098. */
  75099. onBeforeRenderObservable: Observable<number>;
  75100. private _onBeforeRenderObserver;
  75101. /**
  75102. * Set a before render callback in the texture.
  75103. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  75104. */
  75105. onBeforeRender: (faceIndex: number) => void;
  75106. /**
  75107. * An event triggered after rendering the texture
  75108. */
  75109. onAfterRenderObservable: Observable<number>;
  75110. private _onAfterRenderObserver;
  75111. /**
  75112. * Set a after render callback in the texture.
  75113. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  75114. */
  75115. onAfterRender: (faceIndex: number) => void;
  75116. /**
  75117. * An event triggered after the texture clear
  75118. */
  75119. onClearObservable: Observable<Engine>;
  75120. private _onClearObserver;
  75121. /**
  75122. * Set a clear callback in the texture.
  75123. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  75124. */
  75125. onClear: (Engine: Engine) => void;
  75126. /**
  75127. * Define the clear color of the Render Target if it should be different from the scene.
  75128. */
  75129. clearColor: Color4;
  75130. protected _size: number | {
  75131. width: number;
  75132. height: number;
  75133. };
  75134. protected _initialSizeParameter: number | {
  75135. width: number;
  75136. height: number;
  75137. } | {
  75138. ratio: number;
  75139. };
  75140. protected _sizeRatio: Nullable<number>;
  75141. /** @hidden */
  75142. _generateMipMaps: boolean;
  75143. protected _renderingManager: RenderingManager;
  75144. /** @hidden */
  75145. _waitingRenderList: string[];
  75146. protected _doNotChangeAspectRatio: boolean;
  75147. protected _currentRefreshId: number;
  75148. protected _refreshRate: number;
  75149. protected _textureMatrix: Matrix;
  75150. protected _samples: number;
  75151. protected _renderTargetOptions: RenderTargetCreationOptions;
  75152. /**
  75153. * Gets render target creation options that were used.
  75154. */
  75155. readonly renderTargetOptions: RenderTargetCreationOptions;
  75156. protected _engine: Engine;
  75157. protected _onRatioRescale(): void;
  75158. /**
  75159. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  75160. * It must define where the camera used to render the texture is set
  75161. */
  75162. boundingBoxPosition: Vector3;
  75163. private _boundingBoxSize;
  75164. /**
  75165. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  75166. * When defined, the cubemap will switch to local mode
  75167. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  75168. * @example https://www.babylonjs-playground.com/#RNASML
  75169. */
  75170. boundingBoxSize: Vector3;
  75171. /**
  75172. * In case the RTT has been created with a depth texture, get the associated
  75173. * depth texture.
  75174. * Otherwise, return null.
  75175. */
  75176. depthStencilTexture: Nullable<InternalTexture>;
  75177. /**
  75178. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  75179. * or used a shadow, depth texture...
  75180. * @param name The friendly name of the texture
  75181. * @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)
  75182. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  75183. * @param generateMipMaps True if mip maps need to be generated after render.
  75184. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  75185. * @param type The type of the buffer in the RTT (int, half float, float...)
  75186. * @param isCube True if a cube texture needs to be created
  75187. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  75188. * @param generateDepthBuffer True to generate a depth buffer
  75189. * @param generateStencilBuffer True to generate a stencil buffer
  75190. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  75191. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  75192. * @param delayAllocation if the texture allocation should be delayed (default: false)
  75193. */
  75194. constructor(name: string, size: number | {
  75195. width: number;
  75196. height: number;
  75197. } | {
  75198. ratio: number;
  75199. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  75200. /**
  75201. * Creates a depth stencil texture.
  75202. * This is only available in WebGL 2 or with the depth texture extension available.
  75203. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  75204. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  75205. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  75206. */
  75207. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  75208. private _processSizeParameter;
  75209. /**
  75210. * Define the number of samples to use in case of MSAA.
  75211. * It defaults to one meaning no MSAA has been enabled.
  75212. */
  75213. samples: number;
  75214. /**
  75215. * Resets the refresh counter of the texture and start bak from scratch.
  75216. * Could be useful to regenerate the texture if it is setup to render only once.
  75217. */
  75218. resetRefreshCounter(): void;
  75219. /**
  75220. * Define the refresh rate of the texture or the rendering frequency.
  75221. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  75222. */
  75223. refreshRate: number;
  75224. /**
  75225. * Adds a post process to the render target rendering passes.
  75226. * @param postProcess define the post process to add
  75227. */
  75228. addPostProcess(postProcess: PostProcess): void;
  75229. /**
  75230. * Clear all the post processes attached to the render target
  75231. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  75232. */
  75233. clearPostProcesses(dispose?: boolean): void;
  75234. /**
  75235. * Remove one of the post process from the list of attached post processes to the texture
  75236. * @param postProcess define the post process to remove from the list
  75237. */
  75238. removePostProcess(postProcess: PostProcess): void;
  75239. /** @hidden */
  75240. _shouldRender(): boolean;
  75241. /**
  75242. * Gets the actual render size of the texture.
  75243. * @returns the width of the render size
  75244. */
  75245. getRenderSize(): number;
  75246. /**
  75247. * Gets the actual render width of the texture.
  75248. * @returns the width of the render size
  75249. */
  75250. getRenderWidth(): number;
  75251. /**
  75252. * Gets the actual render height of the texture.
  75253. * @returns the height of the render size
  75254. */
  75255. getRenderHeight(): number;
  75256. /**
  75257. * Get if the texture can be rescaled or not.
  75258. */
  75259. readonly canRescale: boolean;
  75260. /**
  75261. * Resize the texture using a ratio.
  75262. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  75263. */
  75264. scale(ratio: number): void;
  75265. /**
  75266. * Get the texture reflection matrix used to rotate/transform the reflection.
  75267. * @returns the reflection matrix
  75268. */
  75269. getReflectionTextureMatrix(): Matrix;
  75270. /**
  75271. * Resize the texture to a new desired size.
  75272. * Be carrefull as it will recreate all the data in the new texture.
  75273. * @param size Define the new size. It can be:
  75274. * - a number for squared texture,
  75275. * - an object containing { width: number, height: number }
  75276. * - or an object containing a ratio { ratio: number }
  75277. */
  75278. resize(size: number | {
  75279. width: number;
  75280. height: number;
  75281. } | {
  75282. ratio: number;
  75283. }): void;
  75284. /**
  75285. * Renders all the objects from the render list into the texture.
  75286. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  75287. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  75288. */
  75289. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  75290. private _bestReflectionRenderTargetDimension;
  75291. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  75292. private renderToTarget;
  75293. /**
  75294. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  75295. * This allowed control for front to back rendering or reversly depending of the special needs.
  75296. *
  75297. * @param renderingGroupId The rendering group id corresponding to its index
  75298. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  75299. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  75300. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  75301. */
  75302. 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;
  75303. /**
  75304. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  75305. *
  75306. * @param renderingGroupId The rendering group id corresponding to its index
  75307. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  75308. */
  75309. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  75310. /**
  75311. * Clones the texture.
  75312. * @returns the cloned texture
  75313. */
  75314. clone(): RenderTargetTexture;
  75315. /**
  75316. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  75317. * @returns The JSON representation of the texture
  75318. */
  75319. serialize(): any;
  75320. /**
  75321. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  75322. */
  75323. disposeFramebufferObjects(): void;
  75324. /**
  75325. * Dispose the texture and release its associated resources.
  75326. */
  75327. dispose(): void;
  75328. /** @hidden */
  75329. _rebuild(): void;
  75330. /**
  75331. * Clear the info related to rendering groups preventing retention point in material dispose.
  75332. */
  75333. freeRenderingGroups(): void;
  75334. }
  75335. }
  75336. declare module BABYLON {
  75337. /**
  75338. * Mirror texture can be used to simulate the view from a mirror in a scene.
  75339. * It will dynamically be rendered every frame to adapt to the camera point of view.
  75340. * You can then easily use it as a reflectionTexture on a flat surface.
  75341. * In case the surface is not a plane, please consider relying on reflection probes.
  75342. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  75343. */
  75344. export class MirrorTexture extends RenderTargetTexture {
  75345. private scene;
  75346. /**
  75347. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  75348. * 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.
  75349. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  75350. */
  75351. mirrorPlane: Plane;
  75352. /**
  75353. * Define the blur ratio used to blur the reflection if needed.
  75354. */
  75355. blurRatio: number;
  75356. /**
  75357. * Define the adaptive blur kernel used to blur the reflection if needed.
  75358. * This will autocompute the closest best match for the `blurKernel`
  75359. */
  75360. adaptiveBlurKernel: number;
  75361. /**
  75362. * Define the blur kernel used to blur the reflection if needed.
  75363. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  75364. */
  75365. blurKernel: number;
  75366. /**
  75367. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  75368. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  75369. */
  75370. blurKernelX: number;
  75371. /**
  75372. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  75373. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  75374. */
  75375. blurKernelY: number;
  75376. private _autoComputeBlurKernel;
  75377. protected _onRatioRescale(): void;
  75378. private _updateGammaSpace;
  75379. private _imageProcessingConfigChangeObserver;
  75380. private _transformMatrix;
  75381. private _mirrorMatrix;
  75382. private _savedViewMatrix;
  75383. private _blurX;
  75384. private _blurY;
  75385. private _adaptiveBlurKernel;
  75386. private _blurKernelX;
  75387. private _blurKernelY;
  75388. private _blurRatio;
  75389. /**
  75390. * Instantiates a Mirror Texture.
  75391. * Mirror texture can be used to simulate the view from a mirror in a scene.
  75392. * It will dynamically be rendered every frame to adapt to the camera point of view.
  75393. * You can then easily use it as a reflectionTexture on a flat surface.
  75394. * In case the surface is not a plane, please consider relying on reflection probes.
  75395. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  75396. * @param name
  75397. * @param size
  75398. * @param scene
  75399. * @param generateMipMaps
  75400. * @param type
  75401. * @param samplingMode
  75402. * @param generateDepthBuffer
  75403. */
  75404. constructor(name: string, size: number | {
  75405. width: number;
  75406. height: number;
  75407. } | {
  75408. ratio: number;
  75409. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  75410. private _preparePostProcesses;
  75411. /**
  75412. * Clone the mirror texture.
  75413. * @returns the cloned texture
  75414. */
  75415. clone(): MirrorTexture;
  75416. /**
  75417. * Serialize the texture to a JSON representation you could use in Parse later on
  75418. * @returns the serialized JSON representation
  75419. */
  75420. serialize(): any;
  75421. /**
  75422. * Dispose the texture and release its associated resources.
  75423. */
  75424. dispose(): void;
  75425. }
  75426. }
  75427. declare module BABYLON {
  75428. /**
  75429. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  75430. * @see http://doc.babylonjs.com/babylon101/materials#texture
  75431. */
  75432. export class Texture extends BaseTexture {
  75433. /** @hidden */
  75434. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  75435. /** @hidden */
  75436. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  75437. /** @hidden */
  75438. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  75439. /** nearest is mag = nearest and min = nearest and mip = linear */
  75440. static readonly NEAREST_SAMPLINGMODE: number;
  75441. /** nearest is mag = nearest and min = nearest and mip = linear */
  75442. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  75443. /** Bilinear is mag = linear and min = linear and mip = nearest */
  75444. static readonly BILINEAR_SAMPLINGMODE: number;
  75445. /** Bilinear is mag = linear and min = linear and mip = nearest */
  75446. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  75447. /** Trilinear is mag = linear and min = linear and mip = linear */
  75448. static readonly TRILINEAR_SAMPLINGMODE: number;
  75449. /** Trilinear is mag = linear and min = linear and mip = linear */
  75450. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  75451. /** mag = nearest and min = nearest and mip = nearest */
  75452. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  75453. /** mag = nearest and min = linear and mip = nearest */
  75454. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  75455. /** mag = nearest and min = linear and mip = linear */
  75456. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  75457. /** mag = nearest and min = linear and mip = none */
  75458. static readonly NEAREST_LINEAR: number;
  75459. /** mag = nearest and min = nearest and mip = none */
  75460. static readonly NEAREST_NEAREST: number;
  75461. /** mag = linear and min = nearest and mip = nearest */
  75462. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  75463. /** mag = linear and min = nearest and mip = linear */
  75464. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  75465. /** mag = linear and min = linear and mip = none */
  75466. static readonly LINEAR_LINEAR: number;
  75467. /** mag = linear and min = nearest and mip = none */
  75468. static readonly LINEAR_NEAREST: number;
  75469. /** Explicit coordinates mode */
  75470. static readonly EXPLICIT_MODE: number;
  75471. /** Spherical coordinates mode */
  75472. static readonly SPHERICAL_MODE: number;
  75473. /** Planar coordinates mode */
  75474. static readonly PLANAR_MODE: number;
  75475. /** Cubic coordinates mode */
  75476. static readonly CUBIC_MODE: number;
  75477. /** Projection coordinates mode */
  75478. static readonly PROJECTION_MODE: number;
  75479. /** Inverse Cubic coordinates mode */
  75480. static readonly SKYBOX_MODE: number;
  75481. /** Inverse Cubic coordinates mode */
  75482. static readonly INVCUBIC_MODE: number;
  75483. /** Equirectangular coordinates mode */
  75484. static readonly EQUIRECTANGULAR_MODE: number;
  75485. /** Equirectangular Fixed coordinates mode */
  75486. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  75487. /** Equirectangular Fixed Mirrored coordinates mode */
  75488. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  75489. /** Texture is not repeating outside of 0..1 UVs */
  75490. static readonly CLAMP_ADDRESSMODE: number;
  75491. /** Texture is repeating outside of 0..1 UVs */
  75492. static readonly WRAP_ADDRESSMODE: number;
  75493. /** Texture is repeating and mirrored */
  75494. static readonly MIRROR_ADDRESSMODE: number;
  75495. /**
  75496. * 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
  75497. */
  75498. static UseSerializedUrlIfAny: boolean;
  75499. /**
  75500. * Define the url of the texture.
  75501. */
  75502. url: Nullable<string>;
  75503. /**
  75504. * Define an offset on the texture to offset the u coordinates of the UVs
  75505. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  75506. */
  75507. uOffset: number;
  75508. /**
  75509. * Define an offset on the texture to offset the v coordinates of the UVs
  75510. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  75511. */
  75512. vOffset: number;
  75513. /**
  75514. * Define an offset on the texture to scale the u coordinates of the UVs
  75515. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  75516. */
  75517. uScale: number;
  75518. /**
  75519. * Define an offset on the texture to scale the v coordinates of the UVs
  75520. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  75521. */
  75522. vScale: number;
  75523. /**
  75524. * Define an offset on the texture to rotate around the u coordinates of the UVs
  75525. * @see http://doc.babylonjs.com/how_to/more_materials
  75526. */
  75527. uAng: number;
  75528. /**
  75529. * Define an offset on the texture to rotate around the v coordinates of the UVs
  75530. * @see http://doc.babylonjs.com/how_to/more_materials
  75531. */
  75532. vAng: number;
  75533. /**
  75534. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  75535. * @see http://doc.babylonjs.com/how_to/more_materials
  75536. */
  75537. wAng: number;
  75538. /**
  75539. * Defines the center of rotation (U)
  75540. */
  75541. uRotationCenter: number;
  75542. /**
  75543. * Defines the center of rotation (V)
  75544. */
  75545. vRotationCenter: number;
  75546. /**
  75547. * Defines the center of rotation (W)
  75548. */
  75549. wRotationCenter: number;
  75550. /**
  75551. * Are mip maps generated for this texture or not.
  75552. */
  75553. readonly noMipmap: boolean;
  75554. private _noMipmap;
  75555. /** @hidden */
  75556. _invertY: boolean;
  75557. private _rowGenerationMatrix;
  75558. private _cachedTextureMatrix;
  75559. private _projectionModeMatrix;
  75560. private _t0;
  75561. private _t1;
  75562. private _t2;
  75563. private _cachedUOffset;
  75564. private _cachedVOffset;
  75565. private _cachedUScale;
  75566. private _cachedVScale;
  75567. private _cachedUAng;
  75568. private _cachedVAng;
  75569. private _cachedWAng;
  75570. private _cachedProjectionMatrixId;
  75571. private _cachedCoordinatesMode;
  75572. /** @hidden */
  75573. protected _initialSamplingMode: number;
  75574. /** @hidden */
  75575. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  75576. private _deleteBuffer;
  75577. protected _format: Nullable<number>;
  75578. private _delayedOnLoad;
  75579. private _delayedOnError;
  75580. /**
  75581. * Observable triggered once the texture has been loaded.
  75582. */
  75583. onLoadObservable: Observable<Texture>;
  75584. protected _isBlocking: boolean;
  75585. /**
  75586. * Is the texture preventing material to render while loading.
  75587. * If false, a default texture will be used instead of the loading one during the preparation step.
  75588. */
  75589. isBlocking: boolean;
  75590. /**
  75591. * Get the current sampling mode associated with the texture.
  75592. */
  75593. readonly samplingMode: number;
  75594. /**
  75595. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  75596. */
  75597. readonly invertY: boolean;
  75598. /**
  75599. * Instantiates a new texture.
  75600. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  75601. * @see http://doc.babylonjs.com/babylon101/materials#texture
  75602. * @param url define the url of the picture to load as a texture
  75603. * @param scene define the scene the texture will belong to
  75604. * @param noMipmap define if the texture will require mip maps or not
  75605. * @param invertY define if the texture needs to be inverted on the y axis during loading
  75606. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  75607. * @param onLoad define a callback triggered when the texture has been loaded
  75608. * @param onError define a callback triggered when an error occurred during the loading session
  75609. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  75610. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  75611. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  75612. */
  75613. 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);
  75614. /**
  75615. * Update the url (and optional buffer) of this texture if url was null during construction.
  75616. * @param url the url of the texture
  75617. * @param buffer the buffer of the texture (defaults to null)
  75618. * @param onLoad callback called when the texture is loaded (defaults to null)
  75619. */
  75620. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  75621. /**
  75622. * Finish the loading sequence of a texture flagged as delayed load.
  75623. * @hidden
  75624. */
  75625. delayLoad(): void;
  75626. private _prepareRowForTextureGeneration;
  75627. /**
  75628. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  75629. * @returns the transform matrix of the texture.
  75630. */
  75631. getTextureMatrix(): Matrix;
  75632. /**
  75633. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  75634. * @returns The reflection texture transform
  75635. */
  75636. getReflectionTextureMatrix(): Matrix;
  75637. /**
  75638. * Clones the texture.
  75639. * @returns the cloned texture
  75640. */
  75641. clone(): Texture;
  75642. /**
  75643. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  75644. * @returns The JSON representation of the texture
  75645. */
  75646. serialize(): any;
  75647. /**
  75648. * Get the current class name of the texture useful for serialization or dynamic coding.
  75649. * @returns "Texture"
  75650. */
  75651. getClassName(): string;
  75652. /**
  75653. * Dispose the texture and release its associated resources.
  75654. */
  75655. dispose(): void;
  75656. /**
  75657. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  75658. * @param parsedTexture Define the JSON representation of the texture
  75659. * @param scene Define the scene the parsed texture should be instantiated in
  75660. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  75661. * @returns The parsed texture if successful
  75662. */
  75663. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  75664. /**
  75665. * Creates a texture from its base 64 representation.
  75666. * @param data Define the base64 payload without the data: prefix
  75667. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  75668. * @param scene Define the scene the texture should belong to
  75669. * @param noMipmap Forces the texture to not create mip map information if true
  75670. * @param invertY define if the texture needs to be inverted on the y axis during loading
  75671. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  75672. * @param onLoad define a callback triggered when the texture has been loaded
  75673. * @param onError define a callback triggered when an error occurred during the loading session
  75674. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  75675. * @returns the created texture
  75676. */
  75677. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  75678. /**
  75679. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  75680. * @param data Define the base64 payload without the data: prefix
  75681. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  75682. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  75683. * @param scene Define the scene the texture should belong to
  75684. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  75685. * @param noMipmap Forces the texture to not create mip map information if true
  75686. * @param invertY define if the texture needs to be inverted on the y axis during loading
  75687. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  75688. * @param onLoad define a callback triggered when the texture has been loaded
  75689. * @param onError define a callback triggered when an error occurred during the loading session
  75690. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  75691. * @returns the created texture
  75692. */
  75693. 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;
  75694. }
  75695. }
  75696. declare module BABYLON {
  75697. /**
  75698. * Raw texture can help creating a texture directly from an array of data.
  75699. * This can be super useful if you either get the data from an uncompressed source or
  75700. * if you wish to create your texture pixel by pixel.
  75701. */
  75702. export class RawTexture extends Texture {
  75703. /**
  75704. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75705. */
  75706. format: number;
  75707. private _engine;
  75708. /**
  75709. * Instantiates a new RawTexture.
  75710. * Raw texture can help creating a texture directly from an array of data.
  75711. * This can be super useful if you either get the data from an uncompressed source or
  75712. * if you wish to create your texture pixel by pixel.
  75713. * @param data define the array of data to use to create the texture
  75714. * @param width define the width of the texture
  75715. * @param height define the height of the texture
  75716. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75717. * @param scene define the scene the texture belongs to
  75718. * @param generateMipMaps define whether mip maps should be generated or not
  75719. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75720. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75721. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75722. */
  75723. constructor(data: ArrayBufferView, width: number, height: number,
  75724. /**
  75725. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75726. */
  75727. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  75728. /**
  75729. * Updates the texture underlying data.
  75730. * @param data Define the new data of the texture
  75731. */
  75732. update(data: ArrayBufferView): void;
  75733. /**
  75734. * Creates a luminance texture from some data.
  75735. * @param data Define the texture data
  75736. * @param width Define the width of the texture
  75737. * @param height Define the height of the texture
  75738. * @param scene Define the scene the texture belongs to
  75739. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75740. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75741. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75742. * @returns the luminance texture
  75743. */
  75744. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75745. /**
  75746. * Creates a luminance alpha texture from some data.
  75747. * @param data Define the texture data
  75748. * @param width Define the width of the texture
  75749. * @param height Define the height of the texture
  75750. * @param scene Define the scene the texture belongs to
  75751. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75752. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75753. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75754. * @returns the luminance alpha texture
  75755. */
  75756. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75757. /**
  75758. * Creates an alpha texture from some data.
  75759. * @param data Define the texture data
  75760. * @param width Define the width of the texture
  75761. * @param height Define the height of the texture
  75762. * @param scene Define the scene the texture belongs to
  75763. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75764. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75765. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75766. * @returns the alpha texture
  75767. */
  75768. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75769. /**
  75770. * Creates a RGB texture from some data.
  75771. * @param data Define the texture data
  75772. * @param width Define the width of the texture
  75773. * @param height Define the height of the texture
  75774. * @param scene Define the scene the texture belongs to
  75775. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75776. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75777. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75778. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75779. * @returns the RGB alpha texture
  75780. */
  75781. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75782. /**
  75783. * Creates a RGBA texture from some data.
  75784. * @param data Define the texture data
  75785. * @param width Define the width of the texture
  75786. * @param height Define the height of the texture
  75787. * @param scene Define the scene the texture belongs to
  75788. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75789. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75790. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75791. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75792. * @returns the RGBA texture
  75793. */
  75794. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75795. /**
  75796. * Creates a R texture from some data.
  75797. * @param data Define the texture data
  75798. * @param width Define the width of the texture
  75799. * @param height Define the height of the texture
  75800. * @param scene Define the scene the texture belongs to
  75801. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75802. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75803. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75804. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75805. * @returns the R texture
  75806. */
  75807. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75808. }
  75809. }
  75810. declare module BABYLON {
  75811. /**
  75812. * Defines a runtime animation
  75813. */
  75814. export class RuntimeAnimation {
  75815. private _events;
  75816. /**
  75817. * The current frame of the runtime animation
  75818. */
  75819. private _currentFrame;
  75820. /**
  75821. * The animation used by the runtime animation
  75822. */
  75823. private _animation;
  75824. /**
  75825. * The target of the runtime animation
  75826. */
  75827. private _target;
  75828. /**
  75829. * The initiating animatable
  75830. */
  75831. private _host;
  75832. /**
  75833. * The original value of the runtime animation
  75834. */
  75835. private _originalValue;
  75836. /**
  75837. * The original blend value of the runtime animation
  75838. */
  75839. private _originalBlendValue;
  75840. /**
  75841. * The offsets cache of the runtime animation
  75842. */
  75843. private _offsetsCache;
  75844. /**
  75845. * The high limits cache of the runtime animation
  75846. */
  75847. private _highLimitsCache;
  75848. /**
  75849. * Specifies if the runtime animation has been stopped
  75850. */
  75851. private _stopped;
  75852. /**
  75853. * The blending factor of the runtime animation
  75854. */
  75855. private _blendingFactor;
  75856. /**
  75857. * The BabylonJS scene
  75858. */
  75859. private _scene;
  75860. /**
  75861. * The current value of the runtime animation
  75862. */
  75863. private _currentValue;
  75864. /** @hidden */
  75865. _workValue: any;
  75866. /**
  75867. * The active target of the runtime animation
  75868. */
  75869. private _activeTarget;
  75870. /**
  75871. * The target path of the runtime animation
  75872. */
  75873. private _targetPath;
  75874. /**
  75875. * The weight of the runtime animation
  75876. */
  75877. private _weight;
  75878. /**
  75879. * The ratio offset of the runtime animation
  75880. */
  75881. private _ratioOffset;
  75882. /**
  75883. * The previous delay of the runtime animation
  75884. */
  75885. private _previousDelay;
  75886. /**
  75887. * The previous ratio of the runtime animation
  75888. */
  75889. private _previousRatio;
  75890. /**
  75891. * Gets the current frame of the runtime animation
  75892. */
  75893. readonly currentFrame: number;
  75894. /**
  75895. * Gets the weight of the runtime animation
  75896. */
  75897. readonly weight: number;
  75898. /**
  75899. * Gets the current value of the runtime animation
  75900. */
  75901. readonly currentValue: any;
  75902. /**
  75903. * Gets the target path of the runtime animation
  75904. */
  75905. readonly targetPath: string;
  75906. /**
  75907. * Gets the actual target of the runtime animation
  75908. */
  75909. readonly target: any;
  75910. /**
  75911. * Create a new RuntimeAnimation object
  75912. * @param target defines the target of the animation
  75913. * @param animation defines the source animation object
  75914. * @param scene defines the hosting scene
  75915. * @param host defines the initiating Animatable
  75916. */
  75917. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  75918. /**
  75919. * Gets the animation from the runtime animation
  75920. */
  75921. readonly animation: Animation;
  75922. /**
  75923. * Resets the runtime animation to the beginning
  75924. * @param restoreOriginal defines whether to restore the target property to the original value
  75925. */
  75926. reset(restoreOriginal?: boolean): void;
  75927. /**
  75928. * Specifies if the runtime animation is stopped
  75929. * @returns Boolean specifying if the runtime animation is stopped
  75930. */
  75931. isStopped(): boolean;
  75932. /**
  75933. * Disposes of the runtime animation
  75934. */
  75935. dispose(): void;
  75936. /**
  75937. * Interpolates the animation from the current frame
  75938. * @param currentFrame The frame to interpolate the animation to
  75939. * @param repeatCount The number of times that the animation should loop
  75940. * @param loopMode The type of looping mode to use
  75941. * @param offsetValue Animation offset value
  75942. * @param highLimitValue The high limit value
  75943. * @returns The interpolated value
  75944. */
  75945. private _interpolate;
  75946. /**
  75947. * Apply the interpolated value to the target
  75948. * @param currentValue defines the value computed by the animation
  75949. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  75950. */
  75951. setValue(currentValue: any, weight?: number): void;
  75952. private _setValue;
  75953. /**
  75954. * Gets the loop pmode of the runtime animation
  75955. * @returns Loop Mode
  75956. */
  75957. private _getCorrectLoopMode;
  75958. /**
  75959. * Move the current animation to a given frame
  75960. * @param frame defines the frame to move to
  75961. */
  75962. goToFrame(frame: number): void;
  75963. /**
  75964. * @hidden Internal use only
  75965. */
  75966. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  75967. /**
  75968. * Execute the current animation
  75969. * @param delay defines the delay to add to the current frame
  75970. * @param from defines the lower bound of the animation range
  75971. * @param to defines the upper bound of the animation range
  75972. * @param loop defines if the current animation must loop
  75973. * @param speedRatio defines the current speed ratio
  75974. * @param weight defines the weight of the animation (default is -1 so no weight)
  75975. * @param onLoop optional callback called when animation loops
  75976. * @returns a boolean indicating if the animation is running
  75977. */
  75978. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  75979. }
  75980. }
  75981. declare module BABYLON {
  75982. /**
  75983. * Class used to store an actual running animation
  75984. */
  75985. export class Animatable {
  75986. /** defines the target object */
  75987. target: any;
  75988. /** defines the starting frame number (default is 0) */
  75989. fromFrame: number;
  75990. /** defines the ending frame number (default is 100) */
  75991. toFrame: number;
  75992. /** defines if the animation must loop (default is false) */
  75993. loopAnimation: boolean;
  75994. /** defines a callback to call when animation ends if it is not looping */
  75995. onAnimationEnd?: (() => void) | null | undefined;
  75996. /** defines a callback to call when animation loops */
  75997. onAnimationLoop?: (() => void) | null | undefined;
  75998. private _localDelayOffset;
  75999. private _pausedDelay;
  76000. private _runtimeAnimations;
  76001. private _paused;
  76002. private _scene;
  76003. private _speedRatio;
  76004. private _weight;
  76005. private _syncRoot;
  76006. /**
  76007. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  76008. * This will only apply for non looping animation (default is true)
  76009. */
  76010. disposeOnEnd: boolean;
  76011. /**
  76012. * Gets a boolean indicating if the animation has started
  76013. */
  76014. animationStarted: boolean;
  76015. /**
  76016. * Observer raised when the animation ends
  76017. */
  76018. onAnimationEndObservable: Observable<Animatable>;
  76019. /**
  76020. * Observer raised when the animation loops
  76021. */
  76022. onAnimationLoopObservable: Observable<Animatable>;
  76023. /**
  76024. * Gets the root Animatable used to synchronize and normalize animations
  76025. */
  76026. readonly syncRoot: Animatable;
  76027. /**
  76028. * Gets the current frame of the first RuntimeAnimation
  76029. * Used to synchronize Animatables
  76030. */
  76031. readonly masterFrame: number;
  76032. /**
  76033. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  76034. */
  76035. weight: number;
  76036. /**
  76037. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  76038. */
  76039. speedRatio: number;
  76040. /**
  76041. * Creates a new Animatable
  76042. * @param scene defines the hosting scene
  76043. * @param target defines the target object
  76044. * @param fromFrame defines the starting frame number (default is 0)
  76045. * @param toFrame defines the ending frame number (default is 100)
  76046. * @param loopAnimation defines if the animation must loop (default is false)
  76047. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  76048. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  76049. * @param animations defines a group of animation to add to the new Animatable
  76050. * @param onAnimationLoop defines a callback to call when animation loops
  76051. */
  76052. constructor(scene: Scene,
  76053. /** defines the target object */
  76054. target: any,
  76055. /** defines the starting frame number (default is 0) */
  76056. fromFrame?: number,
  76057. /** defines the ending frame number (default is 100) */
  76058. toFrame?: number,
  76059. /** defines if the animation must loop (default is false) */
  76060. loopAnimation?: boolean, speedRatio?: number,
  76061. /** defines a callback to call when animation ends if it is not looping */
  76062. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  76063. /** defines a callback to call when animation loops */
  76064. onAnimationLoop?: (() => void) | null | undefined);
  76065. /**
  76066. * Synchronize and normalize current Animatable with a source Animatable
  76067. * This is useful when using animation weights and when animations are not of the same length
  76068. * @param root defines the root Animatable to synchronize with
  76069. * @returns the current Animatable
  76070. */
  76071. syncWith(root: Animatable): Animatable;
  76072. /**
  76073. * Gets the list of runtime animations
  76074. * @returns an array of RuntimeAnimation
  76075. */
  76076. getAnimations(): RuntimeAnimation[];
  76077. /**
  76078. * Adds more animations to the current animatable
  76079. * @param target defines the target of the animations
  76080. * @param animations defines the new animations to add
  76081. */
  76082. appendAnimations(target: any, animations: Animation[]): void;
  76083. /**
  76084. * Gets the source animation for a specific property
  76085. * @param property defines the propertyu to look for
  76086. * @returns null or the source animation for the given property
  76087. */
  76088. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  76089. /**
  76090. * Gets the runtime animation for a specific property
  76091. * @param property defines the propertyu to look for
  76092. * @returns null or the runtime animation for the given property
  76093. */
  76094. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  76095. /**
  76096. * Resets the animatable to its original state
  76097. */
  76098. reset(): void;
  76099. /**
  76100. * Allows the animatable to blend with current running animations
  76101. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76102. * @param blendingSpeed defines the blending speed to use
  76103. */
  76104. enableBlending(blendingSpeed: number): void;
  76105. /**
  76106. * Disable animation blending
  76107. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76108. */
  76109. disableBlending(): void;
  76110. /**
  76111. * Jump directly to a given frame
  76112. * @param frame defines the frame to jump to
  76113. */
  76114. goToFrame(frame: number): void;
  76115. /**
  76116. * Pause the animation
  76117. */
  76118. pause(): void;
  76119. /**
  76120. * Restart the animation
  76121. */
  76122. restart(): void;
  76123. private _raiseOnAnimationEnd;
  76124. /**
  76125. * Stop and delete the current animation
  76126. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  76127. * @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)
  76128. */
  76129. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  76130. /**
  76131. * Wait asynchronously for the animation to end
  76132. * @returns a promise which will be fullfilled when the animation ends
  76133. */
  76134. waitAsync(): Promise<Animatable>;
  76135. /** @hidden */
  76136. _animate(delay: number): boolean;
  76137. }
  76138. interface Scene {
  76139. /** @hidden */
  76140. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  76141. /** @hidden */
  76142. _processLateAnimationBindingsForMatrices(holder: {
  76143. totalWeight: number;
  76144. animations: RuntimeAnimation[];
  76145. originalValue: Matrix;
  76146. }): any;
  76147. /** @hidden */
  76148. _processLateAnimationBindingsForQuaternions(holder: {
  76149. totalWeight: number;
  76150. animations: RuntimeAnimation[];
  76151. originalValue: Quaternion;
  76152. }, refQuaternion: Quaternion): Quaternion;
  76153. /** @hidden */
  76154. _processLateAnimationBindings(): void;
  76155. /**
  76156. * Will start the animation sequence of a given target
  76157. * @param target defines the target
  76158. * @param from defines from which frame should animation start
  76159. * @param to defines until which frame should animation run.
  76160. * @param weight defines the weight to apply to the animation (1.0 by default)
  76161. * @param loop defines if the animation loops
  76162. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76163. * @param onAnimationEnd defines the function to be executed when the animation ends
  76164. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76165. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  76166. * @param onAnimationLoop defines the callback to call when an animation loops
  76167. * @returns the animatable object created for this animation
  76168. */
  76169. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  76170. /**
  76171. * Will start the animation sequence of a given target
  76172. * @param target defines the target
  76173. * @param from defines from which frame should animation start
  76174. * @param to defines until which frame should animation run.
  76175. * @param loop defines if the animation loops
  76176. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76177. * @param onAnimationEnd defines the function to be executed when the animation ends
  76178. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76179. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  76180. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  76181. * @param onAnimationLoop defines the callback to call when an animation loops
  76182. * @returns the animatable object created for this animation
  76183. */
  76184. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  76185. /**
  76186. * Will start the animation sequence of a given target and its hierarchy
  76187. * @param target defines the target
  76188. * @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.
  76189. * @param from defines from which frame should animation start
  76190. * @param to defines until which frame should animation run.
  76191. * @param loop defines if the animation loops
  76192. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76193. * @param onAnimationEnd defines the function to be executed when the animation ends
  76194. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76195. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  76196. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  76197. * @param onAnimationLoop defines the callback to call when an animation loops
  76198. * @returns the list of created animatables
  76199. */
  76200. 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[];
  76201. /**
  76202. * Begin a new animation on a given node
  76203. * @param target defines the target where the animation will take place
  76204. * @param animations defines the list of animations to start
  76205. * @param from defines the initial value
  76206. * @param to defines the final value
  76207. * @param loop defines if you want animation to loop (off by default)
  76208. * @param speedRatio defines the speed ratio to apply to all animations
  76209. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  76210. * @param onAnimationLoop defines the callback to call when an animation loops
  76211. * @returns the list of created animatables
  76212. */
  76213. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  76214. /**
  76215. * Begin a new animation on a given node and its hierarchy
  76216. * @param target defines the root node where the animation will take place
  76217. * @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.
  76218. * @param animations defines the list of animations to start
  76219. * @param from defines the initial value
  76220. * @param to defines the final value
  76221. * @param loop defines if you want animation to loop (off by default)
  76222. * @param speedRatio defines the speed ratio to apply to all animations
  76223. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  76224. * @param onAnimationLoop defines the callback to call when an animation loops
  76225. * @returns the list of animatables created for all nodes
  76226. */
  76227. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  76228. /**
  76229. * Gets the animatable associated with a specific target
  76230. * @param target defines the target of the animatable
  76231. * @returns the required animatable if found
  76232. */
  76233. getAnimatableByTarget(target: any): Nullable<Animatable>;
  76234. /**
  76235. * Gets all animatables associated with a given target
  76236. * @param target defines the target to look animatables for
  76237. * @returns an array of Animatables
  76238. */
  76239. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  76240. /**
  76241. * Will stop the animation of the given target
  76242. * @param target - the target
  76243. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  76244. * @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)
  76245. */
  76246. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  76247. /**
  76248. * Stops and removes all animations that have been applied to the scene
  76249. */
  76250. stopAllAnimations(): void;
  76251. }
  76252. interface Bone {
  76253. /**
  76254. * Copy an animation range from another bone
  76255. * @param source defines the source bone
  76256. * @param rangeName defines the range name to copy
  76257. * @param frameOffset defines the frame offset
  76258. * @param rescaleAsRequired defines if rescaling must be applied if required
  76259. * @param skelDimensionsRatio defines the scaling ratio
  76260. * @returns true if operation was successful
  76261. */
  76262. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  76263. }
  76264. }
  76265. declare module BABYLON {
  76266. /**
  76267. * Class used to handle skinning animations
  76268. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  76269. */
  76270. export class Skeleton implements IAnimatable {
  76271. /** defines the skeleton name */
  76272. name: string;
  76273. /** defines the skeleton Id */
  76274. id: string;
  76275. /**
  76276. * Defines the list of child bones
  76277. */
  76278. bones: Bone[];
  76279. /**
  76280. * Defines an estimate of the dimension of the skeleton at rest
  76281. */
  76282. dimensionsAtRest: Vector3;
  76283. /**
  76284. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  76285. */
  76286. needInitialSkinMatrix: boolean;
  76287. /**
  76288. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  76289. */
  76290. overrideMesh: Nullable<AbstractMesh>;
  76291. /**
  76292. * Gets the list of animations attached to this skeleton
  76293. */
  76294. animations: Array<Animation>;
  76295. private _scene;
  76296. private _isDirty;
  76297. private _transformMatrices;
  76298. private _transformMatrixTexture;
  76299. private _meshesWithPoseMatrix;
  76300. private _animatables;
  76301. private _identity;
  76302. private _synchronizedWithMesh;
  76303. private _ranges;
  76304. private _lastAbsoluteTransformsUpdateId;
  76305. private _canUseTextureForBones;
  76306. /** @hidden */
  76307. _numBonesWithLinkedTransformNode: number;
  76308. /**
  76309. * Specifies if the skeleton should be serialized
  76310. */
  76311. doNotSerialize: boolean;
  76312. private _useTextureToStoreBoneMatrices;
  76313. /**
  76314. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  76315. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  76316. */
  76317. useTextureToStoreBoneMatrices: boolean;
  76318. private _animationPropertiesOverride;
  76319. /**
  76320. * Gets or sets the animation properties override
  76321. */
  76322. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  76323. /**
  76324. * An observable triggered before computing the skeleton's matrices
  76325. */
  76326. onBeforeComputeObservable: Observable<Skeleton>;
  76327. /**
  76328. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  76329. */
  76330. readonly isUsingTextureForMatrices: boolean;
  76331. /**
  76332. * Creates a new skeleton
  76333. * @param name defines the skeleton name
  76334. * @param id defines the skeleton Id
  76335. * @param scene defines the hosting scene
  76336. */
  76337. constructor(
  76338. /** defines the skeleton name */
  76339. name: string,
  76340. /** defines the skeleton Id */
  76341. id: string, scene: Scene);
  76342. /**
  76343. * Gets the current object class name.
  76344. * @return the class name
  76345. */
  76346. getClassName(): string;
  76347. /**
  76348. * Returns an array containing the root bones
  76349. * @returns an array containing the root bones
  76350. */
  76351. getChildren(): Array<Bone>;
  76352. /**
  76353. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  76354. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  76355. * @returns a Float32Array containing matrices data
  76356. */
  76357. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  76358. /**
  76359. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  76360. * @returns a raw texture containing the data
  76361. */
  76362. getTransformMatrixTexture(): Nullable<RawTexture>;
  76363. /**
  76364. * Gets the current hosting scene
  76365. * @returns a scene object
  76366. */
  76367. getScene(): Scene;
  76368. /**
  76369. * Gets a string representing the current skeleton data
  76370. * @param fullDetails defines a boolean indicating if we want a verbose version
  76371. * @returns a string representing the current skeleton data
  76372. */
  76373. toString(fullDetails?: boolean): string;
  76374. /**
  76375. * Get bone's index searching by name
  76376. * @param name defines bone's name to search for
  76377. * @return the indice of the bone. Returns -1 if not found
  76378. */
  76379. getBoneIndexByName(name: string): number;
  76380. /**
  76381. * Creater a new animation range
  76382. * @param name defines the name of the range
  76383. * @param from defines the start key
  76384. * @param to defines the end key
  76385. */
  76386. createAnimationRange(name: string, from: number, to: number): void;
  76387. /**
  76388. * Delete a specific animation range
  76389. * @param name defines the name of the range
  76390. * @param deleteFrames defines if frames must be removed as well
  76391. */
  76392. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  76393. /**
  76394. * Gets a specific animation range
  76395. * @param name defines the name of the range to look for
  76396. * @returns the requested animation range or null if not found
  76397. */
  76398. getAnimationRange(name: string): Nullable<AnimationRange>;
  76399. /**
  76400. * Gets the list of all animation ranges defined on this skeleton
  76401. * @returns an array
  76402. */
  76403. getAnimationRanges(): Nullable<AnimationRange>[];
  76404. /**
  76405. * Copy animation range from a source skeleton.
  76406. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  76407. * @param source defines the source skeleton
  76408. * @param name defines the name of the range to copy
  76409. * @param rescaleAsRequired defines if rescaling must be applied if required
  76410. * @returns true if operation was successful
  76411. */
  76412. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  76413. /**
  76414. * Forces the skeleton to go to rest pose
  76415. */
  76416. returnToRest(): void;
  76417. private _getHighestAnimationFrame;
  76418. /**
  76419. * Begin a specific animation range
  76420. * @param name defines the name of the range to start
  76421. * @param loop defines if looping must be turned on (false by default)
  76422. * @param speedRatio defines the speed ratio to apply (1 by default)
  76423. * @param onAnimationEnd defines a callback which will be called when animation will end
  76424. * @returns a new animatable
  76425. */
  76426. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  76427. /** @hidden */
  76428. _markAsDirty(): void;
  76429. /** @hidden */
  76430. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  76431. /** @hidden */
  76432. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  76433. private _computeTransformMatrices;
  76434. /**
  76435. * Build all resources required to render a skeleton
  76436. */
  76437. prepare(): void;
  76438. /**
  76439. * Gets the list of animatables currently running for this skeleton
  76440. * @returns an array of animatables
  76441. */
  76442. getAnimatables(): IAnimatable[];
  76443. /**
  76444. * Clone the current skeleton
  76445. * @param name defines the name of the new skeleton
  76446. * @param id defines the id of the enw skeleton
  76447. * @returns the new skeleton
  76448. */
  76449. clone(name: string, id: string): Skeleton;
  76450. /**
  76451. * Enable animation blending for this skeleton
  76452. * @param blendingSpeed defines the blending speed to apply
  76453. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76454. */
  76455. enableBlending(blendingSpeed?: number): void;
  76456. /**
  76457. * Releases all resources associated with the current skeleton
  76458. */
  76459. dispose(): void;
  76460. /**
  76461. * Serialize the skeleton in a JSON object
  76462. * @returns a JSON object
  76463. */
  76464. serialize(): any;
  76465. /**
  76466. * Creates a new skeleton from serialized data
  76467. * @param parsedSkeleton defines the serialized data
  76468. * @param scene defines the hosting scene
  76469. * @returns a new skeleton
  76470. */
  76471. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  76472. /**
  76473. * Compute all node absolute transforms
  76474. * @param forceUpdate defines if computation must be done even if cache is up to date
  76475. */
  76476. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  76477. /**
  76478. * Gets the root pose matrix
  76479. * @returns a matrix
  76480. */
  76481. getPoseMatrix(): Nullable<Matrix>;
  76482. /**
  76483. * Sorts bones per internal index
  76484. */
  76485. sortBones(): void;
  76486. private _sortBones;
  76487. }
  76488. }
  76489. declare module BABYLON {
  76490. /**
  76491. * Defines a target to use with MorphTargetManager
  76492. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  76493. */
  76494. export class MorphTarget implements IAnimatable {
  76495. /** defines the name of the target */
  76496. name: string;
  76497. /**
  76498. * Gets or sets the list of animations
  76499. */
  76500. animations: Animation[];
  76501. private _scene;
  76502. private _positions;
  76503. private _normals;
  76504. private _tangents;
  76505. private _influence;
  76506. /**
  76507. * Observable raised when the influence changes
  76508. */
  76509. onInfluenceChanged: Observable<boolean>;
  76510. /** @hidden */
  76511. _onDataLayoutChanged: Observable<void>;
  76512. /**
  76513. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  76514. */
  76515. influence: number;
  76516. /**
  76517. * Gets or sets the id of the morph Target
  76518. */
  76519. id: string;
  76520. private _animationPropertiesOverride;
  76521. /**
  76522. * Gets or sets the animation properties override
  76523. */
  76524. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  76525. /**
  76526. * Creates a new MorphTarget
  76527. * @param name defines the name of the target
  76528. * @param influence defines the influence to use
  76529. * @param scene defines the scene the morphtarget belongs to
  76530. */
  76531. constructor(
  76532. /** defines the name of the target */
  76533. name: string, influence?: number, scene?: Nullable<Scene>);
  76534. /**
  76535. * Gets a boolean defining if the target contains position data
  76536. */
  76537. readonly hasPositions: boolean;
  76538. /**
  76539. * Gets a boolean defining if the target contains normal data
  76540. */
  76541. readonly hasNormals: boolean;
  76542. /**
  76543. * Gets a boolean defining if the target contains tangent data
  76544. */
  76545. readonly hasTangents: boolean;
  76546. /**
  76547. * Affects position data to this target
  76548. * @param data defines the position data to use
  76549. */
  76550. setPositions(data: Nullable<FloatArray>): void;
  76551. /**
  76552. * Gets the position data stored in this target
  76553. * @returns a FloatArray containing the position data (or null if not present)
  76554. */
  76555. getPositions(): Nullable<FloatArray>;
  76556. /**
  76557. * Affects normal data to this target
  76558. * @param data defines the normal data to use
  76559. */
  76560. setNormals(data: Nullable<FloatArray>): void;
  76561. /**
  76562. * Gets the normal data stored in this target
  76563. * @returns a FloatArray containing the normal data (or null if not present)
  76564. */
  76565. getNormals(): Nullable<FloatArray>;
  76566. /**
  76567. * Affects tangent data to this target
  76568. * @param data defines the tangent data to use
  76569. */
  76570. setTangents(data: Nullable<FloatArray>): void;
  76571. /**
  76572. * Gets the tangent data stored in this target
  76573. * @returns a FloatArray containing the tangent data (or null if not present)
  76574. */
  76575. getTangents(): Nullable<FloatArray>;
  76576. /**
  76577. * Serializes the current target into a Serialization object
  76578. * @returns the serialized object
  76579. */
  76580. serialize(): any;
  76581. /**
  76582. * Returns the string "MorphTarget"
  76583. * @returns "MorphTarget"
  76584. */
  76585. getClassName(): string;
  76586. /**
  76587. * Creates a new target from serialized data
  76588. * @param serializationObject defines the serialized data to use
  76589. * @returns a new MorphTarget
  76590. */
  76591. static Parse(serializationObject: any): MorphTarget;
  76592. /**
  76593. * Creates a MorphTarget from mesh data
  76594. * @param mesh defines the source mesh
  76595. * @param name defines the name to use for the new target
  76596. * @param influence defines the influence to attach to the target
  76597. * @returns a new MorphTarget
  76598. */
  76599. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  76600. }
  76601. }
  76602. declare module BABYLON {
  76603. /**
  76604. * This class is used to deform meshes using morphing between different targets
  76605. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  76606. */
  76607. export class MorphTargetManager {
  76608. private _targets;
  76609. private _targetInfluenceChangedObservers;
  76610. private _targetDataLayoutChangedObservers;
  76611. private _activeTargets;
  76612. private _scene;
  76613. private _influences;
  76614. private _supportsNormals;
  76615. private _supportsTangents;
  76616. private _vertexCount;
  76617. private _uniqueId;
  76618. private _tempInfluences;
  76619. /**
  76620. * Creates a new MorphTargetManager
  76621. * @param scene defines the current scene
  76622. */
  76623. constructor(scene?: Nullable<Scene>);
  76624. /**
  76625. * Gets the unique ID of this manager
  76626. */
  76627. readonly uniqueId: number;
  76628. /**
  76629. * Gets the number of vertices handled by this manager
  76630. */
  76631. readonly vertexCount: number;
  76632. /**
  76633. * Gets a boolean indicating if this manager supports morphing of normals
  76634. */
  76635. readonly supportsNormals: boolean;
  76636. /**
  76637. * Gets a boolean indicating if this manager supports morphing of tangents
  76638. */
  76639. readonly supportsTangents: boolean;
  76640. /**
  76641. * Gets the number of targets stored in this manager
  76642. */
  76643. readonly numTargets: number;
  76644. /**
  76645. * Gets the number of influencers (ie. the number of targets with influences > 0)
  76646. */
  76647. readonly numInfluencers: number;
  76648. /**
  76649. * Gets the list of influences (one per target)
  76650. */
  76651. readonly influences: Float32Array;
  76652. /**
  76653. * Gets the active target at specified index. An active target is a target with an influence > 0
  76654. * @param index defines the index to check
  76655. * @returns the requested target
  76656. */
  76657. getActiveTarget(index: number): MorphTarget;
  76658. /**
  76659. * Gets the target at specified index
  76660. * @param index defines the index to check
  76661. * @returns the requested target
  76662. */
  76663. getTarget(index: number): MorphTarget;
  76664. /**
  76665. * Add a new target to this manager
  76666. * @param target defines the target to add
  76667. */
  76668. addTarget(target: MorphTarget): void;
  76669. /**
  76670. * Removes a target from the manager
  76671. * @param target defines the target to remove
  76672. */
  76673. removeTarget(target: MorphTarget): void;
  76674. /**
  76675. * Serializes the current manager into a Serialization object
  76676. * @returns the serialized object
  76677. */
  76678. serialize(): any;
  76679. private _syncActiveTargets;
  76680. /**
  76681. * Syncrhonize the targets with all the meshes using this morph target manager
  76682. */
  76683. synchronize(): void;
  76684. /**
  76685. * Creates a new MorphTargetManager from serialized data
  76686. * @param serializationObject defines the serialized data
  76687. * @param scene defines the hosting scene
  76688. * @returns the new MorphTargetManager
  76689. */
  76690. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  76691. }
  76692. }
  76693. declare module BABYLON {
  76694. /**
  76695. * Mesh representing the gorund
  76696. */
  76697. export class GroundMesh extends Mesh {
  76698. /** If octree should be generated */
  76699. generateOctree: boolean;
  76700. private _heightQuads;
  76701. /** @hidden */
  76702. _subdivisionsX: number;
  76703. /** @hidden */
  76704. _subdivisionsY: number;
  76705. /** @hidden */
  76706. _width: number;
  76707. /** @hidden */
  76708. _height: number;
  76709. /** @hidden */
  76710. _minX: number;
  76711. /** @hidden */
  76712. _maxX: number;
  76713. /** @hidden */
  76714. _minZ: number;
  76715. /** @hidden */
  76716. _maxZ: number;
  76717. constructor(name: string, scene: Scene);
  76718. /**
  76719. * "GroundMesh"
  76720. * @returns "GroundMesh"
  76721. */
  76722. getClassName(): string;
  76723. /**
  76724. * The minimum of x and y subdivisions
  76725. */
  76726. readonly subdivisions: number;
  76727. /**
  76728. * X subdivisions
  76729. */
  76730. readonly subdivisionsX: number;
  76731. /**
  76732. * Y subdivisions
  76733. */
  76734. readonly subdivisionsY: number;
  76735. /**
  76736. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  76737. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  76738. * @param chunksCount the number of subdivisions for x and y
  76739. * @param octreeBlocksSize (Default: 32)
  76740. */
  76741. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  76742. /**
  76743. * Returns a height (y) value in the Worl system :
  76744. * the ground altitude at the coordinates (x, z) expressed in the World system.
  76745. * @param x x coordinate
  76746. * @param z z coordinate
  76747. * @returns the ground y position if (x, z) are outside the ground surface.
  76748. */
  76749. getHeightAtCoordinates(x: number, z: number): number;
  76750. /**
  76751. * Returns a normalized vector (Vector3) orthogonal to the ground
  76752. * at the ground coordinates (x, z) expressed in the World system.
  76753. * @param x x coordinate
  76754. * @param z z coordinate
  76755. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  76756. */
  76757. getNormalAtCoordinates(x: number, z: number): Vector3;
  76758. /**
  76759. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  76760. * at the ground coordinates (x, z) expressed in the World system.
  76761. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  76762. * @param x x coordinate
  76763. * @param z z coordinate
  76764. * @param ref vector to store the result
  76765. * @returns the GroundMesh.
  76766. */
  76767. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  76768. /**
  76769. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  76770. * if the ground has been updated.
  76771. * This can be used in the render loop.
  76772. * @returns the GroundMesh.
  76773. */
  76774. updateCoordinateHeights(): GroundMesh;
  76775. private _getFacetAt;
  76776. private _initHeightQuads;
  76777. private _computeHeightQuads;
  76778. /**
  76779. * Serializes this ground mesh
  76780. * @param serializationObject object to write serialization to
  76781. */
  76782. serialize(serializationObject: any): void;
  76783. /**
  76784. * Parses a serialized ground mesh
  76785. * @param parsedMesh the serialized mesh
  76786. * @param scene the scene to create the ground mesh in
  76787. * @returns the created ground mesh
  76788. */
  76789. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  76790. }
  76791. }
  76792. declare module BABYLON {
  76793. /**
  76794. * Interface for Physics-Joint data
  76795. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76796. */
  76797. export interface PhysicsJointData {
  76798. /**
  76799. * The main pivot of the joint
  76800. */
  76801. mainPivot?: Vector3;
  76802. /**
  76803. * The connected pivot of the joint
  76804. */
  76805. connectedPivot?: Vector3;
  76806. /**
  76807. * The main axis of the joint
  76808. */
  76809. mainAxis?: Vector3;
  76810. /**
  76811. * The connected axis of the joint
  76812. */
  76813. connectedAxis?: Vector3;
  76814. /**
  76815. * The collision of the joint
  76816. */
  76817. collision?: boolean;
  76818. /**
  76819. * Native Oimo/Cannon/Energy data
  76820. */
  76821. nativeParams?: any;
  76822. }
  76823. /**
  76824. * This is a holder class for the physics joint created by the physics plugin
  76825. * It holds a set of functions to control the underlying joint
  76826. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76827. */
  76828. export class PhysicsJoint {
  76829. /**
  76830. * The type of the physics joint
  76831. */
  76832. type: number;
  76833. /**
  76834. * The data for the physics joint
  76835. */
  76836. jointData: PhysicsJointData;
  76837. private _physicsJoint;
  76838. protected _physicsPlugin: IPhysicsEnginePlugin;
  76839. /**
  76840. * Initializes the physics joint
  76841. * @param type The type of the physics joint
  76842. * @param jointData The data for the physics joint
  76843. */
  76844. constructor(
  76845. /**
  76846. * The type of the physics joint
  76847. */
  76848. type: number,
  76849. /**
  76850. * The data for the physics joint
  76851. */
  76852. jointData: PhysicsJointData);
  76853. /**
  76854. * Gets the physics joint
  76855. */
  76856. /**
  76857. * Sets the physics joint
  76858. */
  76859. physicsJoint: any;
  76860. /**
  76861. * Sets the physics plugin
  76862. */
  76863. physicsPlugin: IPhysicsEnginePlugin;
  76864. /**
  76865. * Execute a function that is physics-plugin specific.
  76866. * @param {Function} func the function that will be executed.
  76867. * It accepts two parameters: the physics world and the physics joint
  76868. */
  76869. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  76870. /**
  76871. * Distance-Joint type
  76872. */
  76873. static DistanceJoint: number;
  76874. /**
  76875. * Hinge-Joint type
  76876. */
  76877. static HingeJoint: number;
  76878. /**
  76879. * Ball-and-Socket joint type
  76880. */
  76881. static BallAndSocketJoint: number;
  76882. /**
  76883. * Wheel-Joint type
  76884. */
  76885. static WheelJoint: number;
  76886. /**
  76887. * Slider-Joint type
  76888. */
  76889. static SliderJoint: number;
  76890. /**
  76891. * Prismatic-Joint type
  76892. */
  76893. static PrismaticJoint: number;
  76894. /**
  76895. * Universal-Joint type
  76896. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  76897. */
  76898. static UniversalJoint: number;
  76899. /**
  76900. * Hinge-Joint 2 type
  76901. */
  76902. static Hinge2Joint: number;
  76903. /**
  76904. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  76905. */
  76906. static PointToPointJoint: number;
  76907. /**
  76908. * Spring-Joint type
  76909. */
  76910. static SpringJoint: number;
  76911. /**
  76912. * Lock-Joint type
  76913. */
  76914. static LockJoint: number;
  76915. }
  76916. /**
  76917. * A class representing a physics distance joint
  76918. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76919. */
  76920. export class DistanceJoint extends PhysicsJoint {
  76921. /**
  76922. *
  76923. * @param jointData The data for the Distance-Joint
  76924. */
  76925. constructor(jointData: DistanceJointData);
  76926. /**
  76927. * Update the predefined distance.
  76928. * @param maxDistance The maximum preferred distance
  76929. * @param minDistance The minimum preferred distance
  76930. */
  76931. updateDistance(maxDistance: number, minDistance?: number): void;
  76932. }
  76933. /**
  76934. * Represents a Motor-Enabled Joint
  76935. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76936. */
  76937. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  76938. /**
  76939. * Initializes the Motor-Enabled Joint
  76940. * @param type The type of the joint
  76941. * @param jointData The physica joint data for the joint
  76942. */
  76943. constructor(type: number, jointData: PhysicsJointData);
  76944. /**
  76945. * Set the motor values.
  76946. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76947. * @param force the force to apply
  76948. * @param maxForce max force for this motor.
  76949. */
  76950. setMotor(force?: number, maxForce?: number): void;
  76951. /**
  76952. * Set the motor's limits.
  76953. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76954. * @param upperLimit The upper limit of the motor
  76955. * @param lowerLimit The lower limit of the motor
  76956. */
  76957. setLimit(upperLimit: number, lowerLimit?: number): void;
  76958. }
  76959. /**
  76960. * This class represents a single physics Hinge-Joint
  76961. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76962. */
  76963. export class HingeJoint extends MotorEnabledJoint {
  76964. /**
  76965. * Initializes the Hinge-Joint
  76966. * @param jointData The joint data for the Hinge-Joint
  76967. */
  76968. constructor(jointData: PhysicsJointData);
  76969. /**
  76970. * Set the motor values.
  76971. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76972. * @param {number} force the force to apply
  76973. * @param {number} maxForce max force for this motor.
  76974. */
  76975. setMotor(force?: number, maxForce?: number): void;
  76976. /**
  76977. * Set the motor's limits.
  76978. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76979. * @param upperLimit The upper limit of the motor
  76980. * @param lowerLimit The lower limit of the motor
  76981. */
  76982. setLimit(upperLimit: number, lowerLimit?: number): void;
  76983. }
  76984. /**
  76985. * This class represents a dual hinge physics joint (same as wheel joint)
  76986. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76987. */
  76988. export class Hinge2Joint extends MotorEnabledJoint {
  76989. /**
  76990. * Initializes the Hinge2-Joint
  76991. * @param jointData The joint data for the Hinge2-Joint
  76992. */
  76993. constructor(jointData: PhysicsJointData);
  76994. /**
  76995. * Set the motor values.
  76996. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76997. * @param {number} targetSpeed the speed the motor is to reach
  76998. * @param {number} maxForce max force for this motor.
  76999. * @param {motorIndex} the motor's index, 0 or 1.
  77000. */
  77001. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  77002. /**
  77003. * Set the motor limits.
  77004. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77005. * @param {number} upperLimit the upper limit
  77006. * @param {number} lowerLimit lower limit
  77007. * @param {motorIndex} the motor's index, 0 or 1.
  77008. */
  77009. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  77010. }
  77011. /**
  77012. * Interface for a motor enabled joint
  77013. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77014. */
  77015. export interface IMotorEnabledJoint {
  77016. /**
  77017. * Physics joint
  77018. */
  77019. physicsJoint: any;
  77020. /**
  77021. * Sets the motor of the motor-enabled joint
  77022. * @param force The force of the motor
  77023. * @param maxForce The maximum force of the motor
  77024. * @param motorIndex The index of the motor
  77025. */
  77026. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  77027. /**
  77028. * Sets the limit of the motor
  77029. * @param upperLimit The upper limit of the motor
  77030. * @param lowerLimit The lower limit of the motor
  77031. * @param motorIndex The index of the motor
  77032. */
  77033. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  77034. }
  77035. /**
  77036. * Joint data for a Distance-Joint
  77037. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77038. */
  77039. export interface DistanceJointData extends PhysicsJointData {
  77040. /**
  77041. * Max distance the 2 joint objects can be apart
  77042. */
  77043. maxDistance: number;
  77044. }
  77045. /**
  77046. * Joint data from a spring joint
  77047. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77048. */
  77049. export interface SpringJointData extends PhysicsJointData {
  77050. /**
  77051. * Length of the spring
  77052. */
  77053. length: number;
  77054. /**
  77055. * Stiffness of the spring
  77056. */
  77057. stiffness: number;
  77058. /**
  77059. * Damping of the spring
  77060. */
  77061. damping: number;
  77062. /** this callback will be called when applying the force to the impostors. */
  77063. forceApplicationCallback: () => void;
  77064. }
  77065. }
  77066. declare module BABYLON {
  77067. /**
  77068. * Interface used to describe a physics joint
  77069. */
  77070. export interface PhysicsImpostorJoint {
  77071. /** Defines the main impostor to which the joint is linked */
  77072. mainImpostor: PhysicsImpostor;
  77073. /** Defines the impostor that is connected to the main impostor using this joint */
  77074. connectedImpostor: PhysicsImpostor;
  77075. /** Defines the joint itself */
  77076. joint: PhysicsJoint;
  77077. }
  77078. /** @hidden */
  77079. export interface IPhysicsEnginePlugin {
  77080. world: any;
  77081. name: string;
  77082. setGravity(gravity: Vector3): void;
  77083. setTimeStep(timeStep: number): void;
  77084. getTimeStep(): number;
  77085. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  77086. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  77087. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  77088. generatePhysicsBody(impostor: PhysicsImpostor): void;
  77089. removePhysicsBody(impostor: PhysicsImpostor): void;
  77090. generateJoint(joint: PhysicsImpostorJoint): void;
  77091. removeJoint(joint: PhysicsImpostorJoint): void;
  77092. isSupported(): boolean;
  77093. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  77094. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  77095. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  77096. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  77097. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  77098. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  77099. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  77100. getBodyMass(impostor: PhysicsImpostor): number;
  77101. getBodyFriction(impostor: PhysicsImpostor): number;
  77102. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  77103. getBodyRestitution(impostor: PhysicsImpostor): number;
  77104. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  77105. sleepBody(impostor: PhysicsImpostor): void;
  77106. wakeUpBody(impostor: PhysicsImpostor): void;
  77107. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  77108. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  77109. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  77110. getRadius(impostor: PhysicsImpostor): number;
  77111. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  77112. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  77113. dispose(): void;
  77114. }
  77115. /**
  77116. * Interface used to define a physics engine
  77117. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  77118. */
  77119. export interface IPhysicsEngine {
  77120. /**
  77121. * Gets the gravity vector used by the simulation
  77122. */
  77123. gravity: Vector3;
  77124. /**
  77125. * Sets the gravity vector used by the simulation
  77126. * @param gravity defines the gravity vector to use
  77127. */
  77128. setGravity(gravity: Vector3): void;
  77129. /**
  77130. * Set the time step of the physics engine.
  77131. * Default is 1/60.
  77132. * To slow it down, enter 1/600 for example.
  77133. * To speed it up, 1/30
  77134. * @param newTimeStep the new timestep to apply to this world.
  77135. */
  77136. setTimeStep(newTimeStep: number): void;
  77137. /**
  77138. * Get the time step of the physics engine.
  77139. * @returns the current time step
  77140. */
  77141. getTimeStep(): number;
  77142. /**
  77143. * Release all resources
  77144. */
  77145. dispose(): void;
  77146. /**
  77147. * Gets the name of the current physics plugin
  77148. * @returns the name of the plugin
  77149. */
  77150. getPhysicsPluginName(): string;
  77151. /**
  77152. * Adding a new impostor for the impostor tracking.
  77153. * This will be done by the impostor itself.
  77154. * @param impostor the impostor to add
  77155. */
  77156. addImpostor(impostor: PhysicsImpostor): void;
  77157. /**
  77158. * Remove an impostor from the engine.
  77159. * This impostor and its mesh will not longer be updated by the physics engine.
  77160. * @param impostor the impostor to remove
  77161. */
  77162. removeImpostor(impostor: PhysicsImpostor): void;
  77163. /**
  77164. * Add a joint to the physics engine
  77165. * @param mainImpostor defines the main impostor to which the joint is added.
  77166. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  77167. * @param joint defines the joint that will connect both impostors.
  77168. */
  77169. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  77170. /**
  77171. * Removes a joint from the simulation
  77172. * @param mainImpostor defines the impostor used with the joint
  77173. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  77174. * @param joint defines the joint to remove
  77175. */
  77176. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  77177. /**
  77178. * Gets the current plugin used to run the simulation
  77179. * @returns current plugin
  77180. */
  77181. getPhysicsPlugin(): IPhysicsEnginePlugin;
  77182. /**
  77183. * Gets the list of physic impostors
  77184. * @returns an array of PhysicsImpostor
  77185. */
  77186. getImpostors(): Array<PhysicsImpostor>;
  77187. /**
  77188. * Gets the impostor for a physics enabled object
  77189. * @param object defines the object impersonated by the impostor
  77190. * @returns the PhysicsImpostor or null if not found
  77191. */
  77192. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  77193. /**
  77194. * Gets the impostor for a physics body object
  77195. * @param body defines physics body used by the impostor
  77196. * @returns the PhysicsImpostor or null if not found
  77197. */
  77198. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  77199. /**
  77200. * Called by the scene. No need to call it.
  77201. * @param delta defines the timespam between frames
  77202. */
  77203. _step(delta: number): void;
  77204. }
  77205. }
  77206. declare module BABYLON {
  77207. /**
  77208. * The interface for the physics imposter parameters
  77209. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77210. */
  77211. export interface PhysicsImpostorParameters {
  77212. /**
  77213. * The mass of the physics imposter
  77214. */
  77215. mass: number;
  77216. /**
  77217. * The friction of the physics imposter
  77218. */
  77219. friction?: number;
  77220. /**
  77221. * The coefficient of restitution of the physics imposter
  77222. */
  77223. restitution?: number;
  77224. /**
  77225. * The native options of the physics imposter
  77226. */
  77227. nativeOptions?: any;
  77228. /**
  77229. * Specifies if the parent should be ignored
  77230. */
  77231. ignoreParent?: boolean;
  77232. /**
  77233. * Specifies if bi-directional transformations should be disabled
  77234. */
  77235. disableBidirectionalTransformation?: boolean;
  77236. }
  77237. /**
  77238. * Interface for a physics-enabled object
  77239. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77240. */
  77241. export interface IPhysicsEnabledObject {
  77242. /**
  77243. * The position of the physics-enabled object
  77244. */
  77245. position: Vector3;
  77246. /**
  77247. * The rotation of the physics-enabled object
  77248. */
  77249. rotationQuaternion: Nullable<Quaternion>;
  77250. /**
  77251. * The scale of the physics-enabled object
  77252. */
  77253. scaling: Vector3;
  77254. /**
  77255. * The rotation of the physics-enabled object
  77256. */
  77257. rotation?: Vector3;
  77258. /**
  77259. * The parent of the physics-enabled object
  77260. */
  77261. parent?: any;
  77262. /**
  77263. * The bounding info of the physics-enabled object
  77264. * @returns The bounding info of the physics-enabled object
  77265. */
  77266. getBoundingInfo(): BoundingInfo;
  77267. /**
  77268. * Computes the world matrix
  77269. * @param force Specifies if the world matrix should be computed by force
  77270. * @returns A world matrix
  77271. */
  77272. computeWorldMatrix(force: boolean): Matrix;
  77273. /**
  77274. * Gets the world matrix
  77275. * @returns A world matrix
  77276. */
  77277. getWorldMatrix?(): Matrix;
  77278. /**
  77279. * Gets the child meshes
  77280. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  77281. * @returns An array of abstract meshes
  77282. */
  77283. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  77284. /**
  77285. * Gets the vertex data
  77286. * @param kind The type of vertex data
  77287. * @returns A nullable array of numbers, or a float32 array
  77288. */
  77289. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  77290. /**
  77291. * Gets the indices from the mesh
  77292. * @returns A nullable array of index arrays
  77293. */
  77294. getIndices?(): Nullable<IndicesArray>;
  77295. /**
  77296. * Gets the scene from the mesh
  77297. * @returns the indices array or null
  77298. */
  77299. getScene?(): Scene;
  77300. /**
  77301. * Gets the absolute position from the mesh
  77302. * @returns the absolute position
  77303. */
  77304. getAbsolutePosition(): Vector3;
  77305. /**
  77306. * Gets the absolute pivot point from the mesh
  77307. * @returns the absolute pivot point
  77308. */
  77309. getAbsolutePivotPoint(): Vector3;
  77310. /**
  77311. * Rotates the mesh
  77312. * @param axis The axis of rotation
  77313. * @param amount The amount of rotation
  77314. * @param space The space of the rotation
  77315. * @returns The rotation transform node
  77316. */
  77317. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  77318. /**
  77319. * Translates the mesh
  77320. * @param axis The axis of translation
  77321. * @param distance The distance of translation
  77322. * @param space The space of the translation
  77323. * @returns The transform node
  77324. */
  77325. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  77326. /**
  77327. * Sets the absolute position of the mesh
  77328. * @param absolutePosition The absolute position of the mesh
  77329. * @returns The transform node
  77330. */
  77331. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  77332. /**
  77333. * Gets the class name of the mesh
  77334. * @returns The class name
  77335. */
  77336. getClassName(): string;
  77337. }
  77338. /**
  77339. * Represents a physics imposter
  77340. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77341. */
  77342. export class PhysicsImpostor {
  77343. /**
  77344. * The physics-enabled object used as the physics imposter
  77345. */
  77346. object: IPhysicsEnabledObject;
  77347. /**
  77348. * The type of the physics imposter
  77349. */
  77350. type: number;
  77351. private _options;
  77352. private _scene?;
  77353. /**
  77354. * The default object size of the imposter
  77355. */
  77356. static DEFAULT_OBJECT_SIZE: Vector3;
  77357. /**
  77358. * The identity quaternion of the imposter
  77359. */
  77360. static IDENTITY_QUATERNION: Quaternion;
  77361. /** @hidden */
  77362. _pluginData: any;
  77363. private _physicsEngine;
  77364. private _physicsBody;
  77365. private _bodyUpdateRequired;
  77366. private _onBeforePhysicsStepCallbacks;
  77367. private _onAfterPhysicsStepCallbacks;
  77368. /** @hidden */
  77369. _onPhysicsCollideCallbacks: Array<{
  77370. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  77371. otherImpostors: Array<PhysicsImpostor>;
  77372. }>;
  77373. private _deltaPosition;
  77374. private _deltaRotation;
  77375. private _deltaRotationConjugated;
  77376. private _parent;
  77377. private _isDisposed;
  77378. private static _tmpVecs;
  77379. private static _tmpQuat;
  77380. /**
  77381. * Specifies if the physics imposter is disposed
  77382. */
  77383. readonly isDisposed: boolean;
  77384. /**
  77385. * Gets the mass of the physics imposter
  77386. */
  77387. mass: number;
  77388. /**
  77389. * Gets the coefficient of friction
  77390. */
  77391. /**
  77392. * Sets the coefficient of friction
  77393. */
  77394. friction: number;
  77395. /**
  77396. * Gets the coefficient of restitution
  77397. */
  77398. /**
  77399. * Sets the coefficient of restitution
  77400. */
  77401. restitution: number;
  77402. /**
  77403. * The unique id of the physics imposter
  77404. * set by the physics engine when adding this impostor to the array
  77405. */
  77406. uniqueId: number;
  77407. private _joints;
  77408. /**
  77409. * Initializes the physics imposter
  77410. * @param object The physics-enabled object used as the physics imposter
  77411. * @param type The type of the physics imposter
  77412. * @param _options The options for the physics imposter
  77413. * @param _scene The Babylon scene
  77414. */
  77415. constructor(
  77416. /**
  77417. * The physics-enabled object used as the physics imposter
  77418. */
  77419. object: IPhysicsEnabledObject,
  77420. /**
  77421. * The type of the physics imposter
  77422. */
  77423. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  77424. /**
  77425. * This function will completly initialize this impostor.
  77426. * It will create a new body - but only if this mesh has no parent.
  77427. * If it has, this impostor will not be used other than to define the impostor
  77428. * of the child mesh.
  77429. * @hidden
  77430. */
  77431. _init(): void;
  77432. private _getPhysicsParent;
  77433. /**
  77434. * Should a new body be generated.
  77435. * @returns boolean specifying if body initialization is required
  77436. */
  77437. isBodyInitRequired(): boolean;
  77438. /**
  77439. * Sets the updated scaling
  77440. * @param updated Specifies if the scaling is updated
  77441. */
  77442. setScalingUpdated(): void;
  77443. /**
  77444. * Force a regeneration of this or the parent's impostor's body.
  77445. * Use under cautious - This will remove all joints already implemented.
  77446. */
  77447. forceUpdate(): void;
  77448. /**
  77449. * Gets the body that holds this impostor. Either its own, or its parent.
  77450. */
  77451. /**
  77452. * Set the physics body. Used mainly by the physics engine/plugin
  77453. */
  77454. physicsBody: any;
  77455. /**
  77456. * Get the parent of the physics imposter
  77457. * @returns Physics imposter or null
  77458. */
  77459. /**
  77460. * Sets the parent of the physics imposter
  77461. */
  77462. parent: Nullable<PhysicsImpostor>;
  77463. /**
  77464. * Resets the update flags
  77465. */
  77466. resetUpdateFlags(): void;
  77467. /**
  77468. * Gets the object extend size
  77469. * @returns the object extend size
  77470. */
  77471. getObjectExtendSize(): Vector3;
  77472. /**
  77473. * Gets the object center
  77474. * @returns The object center
  77475. */
  77476. getObjectCenter(): Vector3;
  77477. /**
  77478. * Get a specific parametes from the options parameter
  77479. * @param paramName The object parameter name
  77480. * @returns The object parameter
  77481. */
  77482. getParam(paramName: string): any;
  77483. /**
  77484. * Sets a specific parameter in the options given to the physics plugin
  77485. * @param paramName The parameter name
  77486. * @param value The value of the parameter
  77487. */
  77488. setParam(paramName: string, value: number): void;
  77489. /**
  77490. * Specifically change the body's mass option. Won't recreate the physics body object
  77491. * @param mass The mass of the physics imposter
  77492. */
  77493. setMass(mass: number): void;
  77494. /**
  77495. * Gets the linear velocity
  77496. * @returns linear velocity or null
  77497. */
  77498. getLinearVelocity(): Nullable<Vector3>;
  77499. /**
  77500. * Sets the linear velocity
  77501. * @param velocity linear velocity or null
  77502. */
  77503. setLinearVelocity(velocity: Nullable<Vector3>): void;
  77504. /**
  77505. * Gets the angular velocity
  77506. * @returns angular velocity or null
  77507. */
  77508. getAngularVelocity(): Nullable<Vector3>;
  77509. /**
  77510. * Sets the angular velocity
  77511. * @param velocity The velocity or null
  77512. */
  77513. setAngularVelocity(velocity: Nullable<Vector3>): void;
  77514. /**
  77515. * Execute a function with the physics plugin native code
  77516. * Provide a function the will have two variables - the world object and the physics body object
  77517. * @param func The function to execute with the physics plugin native code
  77518. */
  77519. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  77520. /**
  77521. * Register a function that will be executed before the physics world is stepping forward
  77522. * @param func The function to execute before the physics world is stepped forward
  77523. */
  77524. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77525. /**
  77526. * Unregister a function that will be executed before the physics world is stepping forward
  77527. * @param func The function to execute before the physics world is stepped forward
  77528. */
  77529. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77530. /**
  77531. * Register a function that will be executed after the physics step
  77532. * @param func The function to execute after physics step
  77533. */
  77534. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77535. /**
  77536. * Unregisters a function that will be executed after the physics step
  77537. * @param func The function to execute after physics step
  77538. */
  77539. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77540. /**
  77541. * register a function that will be executed when this impostor collides against a different body
  77542. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  77543. * @param func Callback that is executed on collision
  77544. */
  77545. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  77546. /**
  77547. * Unregisters the physics imposter on contact
  77548. * @param collideAgainst The physics object to collide against
  77549. * @param func Callback to execute on collision
  77550. */
  77551. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  77552. private _tmpQuat;
  77553. private _tmpQuat2;
  77554. /**
  77555. * Get the parent rotation
  77556. * @returns The parent rotation
  77557. */
  77558. getParentsRotation(): Quaternion;
  77559. /**
  77560. * this function is executed by the physics engine.
  77561. */
  77562. beforeStep: () => void;
  77563. /**
  77564. * this function is executed by the physics engine
  77565. */
  77566. afterStep: () => void;
  77567. /**
  77568. * Legacy collision detection event support
  77569. */
  77570. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  77571. /**
  77572. * event and body object due to cannon's event-based architecture.
  77573. */
  77574. onCollide: (e: {
  77575. body: any;
  77576. }) => void;
  77577. /**
  77578. * Apply a force
  77579. * @param force The force to apply
  77580. * @param contactPoint The contact point for the force
  77581. * @returns The physics imposter
  77582. */
  77583. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  77584. /**
  77585. * Apply an impulse
  77586. * @param force The impulse force
  77587. * @param contactPoint The contact point for the impulse force
  77588. * @returns The physics imposter
  77589. */
  77590. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  77591. /**
  77592. * A help function to create a joint
  77593. * @param otherImpostor A physics imposter used to create a joint
  77594. * @param jointType The type of joint
  77595. * @param jointData The data for the joint
  77596. * @returns The physics imposter
  77597. */
  77598. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  77599. /**
  77600. * Add a joint to this impostor with a different impostor
  77601. * @param otherImpostor A physics imposter used to add a joint
  77602. * @param joint The joint to add
  77603. * @returns The physics imposter
  77604. */
  77605. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  77606. /**
  77607. * Will keep this body still, in a sleep mode.
  77608. * @returns the physics imposter
  77609. */
  77610. sleep(): PhysicsImpostor;
  77611. /**
  77612. * Wake the body up.
  77613. * @returns The physics imposter
  77614. */
  77615. wakeUp(): PhysicsImpostor;
  77616. /**
  77617. * Clones the physics imposter
  77618. * @param newObject The physics imposter clones to this physics-enabled object
  77619. * @returns A nullable physics imposter
  77620. */
  77621. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  77622. /**
  77623. * Disposes the physics imposter
  77624. */
  77625. dispose(): void;
  77626. /**
  77627. * Sets the delta position
  77628. * @param position The delta position amount
  77629. */
  77630. setDeltaPosition(position: Vector3): void;
  77631. /**
  77632. * Sets the delta rotation
  77633. * @param rotation The delta rotation amount
  77634. */
  77635. setDeltaRotation(rotation: Quaternion): void;
  77636. /**
  77637. * Gets the box size of the physics imposter and stores the result in the input parameter
  77638. * @param result Stores the box size
  77639. * @returns The physics imposter
  77640. */
  77641. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  77642. /**
  77643. * Gets the radius of the physics imposter
  77644. * @returns Radius of the physics imposter
  77645. */
  77646. getRadius(): number;
  77647. /**
  77648. * Sync a bone with this impostor
  77649. * @param bone The bone to sync to the impostor.
  77650. * @param boneMesh The mesh that the bone is influencing.
  77651. * @param jointPivot The pivot of the joint / bone in local space.
  77652. * @param distToJoint Optional distance from the impostor to the joint.
  77653. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  77654. */
  77655. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  77656. /**
  77657. * Sync impostor to a bone
  77658. * @param bone The bone that the impostor will be synced to.
  77659. * @param boneMesh The mesh that the bone is influencing.
  77660. * @param jointPivot The pivot of the joint / bone in local space.
  77661. * @param distToJoint Optional distance from the impostor to the joint.
  77662. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  77663. * @param boneAxis Optional vector3 axis the bone is aligned with
  77664. */
  77665. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  77666. /**
  77667. * No-Imposter type
  77668. */
  77669. static NoImpostor: number;
  77670. /**
  77671. * Sphere-Imposter type
  77672. */
  77673. static SphereImpostor: number;
  77674. /**
  77675. * Box-Imposter type
  77676. */
  77677. static BoxImpostor: number;
  77678. /**
  77679. * Plane-Imposter type
  77680. */
  77681. static PlaneImpostor: number;
  77682. /**
  77683. * Mesh-imposter type
  77684. */
  77685. static MeshImpostor: number;
  77686. /**
  77687. * Cylinder-Imposter type
  77688. */
  77689. static CylinderImpostor: number;
  77690. /**
  77691. * Particle-Imposter type
  77692. */
  77693. static ParticleImpostor: number;
  77694. /**
  77695. * Heightmap-Imposter type
  77696. */
  77697. static HeightmapImpostor: number;
  77698. }
  77699. }
  77700. declare module BABYLON {
  77701. /**
  77702. * Class used to represent a specific level of detail of a mesh
  77703. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  77704. */
  77705. export class MeshLODLevel {
  77706. /** Defines the distance where this level should star being displayed */
  77707. distance: number;
  77708. /** Defines the mesh to use to render this level */
  77709. mesh: Nullable<Mesh>;
  77710. /**
  77711. * Creates a new LOD level
  77712. * @param distance defines the distance where this level should star being displayed
  77713. * @param mesh defines the mesh to use to render this level
  77714. */
  77715. constructor(
  77716. /** Defines the distance where this level should star being displayed */
  77717. distance: number,
  77718. /** Defines the mesh to use to render this level */
  77719. mesh: Nullable<Mesh>);
  77720. }
  77721. /**
  77722. * @hidden
  77723. **/
  77724. export class _CreationDataStorage {
  77725. closePath?: boolean;
  77726. closeArray?: boolean;
  77727. idx: number[];
  77728. dashSize: number;
  77729. gapSize: number;
  77730. path3D: Path3D;
  77731. pathArray: Vector3[][];
  77732. arc: number;
  77733. radius: number;
  77734. cap: number;
  77735. tessellation: number;
  77736. }
  77737. /**
  77738. * @hidden
  77739. **/
  77740. class _InstanceDataStorage {
  77741. visibleInstances: any;
  77742. renderIdForInstances: number[];
  77743. batchCache: _InstancesBatch;
  77744. instancesBufferSize: number;
  77745. instancesBuffer: Nullable<Buffer>;
  77746. instancesData: Float32Array;
  77747. overridenInstanceCount: number;
  77748. }
  77749. /**
  77750. * @hidden
  77751. **/
  77752. export class _InstancesBatch {
  77753. mustReturn: boolean;
  77754. visibleInstances: Nullable<InstancedMesh[]>[];
  77755. renderSelf: boolean[];
  77756. }
  77757. /**
  77758. * Class used to represent renderable models
  77759. */
  77760. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  77761. /**
  77762. * Mesh side orientation : usually the external or front surface
  77763. */
  77764. static readonly FRONTSIDE: number;
  77765. /**
  77766. * Mesh side orientation : usually the internal or back surface
  77767. */
  77768. static readonly BACKSIDE: number;
  77769. /**
  77770. * Mesh side orientation : both internal and external or front and back surfaces
  77771. */
  77772. static readonly DOUBLESIDE: number;
  77773. /**
  77774. * Mesh side orientation : by default, `FRONTSIDE`
  77775. */
  77776. static readonly DEFAULTSIDE: number;
  77777. /**
  77778. * Mesh cap setting : no cap
  77779. */
  77780. static readonly NO_CAP: number;
  77781. /**
  77782. * Mesh cap setting : one cap at the beginning of the mesh
  77783. */
  77784. static readonly CAP_START: number;
  77785. /**
  77786. * Mesh cap setting : one cap at the end of the mesh
  77787. */
  77788. static readonly CAP_END: number;
  77789. /**
  77790. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  77791. */
  77792. static readonly CAP_ALL: number;
  77793. /**
  77794. * Gets the default side orientation.
  77795. * @param orientation the orientation to value to attempt to get
  77796. * @returns the default orientation
  77797. * @hidden
  77798. */
  77799. static _GetDefaultSideOrientation(orientation?: number): number;
  77800. private _onBeforeRenderObservable;
  77801. private _onBeforeBindObservable;
  77802. private _onAfterRenderObservable;
  77803. private _onBeforeDrawObservable;
  77804. /**
  77805. * An event triggered before rendering the mesh
  77806. */
  77807. readonly onBeforeRenderObservable: Observable<Mesh>;
  77808. /**
  77809. * An event triggered before binding the mesh
  77810. */
  77811. readonly onBeforeBindObservable: Observable<Mesh>;
  77812. /**
  77813. * An event triggered after rendering the mesh
  77814. */
  77815. readonly onAfterRenderObservable: Observable<Mesh>;
  77816. /**
  77817. * An event triggered before drawing the mesh
  77818. */
  77819. readonly onBeforeDrawObservable: Observable<Mesh>;
  77820. private _onBeforeDrawObserver;
  77821. /**
  77822. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  77823. */
  77824. onBeforeDraw: () => void;
  77825. /**
  77826. * Gets the delay loading state of the mesh (when delay loading is turned on)
  77827. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  77828. */
  77829. delayLoadState: number;
  77830. /**
  77831. * Gets the list of instances created from this mesh
  77832. * it is not supposed to be modified manually.
  77833. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  77834. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77835. */
  77836. instances: InstancedMesh[];
  77837. /**
  77838. * Gets the file containing delay loading data for this mesh
  77839. */
  77840. delayLoadingFile: string;
  77841. /** @hidden */
  77842. _binaryInfo: any;
  77843. private _LODLevels;
  77844. /**
  77845. * User defined function used to change how LOD level selection is done
  77846. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  77847. */
  77848. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  77849. private _morphTargetManager;
  77850. /**
  77851. * Gets or sets the morph target manager
  77852. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  77853. */
  77854. morphTargetManager: Nullable<MorphTargetManager>;
  77855. /** @hidden */
  77856. _creationDataStorage: Nullable<_CreationDataStorage>;
  77857. /** @hidden */
  77858. _geometry: Nullable<Geometry>;
  77859. /** @hidden */
  77860. _delayInfo: Array<string>;
  77861. /** @hidden */
  77862. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  77863. /** @hidden */
  77864. _instanceDataStorage: _InstanceDataStorage;
  77865. private _effectiveMaterial;
  77866. /** @hidden */
  77867. _shouldGenerateFlatShading: boolean;
  77868. private _preActivateId;
  77869. /** @hidden */
  77870. _originalBuilderSideOrientation: number;
  77871. /**
  77872. * Use this property to change the original side orientation defined at construction time
  77873. */
  77874. overrideMaterialSideOrientation: Nullable<number>;
  77875. private _areNormalsFrozen;
  77876. private _sourcePositions;
  77877. private _sourceNormals;
  77878. private _source;
  77879. private meshMap;
  77880. /**
  77881. * Gets the source mesh (the one used to clone this one from)
  77882. */
  77883. readonly source: Nullable<Mesh>;
  77884. /**
  77885. * Gets or sets a boolean indicating that this mesh does not use index buffer
  77886. */
  77887. isUnIndexed: boolean;
  77888. /**
  77889. * @constructor
  77890. * @param name The value used by scene.getMeshByName() to do a lookup.
  77891. * @param scene The scene to add this mesh to.
  77892. * @param parent The parent of this mesh, if it has one
  77893. * @param source An optional Mesh from which geometry is shared, cloned.
  77894. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  77895. * When false, achieved by calling a clone(), also passing False.
  77896. * This will make creation of children, recursive.
  77897. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  77898. */
  77899. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  77900. /**
  77901. * Gets the class name
  77902. * @returns the string "Mesh".
  77903. */
  77904. getClassName(): string;
  77905. /** @hidden */
  77906. readonly _isMesh: boolean;
  77907. /**
  77908. * Returns a description of this mesh
  77909. * @param fullDetails define if full details about this mesh must be used
  77910. * @returns a descriptive string representing this mesh
  77911. */
  77912. toString(fullDetails?: boolean): string;
  77913. /** @hidden */
  77914. _unBindEffect(): void;
  77915. /**
  77916. * Gets a boolean indicating if this mesh has LOD
  77917. */
  77918. readonly hasLODLevels: boolean;
  77919. /**
  77920. * Gets the list of MeshLODLevel associated with the current mesh
  77921. * @returns an array of MeshLODLevel
  77922. */
  77923. getLODLevels(): MeshLODLevel[];
  77924. private _sortLODLevels;
  77925. /**
  77926. * Add a mesh as LOD level triggered at the given distance.
  77927. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77928. * @param distance The distance from the center of the object to show this level
  77929. * @param mesh The mesh to be added as LOD level (can be null)
  77930. * @return This mesh (for chaining)
  77931. */
  77932. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  77933. /**
  77934. * Returns the LOD level mesh at the passed distance or null if not found.
  77935. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77936. * @param distance The distance from the center of the object to show this level
  77937. * @returns a Mesh or `null`
  77938. */
  77939. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  77940. /**
  77941. * Remove a mesh from the LOD array
  77942. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77943. * @param mesh defines the mesh to be removed
  77944. * @return This mesh (for chaining)
  77945. */
  77946. removeLODLevel(mesh: Mesh): Mesh;
  77947. /**
  77948. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  77949. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77950. * @param camera defines the camera to use to compute distance
  77951. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  77952. * @return This mesh (for chaining)
  77953. */
  77954. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  77955. /**
  77956. * Gets the mesh internal Geometry object
  77957. */
  77958. readonly geometry: Nullable<Geometry>;
  77959. /**
  77960. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  77961. * @returns the total number of vertices
  77962. */
  77963. getTotalVertices(): number;
  77964. /**
  77965. * Returns the content of an associated vertex buffer
  77966. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77967. * - VertexBuffer.PositionKind
  77968. * - VertexBuffer.UVKind
  77969. * - VertexBuffer.UV2Kind
  77970. * - VertexBuffer.UV3Kind
  77971. * - VertexBuffer.UV4Kind
  77972. * - VertexBuffer.UV5Kind
  77973. * - VertexBuffer.UV6Kind
  77974. * - VertexBuffer.ColorKind
  77975. * - VertexBuffer.MatricesIndicesKind
  77976. * - VertexBuffer.MatricesIndicesExtraKind
  77977. * - VertexBuffer.MatricesWeightsKind
  77978. * - VertexBuffer.MatricesWeightsExtraKind
  77979. * @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
  77980. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  77981. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  77982. */
  77983. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  77984. /**
  77985. * Returns the mesh VertexBuffer object from the requested `kind`
  77986. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77987. * - VertexBuffer.PositionKind
  77988. * - VertexBuffer.UVKind
  77989. * - VertexBuffer.UV2Kind
  77990. * - VertexBuffer.UV3Kind
  77991. * - VertexBuffer.UV4Kind
  77992. * - VertexBuffer.UV5Kind
  77993. * - VertexBuffer.UV6Kind
  77994. * - VertexBuffer.ColorKind
  77995. * - VertexBuffer.MatricesIndicesKind
  77996. * - VertexBuffer.MatricesIndicesExtraKind
  77997. * - VertexBuffer.MatricesWeightsKind
  77998. * - VertexBuffer.MatricesWeightsExtraKind
  77999. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  78000. */
  78001. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  78002. /**
  78003. * Tests if a specific vertex buffer is associated with this mesh
  78004. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  78005. * - VertexBuffer.PositionKind
  78006. * - VertexBuffer.UVKind
  78007. * - VertexBuffer.UV2Kind
  78008. * - VertexBuffer.UV3Kind
  78009. * - VertexBuffer.UV4Kind
  78010. * - VertexBuffer.UV5Kind
  78011. * - VertexBuffer.UV6Kind
  78012. * - VertexBuffer.ColorKind
  78013. * - VertexBuffer.MatricesIndicesKind
  78014. * - VertexBuffer.MatricesIndicesExtraKind
  78015. * - VertexBuffer.MatricesWeightsKind
  78016. * - VertexBuffer.MatricesWeightsExtraKind
  78017. * @returns a boolean
  78018. */
  78019. isVerticesDataPresent(kind: string): boolean;
  78020. /**
  78021. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  78022. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  78023. * - VertexBuffer.PositionKind
  78024. * - VertexBuffer.UVKind
  78025. * - VertexBuffer.UV2Kind
  78026. * - VertexBuffer.UV3Kind
  78027. * - VertexBuffer.UV4Kind
  78028. * - VertexBuffer.UV5Kind
  78029. * - VertexBuffer.UV6Kind
  78030. * - VertexBuffer.ColorKind
  78031. * - VertexBuffer.MatricesIndicesKind
  78032. * - VertexBuffer.MatricesIndicesExtraKind
  78033. * - VertexBuffer.MatricesWeightsKind
  78034. * - VertexBuffer.MatricesWeightsExtraKind
  78035. * @returns a boolean
  78036. */
  78037. isVertexBufferUpdatable(kind: string): boolean;
  78038. /**
  78039. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  78040. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  78041. * - VertexBuffer.PositionKind
  78042. * - VertexBuffer.UVKind
  78043. * - VertexBuffer.UV2Kind
  78044. * - VertexBuffer.UV3Kind
  78045. * - VertexBuffer.UV4Kind
  78046. * - VertexBuffer.UV5Kind
  78047. * - VertexBuffer.UV6Kind
  78048. * - VertexBuffer.ColorKind
  78049. * - VertexBuffer.MatricesIndicesKind
  78050. * - VertexBuffer.MatricesIndicesExtraKind
  78051. * - VertexBuffer.MatricesWeightsKind
  78052. * - VertexBuffer.MatricesWeightsExtraKind
  78053. * @returns an array of strings
  78054. */
  78055. getVerticesDataKinds(): string[];
  78056. /**
  78057. * Returns a positive integer : the total number of indices in this mesh geometry.
  78058. * @returns the numner of indices or zero if the mesh has no geometry.
  78059. */
  78060. getTotalIndices(): number;
  78061. /**
  78062. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  78063. * @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.
  78064. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  78065. * @returns the indices array or an empty array if the mesh has no geometry
  78066. */
  78067. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  78068. readonly isBlocked: boolean;
  78069. /**
  78070. * Determine if the current mesh is ready to be rendered
  78071. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  78072. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  78073. * @returns true if all associated assets are ready (material, textures, shaders)
  78074. */
  78075. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  78076. /**
  78077. * 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.
  78078. */
  78079. readonly areNormalsFrozen: boolean;
  78080. /**
  78081. * 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.
  78082. * @returns the current mesh
  78083. */
  78084. freezeNormals(): Mesh;
  78085. /**
  78086. * 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
  78087. * @returns the current mesh
  78088. */
  78089. unfreezeNormals(): Mesh;
  78090. /**
  78091. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  78092. */
  78093. overridenInstanceCount: number;
  78094. /** @hidden */
  78095. _preActivate(): Mesh;
  78096. /** @hidden */
  78097. _preActivateForIntermediateRendering(renderId: number): Mesh;
  78098. /** @hidden */
  78099. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  78100. /**
  78101. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  78102. * This means the mesh underlying bounding box and sphere are recomputed.
  78103. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  78104. * @returns the current mesh
  78105. */
  78106. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  78107. /** @hidden */
  78108. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  78109. /**
  78110. * This function will subdivide the mesh into multiple submeshes
  78111. * @param count defines the expected number of submeshes
  78112. */
  78113. subdivide(count: number): void;
  78114. /**
  78115. * Copy a FloatArray into a specific associated vertex buffer
  78116. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  78117. * - VertexBuffer.PositionKind
  78118. * - VertexBuffer.UVKind
  78119. * - VertexBuffer.UV2Kind
  78120. * - VertexBuffer.UV3Kind
  78121. * - VertexBuffer.UV4Kind
  78122. * - VertexBuffer.UV5Kind
  78123. * - VertexBuffer.UV6Kind
  78124. * - VertexBuffer.ColorKind
  78125. * - VertexBuffer.MatricesIndicesKind
  78126. * - VertexBuffer.MatricesIndicesExtraKind
  78127. * - VertexBuffer.MatricesWeightsKind
  78128. * - VertexBuffer.MatricesWeightsExtraKind
  78129. * @param data defines the data source
  78130. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  78131. * @param stride defines the data stride size (can be null)
  78132. * @returns the current mesh
  78133. */
  78134. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  78135. /**
  78136. * Flags an associated vertex buffer as updatable
  78137. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  78138. * - VertexBuffer.PositionKind
  78139. * - VertexBuffer.UVKind
  78140. * - VertexBuffer.UV2Kind
  78141. * - VertexBuffer.UV3Kind
  78142. * - VertexBuffer.UV4Kind
  78143. * - VertexBuffer.UV5Kind
  78144. * - VertexBuffer.UV6Kind
  78145. * - VertexBuffer.ColorKind
  78146. * - VertexBuffer.MatricesIndicesKind
  78147. * - VertexBuffer.MatricesIndicesExtraKind
  78148. * - VertexBuffer.MatricesWeightsKind
  78149. * - VertexBuffer.MatricesWeightsExtraKind
  78150. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  78151. */
  78152. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  78153. /**
  78154. * Sets the mesh global Vertex Buffer
  78155. * @param buffer defines the buffer to use
  78156. * @returns the current mesh
  78157. */
  78158. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  78159. /**
  78160. * Update a specific associated vertex buffer
  78161. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  78162. * - VertexBuffer.PositionKind
  78163. * - VertexBuffer.UVKind
  78164. * - VertexBuffer.UV2Kind
  78165. * - VertexBuffer.UV3Kind
  78166. * - VertexBuffer.UV4Kind
  78167. * - VertexBuffer.UV5Kind
  78168. * - VertexBuffer.UV6Kind
  78169. * - VertexBuffer.ColorKind
  78170. * - VertexBuffer.MatricesIndicesKind
  78171. * - VertexBuffer.MatricesIndicesExtraKind
  78172. * - VertexBuffer.MatricesWeightsKind
  78173. * - VertexBuffer.MatricesWeightsExtraKind
  78174. * @param data defines the data source
  78175. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  78176. * @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)
  78177. * @returns the current mesh
  78178. */
  78179. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  78180. /**
  78181. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  78182. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  78183. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  78184. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  78185. * @returns the current mesh
  78186. */
  78187. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  78188. /**
  78189. * Creates a un-shared specific occurence of the geometry for the mesh.
  78190. * @returns the current mesh
  78191. */
  78192. makeGeometryUnique(): Mesh;
  78193. /**
  78194. * Set the index buffer of this mesh
  78195. * @param indices defines the source data
  78196. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  78197. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  78198. * @returns the current mesh
  78199. */
  78200. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  78201. /**
  78202. * Update the current index buffer
  78203. * @param indices defines the source data
  78204. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  78205. * @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)
  78206. * @returns the current mesh
  78207. */
  78208. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  78209. /**
  78210. * Invert the geometry to move from a right handed system to a left handed one.
  78211. * @returns the current mesh
  78212. */
  78213. toLeftHanded(): Mesh;
  78214. /** @hidden */
  78215. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  78216. /** @hidden */
  78217. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  78218. /**
  78219. * Registers for this mesh a javascript function called just before the rendering process
  78220. * @param func defines the function to call before rendering this mesh
  78221. * @returns the current mesh
  78222. */
  78223. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  78224. /**
  78225. * Disposes a previously registered javascript function called before the rendering
  78226. * @param func defines the function to remove
  78227. * @returns the current mesh
  78228. */
  78229. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  78230. /**
  78231. * Registers for this mesh a javascript function called just after the rendering is complete
  78232. * @param func defines the function to call after rendering this mesh
  78233. * @returns the current mesh
  78234. */
  78235. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  78236. /**
  78237. * Disposes a previously registered javascript function called after the rendering.
  78238. * @param func defines the function to remove
  78239. * @returns the current mesh
  78240. */
  78241. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  78242. /** @hidden */
  78243. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  78244. /** @hidden */
  78245. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  78246. /** @hidden */
  78247. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  78248. /**
  78249. * 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
  78250. * @param subMesh defines the subMesh to render
  78251. * @param enableAlphaMode defines if alpha mode can be changed
  78252. * @returns the current mesh
  78253. */
  78254. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  78255. private _onBeforeDraw;
  78256. /**
  78257. * Renormalize the mesh and patch it up if there are no weights
  78258. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  78259. * However in the case of zero weights then we set just a single influence to 1.
  78260. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  78261. */
  78262. cleanMatrixWeights(): void;
  78263. private normalizeSkinFourWeights;
  78264. private normalizeSkinWeightsAndExtra;
  78265. /**
  78266. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  78267. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  78268. * the user know there was an issue with importing the mesh
  78269. * @returns a validation object with skinned, valid and report string
  78270. */
  78271. validateSkinning(): {
  78272. skinned: boolean;
  78273. valid: boolean;
  78274. report: string;
  78275. };
  78276. /** @hidden */
  78277. _checkDelayState(): Mesh;
  78278. private _queueLoad;
  78279. /**
  78280. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  78281. * A mesh is in the frustum if its bounding box intersects the frustum
  78282. * @param frustumPlanes defines the frustum to test
  78283. * @returns true if the mesh is in the frustum planes
  78284. */
  78285. isInFrustum(frustumPlanes: Plane[]): boolean;
  78286. /**
  78287. * Sets the mesh material by the material or multiMaterial `id` property
  78288. * @param id is a string identifying the material or the multiMaterial
  78289. * @returns the current mesh
  78290. */
  78291. setMaterialByID(id: string): Mesh;
  78292. /**
  78293. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  78294. * @returns an array of IAnimatable
  78295. */
  78296. getAnimatables(): IAnimatable[];
  78297. /**
  78298. * Modifies the mesh geometry according to the passed transformation matrix.
  78299. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  78300. * The mesh normals are modified using the same transformation.
  78301. * Note that, under the hood, this method sets a new VertexBuffer each call.
  78302. * @param transform defines the transform matrix to use
  78303. * @see http://doc.babylonjs.com/resources/baking_transformations
  78304. * @returns the current mesh
  78305. */
  78306. bakeTransformIntoVertices(transform: Matrix): Mesh;
  78307. /**
  78308. * Modifies the mesh geometry according to its own current World Matrix.
  78309. * The mesh World Matrix is then reset.
  78310. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  78311. * Note that, under the hood, this method sets a new VertexBuffer each call.
  78312. * @see http://doc.babylonjs.com/resources/baking_transformations
  78313. * @returns the current mesh
  78314. */
  78315. bakeCurrentTransformIntoVertices(): Mesh;
  78316. /** @hidden */
  78317. readonly _positions: Nullable<Vector3[]>;
  78318. /** @hidden */
  78319. _resetPointsArrayCache(): Mesh;
  78320. /** @hidden */
  78321. _generatePointsArray(): boolean;
  78322. /**
  78323. * Returns a new Mesh object generated from the current mesh properties.
  78324. * This method must not get confused with createInstance()
  78325. * @param name is a string, the name given to the new mesh
  78326. * @param newParent can be any Node object (default `null`)
  78327. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  78328. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  78329. * @returns a new mesh
  78330. */
  78331. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  78332. /**
  78333. * Releases resources associated with this mesh.
  78334. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  78335. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  78336. */
  78337. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  78338. /**
  78339. * Modifies the mesh geometry according to a displacement map.
  78340. * 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.
  78341. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  78342. * @param url is a string, the URL from the image file is to be downloaded.
  78343. * @param minHeight is the lower limit of the displacement.
  78344. * @param maxHeight is the upper limit of the displacement.
  78345. * @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.
  78346. * @param uvOffset is an optional vector2 used to offset UV.
  78347. * @param uvScale is an optional vector2 used to scale UV.
  78348. * @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.
  78349. * @returns the Mesh.
  78350. */
  78351. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  78352. /**
  78353. * Modifies the mesh geometry according to a displacementMap buffer.
  78354. * 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.
  78355. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  78356. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  78357. * @param heightMapWidth is the width of the buffer image.
  78358. * @param heightMapHeight is the height of the buffer image.
  78359. * @param minHeight is the lower limit of the displacement.
  78360. * @param maxHeight is the upper limit of the displacement.
  78361. * @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.
  78362. * @param uvOffset is an optional vector2 used to offset UV.
  78363. * @param uvScale is an optional vector2 used to scale UV.
  78364. * @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.
  78365. * @returns the Mesh.
  78366. */
  78367. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  78368. /**
  78369. * Modify the mesh to get a flat shading rendering.
  78370. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  78371. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  78372. * @returns current mesh
  78373. */
  78374. convertToFlatShadedMesh(): Mesh;
  78375. /**
  78376. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  78377. * In other words, more vertices, no more indices and a single bigger VBO.
  78378. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  78379. * @returns current mesh
  78380. */
  78381. convertToUnIndexedMesh(): Mesh;
  78382. /**
  78383. * Inverses facet orientations.
  78384. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  78385. * @param flipNormals will also inverts the normals
  78386. * @returns current mesh
  78387. */
  78388. flipFaces(flipNormals?: boolean): Mesh;
  78389. /** @hidden */
  78390. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  78391. /** @hidden */
  78392. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  78393. /**
  78394. * Creates a new InstancedMesh object from the mesh model.
  78395. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  78396. * @param name defines the name of the new instance
  78397. * @returns a new InstancedMesh
  78398. */
  78399. createInstance(name: string): InstancedMesh;
  78400. /**
  78401. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  78402. * After this call, all the mesh instances have the same submeshes than the current mesh.
  78403. * @returns the current mesh
  78404. */
  78405. synchronizeInstances(): Mesh;
  78406. /**
  78407. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  78408. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  78409. * This should be used together with the simplification to avoid disappearing triangles.
  78410. * @param successCallback an optional success callback to be called after the optimization finished.
  78411. * @returns the current mesh
  78412. */
  78413. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  78414. /**
  78415. * Serialize current mesh
  78416. * @param serializationObject defines the object which will receive the serialization data
  78417. */
  78418. serialize(serializationObject: any): void;
  78419. /** @hidden */
  78420. _syncGeometryWithMorphTargetManager(): void;
  78421. /** @hidden */
  78422. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  78423. /**
  78424. * Returns a new Mesh object parsed from the source provided.
  78425. * @param parsedMesh is the source
  78426. * @param scene defines the hosting scene
  78427. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  78428. * @returns a new Mesh
  78429. */
  78430. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  78431. /**
  78432. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  78433. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  78434. * @param name defines the name of the mesh to create
  78435. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  78436. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  78437. * @param closePath creates a seam between the first and the last points of each path of the path array
  78438. * @param offset is taken in account only if the `pathArray` is containing a single path
  78439. * @param scene defines the hosting scene
  78440. * @param updatable defines if the mesh must be flagged as updatable
  78441. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78442. * @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)
  78443. * @returns a new Mesh
  78444. */
  78445. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  78446. /**
  78447. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  78448. * @param name defines the name of the mesh to create
  78449. * @param radius sets the radius size (float) of the polygon (default 0.5)
  78450. * @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
  78451. * @param scene defines the hosting scene
  78452. * @param updatable defines if the mesh must be flagged as updatable
  78453. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78454. * @returns a new Mesh
  78455. */
  78456. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  78457. /**
  78458. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  78459. * @param name defines the name of the mesh to create
  78460. * @param size sets the size (float) of each box side (default 1)
  78461. * @param scene defines the hosting scene
  78462. * @param updatable defines if the mesh must be flagged as updatable
  78463. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78464. * @returns a new Mesh
  78465. */
  78466. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  78467. /**
  78468. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  78469. * @param name defines the name of the mesh to create
  78470. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  78471. * @param diameter sets the diameter size (float) of the sphere (default 1)
  78472. * @param scene defines the hosting scene
  78473. * @param updatable defines if the mesh must be flagged as updatable
  78474. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78475. * @returns a new Mesh
  78476. */
  78477. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78478. /**
  78479. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  78480. * @param name defines the name of the mesh to create
  78481. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  78482. * @param diameterTop set the top cap diameter (floats, default 1)
  78483. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  78484. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  78485. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  78486. * @param scene defines the hosting scene
  78487. * @param updatable defines if the mesh must be flagged as updatable
  78488. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78489. * @returns a new Mesh
  78490. */
  78491. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  78492. /**
  78493. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  78494. * @param name defines the name of the mesh to create
  78495. * @param diameter sets the diameter size (float) of the torus (default 1)
  78496. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  78497. * @param tessellation sets the number of torus sides (postive integer, default 16)
  78498. * @param scene defines the hosting scene
  78499. * @param updatable defines if the mesh must be flagged as updatable
  78500. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78501. * @returns a new Mesh
  78502. */
  78503. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78504. /**
  78505. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  78506. * @param name defines the name of the mesh to create
  78507. * @param radius sets the global radius size (float) of the torus knot (default 2)
  78508. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  78509. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  78510. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  78511. * @param p the number of windings on X axis (positive integers, default 2)
  78512. * @param q the number of windings on Y axis (positive integers, default 3)
  78513. * @param scene defines the hosting scene
  78514. * @param updatable defines if the mesh must be flagged as updatable
  78515. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78516. * @returns a new Mesh
  78517. */
  78518. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78519. /**
  78520. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  78521. * @param name defines the name of the mesh to create
  78522. * @param points is an array successive Vector3
  78523. * @param scene defines the hosting scene
  78524. * @param updatable defines if the mesh must be flagged as updatable
  78525. * @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).
  78526. * @returns a new Mesh
  78527. */
  78528. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  78529. /**
  78530. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  78531. * @param name defines the name of the mesh to create
  78532. * @param points is an array successive Vector3
  78533. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  78534. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  78535. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  78536. * @param scene defines the hosting scene
  78537. * @param updatable defines if the mesh must be flagged as updatable
  78538. * @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)
  78539. * @returns a new Mesh
  78540. */
  78541. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  78542. /**
  78543. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  78544. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  78545. * 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.
  78546. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78547. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  78548. * Remember you can only change the shape positions, not their number when updating a polygon.
  78549. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  78550. * @param name defines the name of the mesh to create
  78551. * @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
  78552. * @param scene defines the hosting scene
  78553. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  78554. * @param updatable defines if the mesh must be flagged as updatable
  78555. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78556. * @param earcutInjection can be used to inject your own earcut reference
  78557. * @returns a new Mesh
  78558. */
  78559. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  78560. /**
  78561. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  78562. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  78563. * @param name defines the name of the mesh to create
  78564. * @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
  78565. * @param depth defines the height of extrusion
  78566. * @param scene defines the hosting scene
  78567. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  78568. * @param updatable defines if the mesh must be flagged as updatable
  78569. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78570. * @param earcutInjection can be used to inject your own earcut reference
  78571. * @returns a new Mesh
  78572. */
  78573. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  78574. /**
  78575. * Creates an extruded shape mesh.
  78576. * 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
  78577. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  78578. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  78579. * @param name defines the name of the mesh to create
  78580. * @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
  78581. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  78582. * @param scale is the value to scale the shape
  78583. * @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
  78584. * @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
  78585. * @param scene defines the hosting scene
  78586. * @param updatable defines if the mesh must be flagged as updatable
  78587. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78588. * @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)
  78589. * @returns a new Mesh
  78590. */
  78591. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  78592. /**
  78593. * Creates an custom extruded shape mesh.
  78594. * The custom extrusion is a parametric shape.
  78595. * It has no predefined shape. Its final shape will depend on the input parameters.
  78596. * Please consider using the same method from the MeshBuilder class instead
  78597. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  78598. * @param name defines the name of the mesh to create
  78599. * @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
  78600. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  78601. * @param scaleFunction is a custom Javascript function called on each path point
  78602. * @param rotationFunction is a custom Javascript function called on each path point
  78603. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  78604. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  78605. * @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
  78606. * @param scene defines the hosting scene
  78607. * @param updatable defines if the mesh must be flagged as updatable
  78608. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78609. * @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)
  78610. * @returns a new Mesh
  78611. */
  78612. 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;
  78613. /**
  78614. * Creates lathe mesh.
  78615. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  78616. * Please consider using the same method from the MeshBuilder class instead
  78617. * @param name defines the name of the mesh to create
  78618. * @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
  78619. * @param radius is the radius value of the lathe
  78620. * @param tessellation is the side number of the lathe.
  78621. * @param scene defines the hosting scene
  78622. * @param updatable defines if the mesh must be flagged as updatable
  78623. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78624. * @returns a new Mesh
  78625. */
  78626. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78627. /**
  78628. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  78629. * @param name defines the name of the mesh to create
  78630. * @param size sets the size (float) of both sides of the plane at once (default 1)
  78631. * @param scene defines the hosting scene
  78632. * @param updatable defines if the mesh must be flagged as updatable
  78633. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78634. * @returns a new Mesh
  78635. */
  78636. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78637. /**
  78638. * Creates a ground mesh.
  78639. * Please consider using the same method from the MeshBuilder class instead
  78640. * @param name defines the name of the mesh to create
  78641. * @param width set the width of the ground
  78642. * @param height set the height of the ground
  78643. * @param subdivisions sets the number of subdivisions per side
  78644. * @param scene defines the hosting scene
  78645. * @param updatable defines if the mesh must be flagged as updatable
  78646. * @returns a new Mesh
  78647. */
  78648. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  78649. /**
  78650. * Creates a tiled ground mesh.
  78651. * Please consider using the same method from the MeshBuilder class instead
  78652. * @param name defines the name of the mesh to create
  78653. * @param xmin set the ground minimum X coordinate
  78654. * @param zmin set the ground minimum Y coordinate
  78655. * @param xmax set the ground maximum X coordinate
  78656. * @param zmax set the ground maximum Z coordinate
  78657. * @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
  78658. * @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
  78659. * @param scene defines the hosting scene
  78660. * @param updatable defines if the mesh must be flagged as updatable
  78661. * @returns a new Mesh
  78662. */
  78663. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  78664. w: number;
  78665. h: number;
  78666. }, precision: {
  78667. w: number;
  78668. h: number;
  78669. }, scene: Scene, updatable?: boolean): Mesh;
  78670. /**
  78671. * Creates a ground mesh from a height map.
  78672. * Please consider using the same method from the MeshBuilder class instead
  78673. * @see http://doc.babylonjs.com/babylon101/height_map
  78674. * @param name defines the name of the mesh to create
  78675. * @param url sets the URL of the height map image resource
  78676. * @param width set the ground width size
  78677. * @param height set the ground height size
  78678. * @param subdivisions sets the number of subdivision per side
  78679. * @param minHeight is the minimum altitude on the ground
  78680. * @param maxHeight is the maximum altitude on the ground
  78681. * @param scene defines the hosting scene
  78682. * @param updatable defines if the mesh must be flagged as updatable
  78683. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  78684. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  78685. * @returns a new Mesh
  78686. */
  78687. 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;
  78688. /**
  78689. * Creates a tube mesh.
  78690. * The tube is a parametric shape.
  78691. * It has no predefined shape. Its final shape will depend on the input parameters.
  78692. * Please consider using the same method from the MeshBuilder class instead
  78693. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  78694. * @param name defines the name of the mesh to create
  78695. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  78696. * @param radius sets the tube radius size
  78697. * @param tessellation is the number of sides on the tubular surface
  78698. * @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
  78699. * @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
  78700. * @param scene defines the hosting scene
  78701. * @param updatable defines if the mesh must be flagged as updatable
  78702. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78703. * @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)
  78704. * @returns a new Mesh
  78705. */
  78706. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  78707. (i: number, distance: number): number;
  78708. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  78709. /**
  78710. * Creates a polyhedron mesh.
  78711. * Please consider using the same method from the MeshBuilder class instead.
  78712. * * 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
  78713. * * The parameter `size` (positive float, default 1) sets the polygon size
  78714. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  78715. * * 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`
  78716. * * 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
  78717. * * 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)`)
  78718. * * 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
  78719. * * 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
  78720. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78721. * * If you create a double-sided mesh, you can choose what parts of 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
  78722. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78723. * @param name defines the name of the mesh to create
  78724. * @param options defines the options used to create the mesh
  78725. * @param scene defines the hosting scene
  78726. * @returns a new Mesh
  78727. */
  78728. static CreatePolyhedron(name: string, options: {
  78729. type?: number;
  78730. size?: number;
  78731. sizeX?: number;
  78732. sizeY?: number;
  78733. sizeZ?: number;
  78734. custom?: any;
  78735. faceUV?: Vector4[];
  78736. faceColors?: Color4[];
  78737. updatable?: boolean;
  78738. sideOrientation?: number;
  78739. }, scene: Scene): Mesh;
  78740. /**
  78741. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  78742. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  78743. * * 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`)
  78744. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  78745. * * 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
  78746. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78747. * * If you create a double-sided mesh, you can choose what parts of 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
  78748. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78749. * @param name defines the name of the mesh
  78750. * @param options defines the options used to create the mesh
  78751. * @param scene defines the hosting scene
  78752. * @returns a new Mesh
  78753. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  78754. */
  78755. static CreateIcoSphere(name: string, options: {
  78756. radius?: number;
  78757. flat?: boolean;
  78758. subdivisions?: number;
  78759. sideOrientation?: number;
  78760. updatable?: boolean;
  78761. }, scene: Scene): Mesh;
  78762. /**
  78763. * Creates a decal mesh.
  78764. * Please consider using the same method from the MeshBuilder class instead.
  78765. * A decal is a mesh usually applied as a model onto the surface of another mesh
  78766. * @param name defines the name of the mesh
  78767. * @param sourceMesh defines the mesh receiving the decal
  78768. * @param position sets the position of the decal in world coordinates
  78769. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  78770. * @param size sets the decal scaling
  78771. * @param angle sets the angle to rotate the decal
  78772. * @returns a new Mesh
  78773. */
  78774. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  78775. /**
  78776. * Prepare internal position array for software CPU skinning
  78777. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  78778. */
  78779. setPositionsForCPUSkinning(): Float32Array;
  78780. /**
  78781. * Prepare internal normal array for software CPU skinning
  78782. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  78783. */
  78784. setNormalsForCPUSkinning(): Float32Array;
  78785. /**
  78786. * Updates the vertex buffer by applying transformation from the bones
  78787. * @param skeleton defines the skeleton to apply to current mesh
  78788. * @returns the current mesh
  78789. */
  78790. applySkeleton(skeleton: Skeleton): Mesh;
  78791. /**
  78792. * 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
  78793. * @param meshes defines the list of meshes to scan
  78794. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  78795. */
  78796. static MinMax(meshes: AbstractMesh[]): {
  78797. min: Vector3;
  78798. max: Vector3;
  78799. };
  78800. /**
  78801. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  78802. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  78803. * @returns a vector3
  78804. */
  78805. static Center(meshesOrMinMaxVector: {
  78806. min: Vector3;
  78807. max: Vector3;
  78808. } | AbstractMesh[]): Vector3;
  78809. /**
  78810. * Merge the array of meshes into a single mesh for performance reasons.
  78811. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  78812. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  78813. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  78814. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  78815. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  78816. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  78817. * @returns a new mesh
  78818. */
  78819. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  78820. /** @hidden */
  78821. addInstance(instance: InstancedMesh): void;
  78822. /** @hidden */
  78823. removeInstance(instance: InstancedMesh): void;
  78824. }
  78825. }
  78826. declare module BABYLON {
  78827. /**
  78828. * Base class for the main features of a material in Babylon.js
  78829. */
  78830. export class Material implements IAnimatable {
  78831. /**
  78832. * Returns the triangle fill mode
  78833. */
  78834. static readonly TriangleFillMode: number;
  78835. /**
  78836. * Returns the wireframe mode
  78837. */
  78838. static readonly WireFrameFillMode: number;
  78839. /**
  78840. * Returns the point fill mode
  78841. */
  78842. static readonly PointFillMode: number;
  78843. /**
  78844. * Returns the point list draw mode
  78845. */
  78846. static readonly PointListDrawMode: number;
  78847. /**
  78848. * Returns the line list draw mode
  78849. */
  78850. static readonly LineListDrawMode: number;
  78851. /**
  78852. * Returns the line loop draw mode
  78853. */
  78854. static readonly LineLoopDrawMode: number;
  78855. /**
  78856. * Returns the line strip draw mode
  78857. */
  78858. static readonly LineStripDrawMode: number;
  78859. /**
  78860. * Returns the triangle strip draw mode
  78861. */
  78862. static readonly TriangleStripDrawMode: number;
  78863. /**
  78864. * Returns the triangle fan draw mode
  78865. */
  78866. static readonly TriangleFanDrawMode: number;
  78867. /**
  78868. * Stores the clock-wise side orientation
  78869. */
  78870. static readonly ClockWiseSideOrientation: number;
  78871. /**
  78872. * Stores the counter clock-wise side orientation
  78873. */
  78874. static readonly CounterClockWiseSideOrientation: number;
  78875. /**
  78876. * The dirty texture flag value
  78877. */
  78878. static readonly TextureDirtyFlag: number;
  78879. /**
  78880. * The dirty light flag value
  78881. */
  78882. static readonly LightDirtyFlag: number;
  78883. /**
  78884. * The dirty fresnel flag value
  78885. */
  78886. static readonly FresnelDirtyFlag: number;
  78887. /**
  78888. * The dirty attribute flag value
  78889. */
  78890. static readonly AttributesDirtyFlag: number;
  78891. /**
  78892. * The dirty misc flag value
  78893. */
  78894. static readonly MiscDirtyFlag: number;
  78895. /**
  78896. * The all dirty flag value
  78897. */
  78898. static readonly AllDirtyFlag: number;
  78899. /**
  78900. * The ID of the material
  78901. */
  78902. id: string;
  78903. /**
  78904. * Gets or sets the unique id of the material
  78905. */
  78906. uniqueId: number;
  78907. /**
  78908. * The name of the material
  78909. */
  78910. name: string;
  78911. /**
  78912. * Gets or sets user defined metadata
  78913. */
  78914. metadata: any;
  78915. /**
  78916. * For internal use only. Please do not use.
  78917. */
  78918. reservedDataStore: any;
  78919. /**
  78920. * Specifies if the ready state should be checked on each call
  78921. */
  78922. checkReadyOnEveryCall: boolean;
  78923. /**
  78924. * Specifies if the ready state should be checked once
  78925. */
  78926. checkReadyOnlyOnce: boolean;
  78927. /**
  78928. * The state of the material
  78929. */
  78930. state: string;
  78931. /**
  78932. * The alpha value of the material
  78933. */
  78934. protected _alpha: number;
  78935. /**
  78936. * Sets the alpha value of the material
  78937. */
  78938. /**
  78939. * Gets the alpha value of the material
  78940. */
  78941. alpha: number;
  78942. /**
  78943. * Specifies if back face culling is enabled
  78944. */
  78945. protected _backFaceCulling: boolean;
  78946. /**
  78947. * Sets the back-face culling state
  78948. */
  78949. /**
  78950. * Gets the back-face culling state
  78951. */
  78952. backFaceCulling: boolean;
  78953. /**
  78954. * Stores the value for side orientation
  78955. */
  78956. sideOrientation: number;
  78957. /**
  78958. * Callback triggered when the material is compiled
  78959. */
  78960. onCompiled: (effect: Effect) => void;
  78961. /**
  78962. * Callback triggered when an error occurs
  78963. */
  78964. onError: (effect: Effect, errors: string) => void;
  78965. /**
  78966. * Callback triggered to get the render target textures
  78967. */
  78968. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  78969. /**
  78970. * Gets a boolean indicating that current material needs to register RTT
  78971. */
  78972. readonly hasRenderTargetTextures: boolean;
  78973. /**
  78974. * Specifies if the material should be serialized
  78975. */
  78976. doNotSerialize: boolean;
  78977. /**
  78978. * @hidden
  78979. */
  78980. _storeEffectOnSubMeshes: boolean;
  78981. /**
  78982. * Stores the animations for the material
  78983. */
  78984. animations: Array<Animation>;
  78985. /**
  78986. * An event triggered when the material is disposed
  78987. */
  78988. onDisposeObservable: Observable<Material>;
  78989. /**
  78990. * An observer which watches for dispose events
  78991. */
  78992. private _onDisposeObserver;
  78993. private _onUnBindObservable;
  78994. /**
  78995. * Called during a dispose event
  78996. */
  78997. onDispose: () => void;
  78998. private _onBindObservable;
  78999. /**
  79000. * An event triggered when the material is bound
  79001. */
  79002. readonly onBindObservable: Observable<AbstractMesh>;
  79003. /**
  79004. * An observer which watches for bind events
  79005. */
  79006. private _onBindObserver;
  79007. /**
  79008. * Called during a bind event
  79009. */
  79010. onBind: (Mesh: AbstractMesh) => void;
  79011. /**
  79012. * An event triggered when the material is unbound
  79013. */
  79014. readonly onUnBindObservable: Observable<Material>;
  79015. /**
  79016. * Stores the value of the alpha mode
  79017. */
  79018. private _alphaMode;
  79019. /**
  79020. * Sets the value of the alpha mode.
  79021. *
  79022. * | Value | Type | Description |
  79023. * | --- | --- | --- |
  79024. * | 0 | ALPHA_DISABLE | |
  79025. * | 1 | ALPHA_ADD | |
  79026. * | 2 | ALPHA_COMBINE | |
  79027. * | 3 | ALPHA_SUBTRACT | |
  79028. * | 4 | ALPHA_MULTIPLY | |
  79029. * | 5 | ALPHA_MAXIMIZED | |
  79030. * | 6 | ALPHA_ONEONE | |
  79031. * | 7 | ALPHA_PREMULTIPLIED | |
  79032. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  79033. * | 9 | ALPHA_INTERPOLATE | |
  79034. * | 10 | ALPHA_SCREENMODE | |
  79035. *
  79036. */
  79037. /**
  79038. * Gets the value of the alpha mode
  79039. */
  79040. alphaMode: number;
  79041. /**
  79042. * Stores the state of the need depth pre-pass value
  79043. */
  79044. private _needDepthPrePass;
  79045. /**
  79046. * Sets the need depth pre-pass value
  79047. */
  79048. /**
  79049. * Gets the depth pre-pass value
  79050. */
  79051. needDepthPrePass: boolean;
  79052. /**
  79053. * Specifies if depth writing should be disabled
  79054. */
  79055. disableDepthWrite: boolean;
  79056. /**
  79057. * Specifies if depth writing should be forced
  79058. */
  79059. forceDepthWrite: boolean;
  79060. /**
  79061. * Specifies if there should be a separate pass for culling
  79062. */
  79063. separateCullingPass: boolean;
  79064. /**
  79065. * Stores the state specifing if fog should be enabled
  79066. */
  79067. private _fogEnabled;
  79068. /**
  79069. * Sets the state for enabling fog
  79070. */
  79071. /**
  79072. * Gets the value of the fog enabled state
  79073. */
  79074. fogEnabled: boolean;
  79075. /**
  79076. * Stores the size of points
  79077. */
  79078. pointSize: number;
  79079. /**
  79080. * Stores the z offset value
  79081. */
  79082. zOffset: number;
  79083. /**
  79084. * Gets a value specifying if wireframe mode is enabled
  79085. */
  79086. /**
  79087. * Sets the state of wireframe mode
  79088. */
  79089. wireframe: boolean;
  79090. /**
  79091. * Gets the value specifying if point clouds are enabled
  79092. */
  79093. /**
  79094. * Sets the state of point cloud mode
  79095. */
  79096. pointsCloud: boolean;
  79097. /**
  79098. * Gets the material fill mode
  79099. */
  79100. /**
  79101. * Sets the material fill mode
  79102. */
  79103. fillMode: number;
  79104. /**
  79105. * @hidden
  79106. * Stores the effects for the material
  79107. */
  79108. _effect: Nullable<Effect>;
  79109. /**
  79110. * @hidden
  79111. * Specifies if the material was previously ready
  79112. */
  79113. _wasPreviouslyReady: boolean;
  79114. /**
  79115. * Specifies if uniform buffers should be used
  79116. */
  79117. private _useUBO;
  79118. /**
  79119. * Stores a reference to the scene
  79120. */
  79121. private _scene;
  79122. /**
  79123. * Stores the fill mode state
  79124. */
  79125. private _fillMode;
  79126. /**
  79127. * Specifies if the depth write state should be cached
  79128. */
  79129. private _cachedDepthWriteState;
  79130. /**
  79131. * Stores the uniform buffer
  79132. */
  79133. protected _uniformBuffer: UniformBuffer;
  79134. /** @hidden */
  79135. _indexInSceneMaterialArray: number;
  79136. /** @hidden */
  79137. meshMap: Nullable<{
  79138. [id: string]: AbstractMesh | undefined;
  79139. }>;
  79140. /**
  79141. * Creates a material instance
  79142. * @param name defines the name of the material
  79143. * @param scene defines the scene to reference
  79144. * @param doNotAdd specifies if the material should be added to the scene
  79145. */
  79146. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  79147. /**
  79148. * Returns a string representation of the current material
  79149. * @param fullDetails defines a boolean indicating which levels of logging is desired
  79150. * @returns a string with material information
  79151. */
  79152. toString(fullDetails?: boolean): string;
  79153. /**
  79154. * Gets the class name of the material
  79155. * @returns a string with the class name of the material
  79156. */
  79157. getClassName(): string;
  79158. /**
  79159. * Specifies if updates for the material been locked
  79160. */
  79161. readonly isFrozen: boolean;
  79162. /**
  79163. * Locks updates for the material
  79164. */
  79165. freeze(): void;
  79166. /**
  79167. * Unlocks updates for the material
  79168. */
  79169. unfreeze(): void;
  79170. /**
  79171. * Specifies if the material is ready to be used
  79172. * @param mesh defines the mesh to check
  79173. * @param useInstances specifies if instances should be used
  79174. * @returns a boolean indicating if the material is ready to be used
  79175. */
  79176. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  79177. /**
  79178. * Specifies that the submesh is ready to be used
  79179. * @param mesh defines the mesh to check
  79180. * @param subMesh defines which submesh to check
  79181. * @param useInstances specifies that instances should be used
  79182. * @returns a boolean indicating that the submesh is ready or not
  79183. */
  79184. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  79185. /**
  79186. * Returns the material effect
  79187. * @returns the effect associated with the material
  79188. */
  79189. getEffect(): Nullable<Effect>;
  79190. /**
  79191. * Returns the current scene
  79192. * @returns a Scene
  79193. */
  79194. getScene(): Scene;
  79195. /**
  79196. * Specifies if the material will require alpha blending
  79197. * @returns a boolean specifying if alpha blending is needed
  79198. */
  79199. needAlphaBlending(): boolean;
  79200. /**
  79201. * Specifies if the mesh will require alpha blending
  79202. * @param mesh defines the mesh to check
  79203. * @returns a boolean specifying if alpha blending is needed for the mesh
  79204. */
  79205. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  79206. /**
  79207. * Specifies if this material should be rendered in alpha test mode
  79208. * @returns a boolean specifying if an alpha test is needed.
  79209. */
  79210. needAlphaTesting(): boolean;
  79211. /**
  79212. * Gets the texture used for the alpha test
  79213. * @returns the texture to use for alpha testing
  79214. */
  79215. getAlphaTestTexture(): Nullable<BaseTexture>;
  79216. /**
  79217. * Marks the material to indicate that it needs to be re-calculated
  79218. */
  79219. markDirty(): void;
  79220. /** @hidden */
  79221. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  79222. /**
  79223. * Binds the material to the mesh
  79224. * @param world defines the world transformation matrix
  79225. * @param mesh defines the mesh to bind the material to
  79226. */
  79227. bind(world: Matrix, mesh?: Mesh): void;
  79228. /**
  79229. * Binds the submesh to the material
  79230. * @param world defines the world transformation matrix
  79231. * @param mesh defines the mesh containing the submesh
  79232. * @param subMesh defines the submesh to bind the material to
  79233. */
  79234. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  79235. /**
  79236. * Binds the world matrix to the material
  79237. * @param world defines the world transformation matrix
  79238. */
  79239. bindOnlyWorldMatrix(world: Matrix): void;
  79240. /**
  79241. * Binds the scene's uniform buffer to the effect.
  79242. * @param effect defines the effect to bind to the scene uniform buffer
  79243. * @param sceneUbo defines the uniform buffer storing scene data
  79244. */
  79245. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  79246. /**
  79247. * Binds the view matrix to the effect
  79248. * @param effect defines the effect to bind the view matrix to
  79249. */
  79250. bindView(effect: Effect): void;
  79251. /**
  79252. * Binds the view projection matrix to the effect
  79253. * @param effect defines the effect to bind the view projection matrix to
  79254. */
  79255. bindViewProjection(effect: Effect): void;
  79256. /**
  79257. * Specifies if material alpha testing should be turned on for the mesh
  79258. * @param mesh defines the mesh to check
  79259. */
  79260. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  79261. /**
  79262. * Processes to execute after binding the material to a mesh
  79263. * @param mesh defines the rendered mesh
  79264. */
  79265. protected _afterBind(mesh?: Mesh): void;
  79266. /**
  79267. * Unbinds the material from the mesh
  79268. */
  79269. unbind(): void;
  79270. /**
  79271. * Gets the active textures from the material
  79272. * @returns an array of textures
  79273. */
  79274. getActiveTextures(): BaseTexture[];
  79275. /**
  79276. * Specifies if the material uses a texture
  79277. * @param texture defines the texture to check against the material
  79278. * @returns a boolean specifying if the material uses the texture
  79279. */
  79280. hasTexture(texture: BaseTexture): boolean;
  79281. /**
  79282. * Makes a duplicate of the material, and gives it a new name
  79283. * @param name defines the new name for the duplicated material
  79284. * @returns the cloned material
  79285. */
  79286. clone(name: string): Nullable<Material>;
  79287. /**
  79288. * Gets the meshes bound to the material
  79289. * @returns an array of meshes bound to the material
  79290. */
  79291. getBindedMeshes(): AbstractMesh[];
  79292. /**
  79293. * Force shader compilation
  79294. * @param mesh defines the mesh associated with this material
  79295. * @param onCompiled defines a function to execute once the material is compiled
  79296. * @param options defines the options to configure the compilation
  79297. */
  79298. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  79299. clipPlane: boolean;
  79300. }>): void;
  79301. /**
  79302. * Force shader compilation
  79303. * @param mesh defines the mesh that will use this material
  79304. * @param options defines additional options for compiling the shaders
  79305. * @returns a promise that resolves when the compilation completes
  79306. */
  79307. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  79308. clipPlane: boolean;
  79309. }>): Promise<void>;
  79310. private static readonly _ImageProcessingDirtyCallBack;
  79311. private static readonly _TextureDirtyCallBack;
  79312. private static readonly _FresnelDirtyCallBack;
  79313. private static readonly _MiscDirtyCallBack;
  79314. private static readonly _LightsDirtyCallBack;
  79315. private static readonly _AttributeDirtyCallBack;
  79316. private static _FresnelAndMiscDirtyCallBack;
  79317. private static _TextureAndMiscDirtyCallBack;
  79318. private static readonly _DirtyCallbackArray;
  79319. private static readonly _RunDirtyCallBacks;
  79320. /**
  79321. * Marks a define in the material to indicate that it needs to be re-computed
  79322. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  79323. */
  79324. markAsDirty(flag: number): void;
  79325. /**
  79326. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  79327. * @param func defines a function which checks material defines against the submeshes
  79328. */
  79329. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  79330. /**
  79331. * Indicates that image processing needs to be re-calculated for all submeshes
  79332. */
  79333. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  79334. /**
  79335. * Indicates that textures need to be re-calculated for all submeshes
  79336. */
  79337. protected _markAllSubMeshesAsTexturesDirty(): void;
  79338. /**
  79339. * Indicates that fresnel needs to be re-calculated for all submeshes
  79340. */
  79341. protected _markAllSubMeshesAsFresnelDirty(): void;
  79342. /**
  79343. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  79344. */
  79345. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  79346. /**
  79347. * Indicates that lights need to be re-calculated for all submeshes
  79348. */
  79349. protected _markAllSubMeshesAsLightsDirty(): void;
  79350. /**
  79351. * Indicates that attributes need to be re-calculated for all submeshes
  79352. */
  79353. protected _markAllSubMeshesAsAttributesDirty(): void;
  79354. /**
  79355. * Indicates that misc needs to be re-calculated for all submeshes
  79356. */
  79357. protected _markAllSubMeshesAsMiscDirty(): void;
  79358. /**
  79359. * Indicates that textures and misc need to be re-calculated for all submeshes
  79360. */
  79361. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  79362. /**
  79363. * Disposes the material
  79364. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  79365. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  79366. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  79367. */
  79368. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  79369. /** @hidden */
  79370. private releaseVertexArrayObject;
  79371. /**
  79372. * Serializes this material
  79373. * @returns the serialized material object
  79374. */
  79375. serialize(): any;
  79376. /**
  79377. * Creates a material from parsed material data
  79378. * @param parsedMaterial defines parsed material data
  79379. * @param scene defines the hosting scene
  79380. * @param rootUrl defines the root URL to use to load textures
  79381. * @returns a new material
  79382. */
  79383. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  79384. }
  79385. }
  79386. declare module BABYLON {
  79387. /**
  79388. * Base class for submeshes
  79389. */
  79390. export class BaseSubMesh {
  79391. /** @hidden */
  79392. _materialDefines: Nullable<MaterialDefines>;
  79393. /** @hidden */
  79394. _materialEffect: Nullable<Effect>;
  79395. /**
  79396. * Gets associated effect
  79397. */
  79398. readonly effect: Nullable<Effect>;
  79399. /**
  79400. * Sets associated effect (effect used to render this submesh)
  79401. * @param effect defines the effect to associate with
  79402. * @param defines defines the set of defines used to compile this effect
  79403. */
  79404. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  79405. }
  79406. /**
  79407. * Defines a subdivision inside a mesh
  79408. */
  79409. export class SubMesh extends BaseSubMesh implements ICullable {
  79410. /** the material index to use */
  79411. materialIndex: number;
  79412. /** vertex index start */
  79413. verticesStart: number;
  79414. /** vertices count */
  79415. verticesCount: number;
  79416. /** index start */
  79417. indexStart: number;
  79418. /** indices count */
  79419. indexCount: number;
  79420. /** @hidden */
  79421. _linesIndexCount: number;
  79422. private _mesh;
  79423. private _renderingMesh;
  79424. private _boundingInfo;
  79425. private _linesIndexBuffer;
  79426. /** @hidden */
  79427. _lastColliderWorldVertices: Nullable<Vector3[]>;
  79428. /** @hidden */
  79429. _trianglePlanes: Plane[];
  79430. /** @hidden */
  79431. _lastColliderTransformMatrix: Matrix;
  79432. /** @hidden */
  79433. _renderId: number;
  79434. /** @hidden */
  79435. _alphaIndex: number;
  79436. /** @hidden */
  79437. _distanceToCamera: number;
  79438. /** @hidden */
  79439. _id: number;
  79440. private _currentMaterial;
  79441. /**
  79442. * Add a new submesh to a mesh
  79443. * @param materialIndex defines the material index to use
  79444. * @param verticesStart defines vertex index start
  79445. * @param verticesCount defines vertices count
  79446. * @param indexStart defines index start
  79447. * @param indexCount defines indices count
  79448. * @param mesh defines the parent mesh
  79449. * @param renderingMesh defines an optional rendering mesh
  79450. * @param createBoundingBox defines if bounding box should be created for this submesh
  79451. * @returns the new submesh
  79452. */
  79453. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  79454. /**
  79455. * Creates a new submesh
  79456. * @param materialIndex defines the material index to use
  79457. * @param verticesStart defines vertex index start
  79458. * @param verticesCount defines vertices count
  79459. * @param indexStart defines index start
  79460. * @param indexCount defines indices count
  79461. * @param mesh defines the parent mesh
  79462. * @param renderingMesh defines an optional rendering mesh
  79463. * @param createBoundingBox defines if bounding box should be created for this submesh
  79464. */
  79465. constructor(
  79466. /** the material index to use */
  79467. materialIndex: number,
  79468. /** vertex index start */
  79469. verticesStart: number,
  79470. /** vertices count */
  79471. verticesCount: number,
  79472. /** index start */
  79473. indexStart: number,
  79474. /** indices count */
  79475. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  79476. /**
  79477. * Returns true if this submesh covers the entire parent mesh
  79478. * @ignorenaming
  79479. */
  79480. readonly IsGlobal: boolean;
  79481. /**
  79482. * Returns the submesh BoudingInfo object
  79483. * @returns current bounding info (or mesh's one if the submesh is global)
  79484. */
  79485. getBoundingInfo(): BoundingInfo;
  79486. /**
  79487. * Sets the submesh BoundingInfo
  79488. * @param boundingInfo defines the new bounding info to use
  79489. * @returns the SubMesh
  79490. */
  79491. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  79492. /**
  79493. * Returns the mesh of the current submesh
  79494. * @return the parent mesh
  79495. */
  79496. getMesh(): AbstractMesh;
  79497. /**
  79498. * Returns the rendering mesh of the submesh
  79499. * @returns the rendering mesh (could be different from parent mesh)
  79500. */
  79501. getRenderingMesh(): Mesh;
  79502. /**
  79503. * Returns the submesh material
  79504. * @returns null or the current material
  79505. */
  79506. getMaterial(): Nullable<Material>;
  79507. /**
  79508. * Sets a new updated BoundingInfo object to the submesh
  79509. * @returns the SubMesh
  79510. */
  79511. refreshBoundingInfo(): SubMesh;
  79512. /** @hidden */
  79513. _checkCollision(collider: Collider): boolean;
  79514. /**
  79515. * Updates the submesh BoundingInfo
  79516. * @param world defines the world matrix to use to update the bounding info
  79517. * @returns the submesh
  79518. */
  79519. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  79520. /**
  79521. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  79522. * @param frustumPlanes defines the frustum planes
  79523. * @returns true if the submesh is intersecting with the frustum
  79524. */
  79525. isInFrustum(frustumPlanes: Plane[]): boolean;
  79526. /**
  79527. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  79528. * @param frustumPlanes defines the frustum planes
  79529. * @returns true if the submesh is inside the frustum
  79530. */
  79531. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  79532. /**
  79533. * Renders the submesh
  79534. * @param enableAlphaMode defines if alpha needs to be used
  79535. * @returns the submesh
  79536. */
  79537. render(enableAlphaMode: boolean): SubMesh;
  79538. /**
  79539. * @hidden
  79540. */
  79541. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  79542. /**
  79543. * Checks if the submesh intersects with a ray
  79544. * @param ray defines the ray to test
  79545. * @returns true is the passed ray intersects the submesh bounding box
  79546. */
  79547. canIntersects(ray: Ray): boolean;
  79548. /**
  79549. * Intersects current submesh with a ray
  79550. * @param ray defines the ray to test
  79551. * @param positions defines mesh's positions array
  79552. * @param indices defines mesh's indices array
  79553. * @param fastCheck defines if only bounding info should be used
  79554. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  79555. * @returns intersection info or null if no intersection
  79556. */
  79557. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  79558. /** @hidden */
  79559. private _intersectLines;
  79560. /** @hidden */
  79561. private _intersectTriangles;
  79562. /** @hidden */
  79563. _rebuild(): void;
  79564. /**
  79565. * Creates a new submesh from the passed mesh
  79566. * @param newMesh defines the new hosting mesh
  79567. * @param newRenderingMesh defines an optional rendering mesh
  79568. * @returns the new submesh
  79569. */
  79570. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  79571. /**
  79572. * Release associated resources
  79573. */
  79574. dispose(): void;
  79575. /**
  79576. * Gets the class name
  79577. * @returns the string "SubMesh".
  79578. */
  79579. getClassName(): string;
  79580. /**
  79581. * Creates a new submesh from indices data
  79582. * @param materialIndex the index of the main mesh material
  79583. * @param startIndex the index where to start the copy in the mesh indices array
  79584. * @param indexCount the number of indices to copy then from the startIndex
  79585. * @param mesh the main mesh to create the submesh from
  79586. * @param renderingMesh the optional rendering mesh
  79587. * @returns a new submesh
  79588. */
  79589. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  79590. }
  79591. }
  79592. declare module BABYLON {
  79593. /**
  79594. * Class used to store geometry data (vertex buffers + index buffer)
  79595. */
  79596. export class Geometry implements IGetSetVerticesData {
  79597. /**
  79598. * Gets or sets the ID of the geometry
  79599. */
  79600. id: string;
  79601. /**
  79602. * Gets or sets the unique ID of the geometry
  79603. */
  79604. uniqueId: number;
  79605. /**
  79606. * Gets the delay loading state of the geometry (none by default which means not delayed)
  79607. */
  79608. delayLoadState: number;
  79609. /**
  79610. * Gets the file containing the data to load when running in delay load state
  79611. */
  79612. delayLoadingFile: Nullable<string>;
  79613. /**
  79614. * Callback called when the geometry is updated
  79615. */
  79616. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  79617. private _scene;
  79618. private _engine;
  79619. private _meshes;
  79620. private _totalVertices;
  79621. /** @hidden */
  79622. _indices: IndicesArray;
  79623. /** @hidden */
  79624. _vertexBuffers: {
  79625. [key: string]: VertexBuffer;
  79626. };
  79627. private _isDisposed;
  79628. private _extend;
  79629. private _boundingBias;
  79630. /** @hidden */
  79631. _delayInfo: Array<string>;
  79632. private _indexBuffer;
  79633. private _indexBufferIsUpdatable;
  79634. /** @hidden */
  79635. _boundingInfo: Nullable<BoundingInfo>;
  79636. /** @hidden */
  79637. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  79638. /** @hidden */
  79639. _softwareSkinningFrameId: number;
  79640. private _vertexArrayObjects;
  79641. private _updatable;
  79642. /** @hidden */
  79643. _positions: Nullable<Vector3[]>;
  79644. /**
  79645. * 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
  79646. */
  79647. /**
  79648. * 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
  79649. */
  79650. boundingBias: Vector2;
  79651. /**
  79652. * Static function used to attach a new empty geometry to a mesh
  79653. * @param mesh defines the mesh to attach the geometry to
  79654. * @returns the new Geometry
  79655. */
  79656. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  79657. /**
  79658. * Creates a new geometry
  79659. * @param id defines the unique ID
  79660. * @param scene defines the hosting scene
  79661. * @param vertexData defines the VertexData used to get geometry data
  79662. * @param updatable defines if geometry must be updatable (false by default)
  79663. * @param mesh defines the mesh that will be associated with the geometry
  79664. */
  79665. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  79666. /**
  79667. * Gets the current extend of the geometry
  79668. */
  79669. readonly extend: {
  79670. minimum: Vector3;
  79671. maximum: Vector3;
  79672. };
  79673. /**
  79674. * Gets the hosting scene
  79675. * @returns the hosting Scene
  79676. */
  79677. getScene(): Scene;
  79678. /**
  79679. * Gets the hosting engine
  79680. * @returns the hosting Engine
  79681. */
  79682. getEngine(): Engine;
  79683. /**
  79684. * Defines if the geometry is ready to use
  79685. * @returns true if the geometry is ready to be used
  79686. */
  79687. isReady(): boolean;
  79688. /**
  79689. * Gets a value indicating that the geometry should not be serialized
  79690. */
  79691. readonly doNotSerialize: boolean;
  79692. /** @hidden */
  79693. _rebuild(): void;
  79694. /**
  79695. * Affects all geometry data in one call
  79696. * @param vertexData defines the geometry data
  79697. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  79698. */
  79699. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  79700. /**
  79701. * Set specific vertex data
  79702. * @param kind defines the data kind (Position, normal, etc...)
  79703. * @param data defines the vertex data to use
  79704. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  79705. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  79706. */
  79707. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  79708. /**
  79709. * Removes a specific vertex data
  79710. * @param kind defines the data kind (Position, normal, etc...)
  79711. */
  79712. removeVerticesData(kind: string): void;
  79713. /**
  79714. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  79715. * @param buffer defines the vertex buffer to use
  79716. * @param totalVertices defines the total number of vertices for position kind (could be null)
  79717. */
  79718. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  79719. /**
  79720. * Update a specific vertex buffer
  79721. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  79722. * It will do nothing if the buffer is not updatable
  79723. * @param kind defines the data kind (Position, normal, etc...)
  79724. * @param data defines the data to use
  79725. * @param offset defines the offset in the target buffer where to store the data
  79726. * @param useBytes set to true if the offset is in bytes
  79727. */
  79728. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  79729. /**
  79730. * Update a specific vertex buffer
  79731. * This function will create a new buffer if the current one is not updatable
  79732. * @param kind defines the data kind (Position, normal, etc...)
  79733. * @param data defines the data to use
  79734. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  79735. */
  79736. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  79737. private _updateBoundingInfo;
  79738. /** @hidden */
  79739. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  79740. /**
  79741. * Gets total number of vertices
  79742. * @returns the total number of vertices
  79743. */
  79744. getTotalVertices(): number;
  79745. /**
  79746. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  79747. * @param kind defines the data kind (Position, normal, etc...)
  79748. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  79749. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79750. * @returns a float array containing vertex data
  79751. */
  79752. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  79753. /**
  79754. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  79755. * @param kind defines the data kind (Position, normal, etc...)
  79756. * @returns true if the vertex buffer with the specified kind is updatable
  79757. */
  79758. isVertexBufferUpdatable(kind: string): boolean;
  79759. /**
  79760. * Gets a specific vertex buffer
  79761. * @param kind defines the data kind (Position, normal, etc...)
  79762. * @returns a VertexBuffer
  79763. */
  79764. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  79765. /**
  79766. * Returns all vertex buffers
  79767. * @return an object holding all vertex buffers indexed by kind
  79768. */
  79769. getVertexBuffers(): Nullable<{
  79770. [key: string]: VertexBuffer;
  79771. }>;
  79772. /**
  79773. * Gets a boolean indicating if specific vertex buffer is present
  79774. * @param kind defines the data kind (Position, normal, etc...)
  79775. * @returns true if data is present
  79776. */
  79777. isVerticesDataPresent(kind: string): boolean;
  79778. /**
  79779. * Gets a list of all attached data kinds (Position, normal, etc...)
  79780. * @returns a list of string containing all kinds
  79781. */
  79782. getVerticesDataKinds(): string[];
  79783. /**
  79784. * Update index buffer
  79785. * @param indices defines the indices to store in the index buffer
  79786. * @param offset defines the offset in the target buffer where to store the data
  79787. * @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)
  79788. */
  79789. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  79790. /**
  79791. * Creates a new index buffer
  79792. * @param indices defines the indices to store in the index buffer
  79793. * @param totalVertices defines the total number of vertices (could be null)
  79794. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  79795. */
  79796. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  79797. /**
  79798. * Return the total number of indices
  79799. * @returns the total number of indices
  79800. */
  79801. getTotalIndices(): number;
  79802. /**
  79803. * Gets the index buffer array
  79804. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  79805. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79806. * @returns the index buffer array
  79807. */
  79808. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  79809. /**
  79810. * Gets the index buffer
  79811. * @return the index buffer
  79812. */
  79813. getIndexBuffer(): Nullable<WebGLBuffer>;
  79814. /** @hidden */
  79815. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  79816. /**
  79817. * Release the associated resources for a specific mesh
  79818. * @param mesh defines the source mesh
  79819. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  79820. */
  79821. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  79822. /**
  79823. * Apply current geometry to a given mesh
  79824. * @param mesh defines the mesh to apply geometry to
  79825. */
  79826. applyToMesh(mesh: Mesh): void;
  79827. private _updateExtend;
  79828. private _applyToMesh;
  79829. private notifyUpdate;
  79830. /**
  79831. * Load the geometry if it was flagged as delay loaded
  79832. * @param scene defines the hosting scene
  79833. * @param onLoaded defines a callback called when the geometry is loaded
  79834. */
  79835. load(scene: Scene, onLoaded?: () => void): void;
  79836. private _queueLoad;
  79837. /**
  79838. * Invert the geometry to move from a right handed system to a left handed one.
  79839. */
  79840. toLeftHanded(): void;
  79841. /** @hidden */
  79842. _resetPointsArrayCache(): void;
  79843. /** @hidden */
  79844. _generatePointsArray(): boolean;
  79845. /**
  79846. * Gets a value indicating if the geometry is disposed
  79847. * @returns true if the geometry was disposed
  79848. */
  79849. isDisposed(): boolean;
  79850. private _disposeVertexArrayObjects;
  79851. /**
  79852. * Free all associated resources
  79853. */
  79854. dispose(): void;
  79855. /**
  79856. * Clone the current geometry into a new geometry
  79857. * @param id defines the unique ID of the new geometry
  79858. * @returns a new geometry object
  79859. */
  79860. copy(id: string): Geometry;
  79861. /**
  79862. * Serialize the current geometry info (and not the vertices data) into a JSON object
  79863. * @return a JSON representation of the current geometry data (without the vertices data)
  79864. */
  79865. serialize(): any;
  79866. private toNumberArray;
  79867. /**
  79868. * Serialize all vertices data into a JSON oject
  79869. * @returns a JSON representation of the current geometry data
  79870. */
  79871. serializeVerticeData(): any;
  79872. /**
  79873. * Extracts a clone of a mesh geometry
  79874. * @param mesh defines the source mesh
  79875. * @param id defines the unique ID of the new geometry object
  79876. * @returns the new geometry object
  79877. */
  79878. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  79879. /**
  79880. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  79881. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  79882. * Be aware Math.random() could cause collisions, but:
  79883. * "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"
  79884. * @returns a string containing a new GUID
  79885. */
  79886. static RandomId(): string;
  79887. /** @hidden */
  79888. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  79889. private static _CleanMatricesWeights;
  79890. /**
  79891. * Create a new geometry from persisted data (Using .babylon file format)
  79892. * @param parsedVertexData defines the persisted data
  79893. * @param scene defines the hosting scene
  79894. * @param rootUrl defines the root url to use to load assets (like delayed data)
  79895. * @returns the new geometry object
  79896. */
  79897. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  79898. }
  79899. }
  79900. declare module BABYLON {
  79901. /**
  79902. * Define an interface for all classes that will get and set the data on vertices
  79903. */
  79904. export interface IGetSetVerticesData {
  79905. /**
  79906. * Gets a boolean indicating if specific vertex data is present
  79907. * @param kind defines the vertex data kind to use
  79908. * @returns true is data kind is present
  79909. */
  79910. isVerticesDataPresent(kind: string): boolean;
  79911. /**
  79912. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  79913. * @param kind defines the data kind (Position, normal, etc...)
  79914. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  79915. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79916. * @returns a float array containing vertex data
  79917. */
  79918. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  79919. /**
  79920. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  79921. * @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.
  79922. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79923. * @returns the indices array or an empty array if the mesh has no geometry
  79924. */
  79925. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  79926. /**
  79927. * Set specific vertex data
  79928. * @param kind defines the data kind (Position, normal, etc...)
  79929. * @param data defines the vertex data to use
  79930. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  79931. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  79932. */
  79933. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  79934. /**
  79935. * Update a specific associated vertex buffer
  79936. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  79937. * - VertexBuffer.PositionKind
  79938. * - VertexBuffer.UVKind
  79939. * - VertexBuffer.UV2Kind
  79940. * - VertexBuffer.UV3Kind
  79941. * - VertexBuffer.UV4Kind
  79942. * - VertexBuffer.UV5Kind
  79943. * - VertexBuffer.UV6Kind
  79944. * - VertexBuffer.ColorKind
  79945. * - VertexBuffer.MatricesIndicesKind
  79946. * - VertexBuffer.MatricesIndicesExtraKind
  79947. * - VertexBuffer.MatricesWeightsKind
  79948. * - VertexBuffer.MatricesWeightsExtraKind
  79949. * @param data defines the data source
  79950. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  79951. * @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)
  79952. */
  79953. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  79954. /**
  79955. * Creates a new index buffer
  79956. * @param indices defines the indices to store in the index buffer
  79957. * @param totalVertices defines the total number of vertices (could be null)
  79958. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  79959. */
  79960. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  79961. }
  79962. /**
  79963. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  79964. */
  79965. export class VertexData {
  79966. /**
  79967. * Mesh side orientation : usually the external or front surface
  79968. */
  79969. static readonly FRONTSIDE: number;
  79970. /**
  79971. * Mesh side orientation : usually the internal or back surface
  79972. */
  79973. static readonly BACKSIDE: number;
  79974. /**
  79975. * Mesh side orientation : both internal and external or front and back surfaces
  79976. */
  79977. static readonly DOUBLESIDE: number;
  79978. /**
  79979. * Mesh side orientation : by default, `FRONTSIDE`
  79980. */
  79981. static readonly DEFAULTSIDE: number;
  79982. /**
  79983. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  79984. */
  79985. positions: Nullable<FloatArray>;
  79986. /**
  79987. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  79988. */
  79989. normals: Nullable<FloatArray>;
  79990. /**
  79991. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  79992. */
  79993. tangents: Nullable<FloatArray>;
  79994. /**
  79995. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79996. */
  79997. uvs: Nullable<FloatArray>;
  79998. /**
  79999. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  80000. */
  80001. uvs2: Nullable<FloatArray>;
  80002. /**
  80003. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  80004. */
  80005. uvs3: Nullable<FloatArray>;
  80006. /**
  80007. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  80008. */
  80009. uvs4: Nullable<FloatArray>;
  80010. /**
  80011. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  80012. */
  80013. uvs5: Nullable<FloatArray>;
  80014. /**
  80015. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  80016. */
  80017. uvs6: Nullable<FloatArray>;
  80018. /**
  80019. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  80020. */
  80021. colors: Nullable<FloatArray>;
  80022. /**
  80023. * 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).
  80024. */
  80025. matricesIndices: Nullable<FloatArray>;
  80026. /**
  80027. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  80028. */
  80029. matricesWeights: Nullable<FloatArray>;
  80030. /**
  80031. * An array extending the number of possible indices
  80032. */
  80033. matricesIndicesExtra: Nullable<FloatArray>;
  80034. /**
  80035. * An array extending the number of possible weights when the number of indices is extended
  80036. */
  80037. matricesWeightsExtra: Nullable<FloatArray>;
  80038. /**
  80039. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  80040. */
  80041. indices: Nullable<IndicesArray>;
  80042. /**
  80043. * Uses the passed data array to set the set the values for the specified kind of data
  80044. * @param data a linear array of floating numbers
  80045. * @param kind the type of data that is being set, eg positions, colors etc
  80046. */
  80047. set(data: FloatArray, kind: string): void;
  80048. /**
  80049. * Associates the vertexData to the passed Mesh.
  80050. * Sets it as updatable or not (default `false`)
  80051. * @param mesh the mesh the vertexData is applied to
  80052. * @param updatable when used and having the value true allows new data to update the vertexData
  80053. * @returns the VertexData
  80054. */
  80055. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  80056. /**
  80057. * Associates the vertexData to the passed Geometry.
  80058. * Sets it as updatable or not (default `false`)
  80059. * @param geometry the geometry the vertexData is applied to
  80060. * @param updatable when used and having the value true allows new data to update the vertexData
  80061. * @returns VertexData
  80062. */
  80063. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  80064. /**
  80065. * Updates the associated mesh
  80066. * @param mesh the mesh to be updated
  80067. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  80068. * @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
  80069. * @returns VertexData
  80070. */
  80071. updateMesh(mesh: Mesh): VertexData;
  80072. /**
  80073. * Updates the associated geometry
  80074. * @param geometry the geometry to be updated
  80075. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  80076. * @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
  80077. * @returns VertexData.
  80078. */
  80079. updateGeometry(geometry: Geometry): VertexData;
  80080. private _applyTo;
  80081. private _update;
  80082. /**
  80083. * Transforms each position and each normal of the vertexData according to the passed Matrix
  80084. * @param matrix the transforming matrix
  80085. * @returns the VertexData
  80086. */
  80087. transform(matrix: Matrix): VertexData;
  80088. /**
  80089. * Merges the passed VertexData into the current one
  80090. * @param other the VertexData to be merged into the current one
  80091. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  80092. * @returns the modified VertexData
  80093. */
  80094. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  80095. private _mergeElement;
  80096. private _validate;
  80097. /**
  80098. * Serializes the VertexData
  80099. * @returns a serialized object
  80100. */
  80101. serialize(): any;
  80102. /**
  80103. * Extracts the vertexData from a mesh
  80104. * @param mesh the mesh from which to extract the VertexData
  80105. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  80106. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  80107. * @returns the object VertexData associated to the passed mesh
  80108. */
  80109. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  80110. /**
  80111. * Extracts the vertexData from the geometry
  80112. * @param geometry the geometry from which to extract the VertexData
  80113. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  80114. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  80115. * @returns the object VertexData associated to the passed mesh
  80116. */
  80117. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  80118. private static _ExtractFrom;
  80119. /**
  80120. * Creates the VertexData for a Ribbon
  80121. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  80122. * * pathArray array of paths, each of which an array of successive Vector3
  80123. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  80124. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  80125. * * 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
  80126. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80127. * * 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)
  80128. * * 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)
  80129. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  80130. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  80131. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  80132. * @returns the VertexData of the ribbon
  80133. */
  80134. static CreateRibbon(options: {
  80135. pathArray: Vector3[][];
  80136. closeArray?: boolean;
  80137. closePath?: boolean;
  80138. offset?: number;
  80139. sideOrientation?: number;
  80140. frontUVs?: Vector4;
  80141. backUVs?: Vector4;
  80142. invertUV?: boolean;
  80143. uvs?: Vector2[];
  80144. colors?: Color4[];
  80145. }): VertexData;
  80146. /**
  80147. * Creates the VertexData for a box
  80148. * @param options an object used to set the following optional parameters for the box, required but can be empty
  80149. * * size sets the width, height and depth of the box to the value of size, optional default 1
  80150. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  80151. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  80152. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  80153. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  80154. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  80155. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80156. * * 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)
  80157. * * 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)
  80158. * @returns the VertexData of the box
  80159. */
  80160. static CreateBox(options: {
  80161. size?: number;
  80162. width?: number;
  80163. height?: number;
  80164. depth?: number;
  80165. faceUV?: Vector4[];
  80166. faceColors?: Color4[];
  80167. sideOrientation?: number;
  80168. frontUVs?: Vector4;
  80169. backUVs?: Vector4;
  80170. }): VertexData;
  80171. /**
  80172. * Creates the VertexData for an ellipsoid, defaults to a sphere
  80173. * @param options an object used to set the following optional parameters for the box, required but can be empty
  80174. * * segments sets the number of horizontal strips optional, default 32
  80175. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  80176. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  80177. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  80178. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  80179. * * 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
  80180. * * 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
  80181. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80182. * * 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)
  80183. * * 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)
  80184. * @returns the VertexData of the ellipsoid
  80185. */
  80186. static CreateSphere(options: {
  80187. segments?: number;
  80188. diameter?: number;
  80189. diameterX?: number;
  80190. diameterY?: number;
  80191. diameterZ?: number;
  80192. arc?: number;
  80193. slice?: number;
  80194. sideOrientation?: number;
  80195. frontUVs?: Vector4;
  80196. backUVs?: Vector4;
  80197. }): VertexData;
  80198. /**
  80199. * Creates the VertexData for a cylinder, cone or prism
  80200. * @param options an object used to set the following optional parameters for the box, required but can be empty
  80201. * * height sets the height (y direction) of the cylinder, optional, default 2
  80202. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  80203. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  80204. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  80205. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  80206. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  80207. * * 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
  80208. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  80209. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  80210. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  80211. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  80212. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80213. * * 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)
  80214. * * 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)
  80215. * @returns the VertexData of the cylinder, cone or prism
  80216. */
  80217. static CreateCylinder(options: {
  80218. height?: number;
  80219. diameterTop?: number;
  80220. diameterBottom?: number;
  80221. diameter?: number;
  80222. tessellation?: number;
  80223. subdivisions?: number;
  80224. arc?: number;
  80225. faceColors?: Color4[];
  80226. faceUV?: Vector4[];
  80227. hasRings?: boolean;
  80228. enclose?: boolean;
  80229. sideOrientation?: number;
  80230. frontUVs?: Vector4;
  80231. backUVs?: Vector4;
  80232. }): VertexData;
  80233. /**
  80234. * Creates the VertexData for a torus
  80235. * @param options an object used to set the following optional parameters for the box, required but can be empty
  80236. * * diameter the diameter of the torus, optional default 1
  80237. * * thickness the diameter of the tube forming the torus, optional default 0.5
  80238. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  80239. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80240. * * 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)
  80241. * * 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)
  80242. * @returns the VertexData of the torus
  80243. */
  80244. static CreateTorus(options: {
  80245. diameter?: number;
  80246. thickness?: number;
  80247. tessellation?: number;
  80248. sideOrientation?: number;
  80249. frontUVs?: Vector4;
  80250. backUVs?: Vector4;
  80251. }): VertexData;
  80252. /**
  80253. * Creates the VertexData of the LineSystem
  80254. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  80255. * - lines an array of lines, each line being an array of successive Vector3
  80256. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  80257. * @returns the VertexData of the LineSystem
  80258. */
  80259. static CreateLineSystem(options: {
  80260. lines: Vector3[][];
  80261. colors?: Nullable<Color4[][]>;
  80262. }): VertexData;
  80263. /**
  80264. * Create the VertexData for a DashedLines
  80265. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  80266. * - points an array successive Vector3
  80267. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  80268. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  80269. * - dashNb the intended total number of dashes, optional, default 200
  80270. * @returns the VertexData for the DashedLines
  80271. */
  80272. static CreateDashedLines(options: {
  80273. points: Vector3[];
  80274. dashSize?: number;
  80275. gapSize?: number;
  80276. dashNb?: number;
  80277. }): VertexData;
  80278. /**
  80279. * Creates the VertexData for a Ground
  80280. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  80281. * - width the width (x direction) of the ground, optional, default 1
  80282. * - height the height (z direction) of the ground, optional, default 1
  80283. * - subdivisions the number of subdivisions per side, optional, default 1
  80284. * @returns the VertexData of the Ground
  80285. */
  80286. static CreateGround(options: {
  80287. width?: number;
  80288. height?: number;
  80289. subdivisions?: number;
  80290. subdivisionsX?: number;
  80291. subdivisionsY?: number;
  80292. }): VertexData;
  80293. /**
  80294. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  80295. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  80296. * * xmin the ground minimum X coordinate, optional, default -1
  80297. * * zmin the ground minimum Z coordinate, optional, default -1
  80298. * * xmax the ground maximum X coordinate, optional, default 1
  80299. * * zmax the ground maximum Z coordinate, optional, default 1
  80300. * * 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}
  80301. * * 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}
  80302. * @returns the VertexData of the TiledGround
  80303. */
  80304. static CreateTiledGround(options: {
  80305. xmin: number;
  80306. zmin: number;
  80307. xmax: number;
  80308. zmax: number;
  80309. subdivisions?: {
  80310. w: number;
  80311. h: number;
  80312. };
  80313. precision?: {
  80314. w: number;
  80315. h: number;
  80316. };
  80317. }): VertexData;
  80318. /**
  80319. * Creates the VertexData of the Ground designed from a heightmap
  80320. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  80321. * * width the width (x direction) of the ground
  80322. * * height the height (z direction) of the ground
  80323. * * subdivisions the number of subdivisions per side
  80324. * * minHeight the minimum altitude on the ground, optional, default 0
  80325. * * maxHeight the maximum altitude on the ground, optional default 1
  80326. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  80327. * * buffer the array holding the image color data
  80328. * * bufferWidth the width of image
  80329. * * bufferHeight the height of image
  80330. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  80331. * @returns the VertexData of the Ground designed from a heightmap
  80332. */
  80333. static CreateGroundFromHeightMap(options: {
  80334. width: number;
  80335. height: number;
  80336. subdivisions: number;
  80337. minHeight: number;
  80338. maxHeight: number;
  80339. colorFilter: Color3;
  80340. buffer: Uint8Array;
  80341. bufferWidth: number;
  80342. bufferHeight: number;
  80343. alphaFilter: number;
  80344. }): VertexData;
  80345. /**
  80346. * Creates the VertexData for a Plane
  80347. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  80348. * * size sets the width and height of the plane to the value of size, optional default 1
  80349. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  80350. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  80351. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80352. * * 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)
  80353. * * 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)
  80354. * @returns the VertexData of the box
  80355. */
  80356. static CreatePlane(options: {
  80357. size?: number;
  80358. width?: number;
  80359. height?: number;
  80360. sideOrientation?: number;
  80361. frontUVs?: Vector4;
  80362. backUVs?: Vector4;
  80363. }): VertexData;
  80364. /**
  80365. * Creates the VertexData of the Disc or regular Polygon
  80366. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  80367. * * radius the radius of the disc, optional default 0.5
  80368. * * tessellation the number of polygon sides, optional, default 64
  80369. * * 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
  80370. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80371. * * 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)
  80372. * * 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)
  80373. * @returns the VertexData of the box
  80374. */
  80375. static CreateDisc(options: {
  80376. radius?: number;
  80377. tessellation?: number;
  80378. arc?: number;
  80379. sideOrientation?: number;
  80380. frontUVs?: Vector4;
  80381. backUVs?: Vector4;
  80382. }): VertexData;
  80383. /**
  80384. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  80385. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  80386. * @param polygon a mesh built from polygonTriangulation.build()
  80387. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80388. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  80389. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  80390. * @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)
  80391. * @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)
  80392. * @returns the VertexData of the Polygon
  80393. */
  80394. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  80395. /**
  80396. * Creates the VertexData of the IcoSphere
  80397. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  80398. * * radius the radius of the IcoSphere, optional default 1
  80399. * * radiusX allows stretching in the x direction, optional, default radius
  80400. * * radiusY allows stretching in the y direction, optional, default radius
  80401. * * radiusZ allows stretching in the z direction, optional, default radius
  80402. * * flat when true creates a flat shaded mesh, optional, default true
  80403. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  80404. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80405. * * 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)
  80406. * * 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)
  80407. * @returns the VertexData of the IcoSphere
  80408. */
  80409. static CreateIcoSphere(options: {
  80410. radius?: number;
  80411. radiusX?: number;
  80412. radiusY?: number;
  80413. radiusZ?: number;
  80414. flat?: boolean;
  80415. subdivisions?: number;
  80416. sideOrientation?: number;
  80417. frontUVs?: Vector4;
  80418. backUVs?: Vector4;
  80419. }): VertexData;
  80420. /**
  80421. * Creates the VertexData for a Polyhedron
  80422. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  80423. * * type provided types are:
  80424. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  80425. * * 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)
  80426. * * size the size of the IcoSphere, optional default 1
  80427. * * sizeX allows stretching in the x direction, optional, default size
  80428. * * sizeY allows stretching in the y direction, optional, default size
  80429. * * sizeZ allows stretching in the z direction, optional, default size
  80430. * * 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
  80431. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  80432. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  80433. * * flat when true creates a flat shaded mesh, optional, default true
  80434. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  80435. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80436. * * 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)
  80437. * * 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)
  80438. * @returns the VertexData of the Polyhedron
  80439. */
  80440. static CreatePolyhedron(options: {
  80441. type?: number;
  80442. size?: number;
  80443. sizeX?: number;
  80444. sizeY?: number;
  80445. sizeZ?: number;
  80446. custom?: any;
  80447. faceUV?: Vector4[];
  80448. faceColors?: Color4[];
  80449. flat?: boolean;
  80450. sideOrientation?: number;
  80451. frontUVs?: Vector4;
  80452. backUVs?: Vector4;
  80453. }): VertexData;
  80454. /**
  80455. * Creates the VertexData for a TorusKnot
  80456. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  80457. * * radius the radius of the torus knot, optional, default 2
  80458. * * tube the thickness of the tube, optional, default 0.5
  80459. * * radialSegments the number of sides on each tube segments, optional, default 32
  80460. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  80461. * * p the number of windings around the z axis, optional, default 2
  80462. * * q the number of windings around the x axis, optional, default 3
  80463. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80464. * * 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)
  80465. * * 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)
  80466. * @returns the VertexData of the Torus Knot
  80467. */
  80468. static CreateTorusKnot(options: {
  80469. radius?: number;
  80470. tube?: number;
  80471. radialSegments?: number;
  80472. tubularSegments?: number;
  80473. p?: number;
  80474. q?: number;
  80475. sideOrientation?: number;
  80476. frontUVs?: Vector4;
  80477. backUVs?: Vector4;
  80478. }): VertexData;
  80479. /**
  80480. * Compute normals for given positions and indices
  80481. * @param positions an array of vertex positions, [...., x, y, z, ......]
  80482. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  80483. * @param normals an array of vertex normals, [...., x, y, z, ......]
  80484. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  80485. * * facetNormals : optional array of facet normals (vector3)
  80486. * * facetPositions : optional array of facet positions (vector3)
  80487. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  80488. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  80489. * * bInfo : optional bounding info, required for facetPartitioning computation
  80490. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  80491. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  80492. * * useRightHandedSystem: optional boolean to for right handed system computation
  80493. * * depthSort : optional boolean to enable the facet depth sort computation
  80494. * * distanceTo : optional Vector3 to compute the facet depth from this location
  80495. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  80496. */
  80497. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  80498. facetNormals?: any;
  80499. facetPositions?: any;
  80500. facetPartitioning?: any;
  80501. ratio?: number;
  80502. bInfo?: any;
  80503. bbSize?: Vector3;
  80504. subDiv?: any;
  80505. useRightHandedSystem?: boolean;
  80506. depthSort?: boolean;
  80507. distanceTo?: Vector3;
  80508. depthSortedFacets?: any;
  80509. }): void;
  80510. /** @hidden */
  80511. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  80512. /**
  80513. * Applies VertexData created from the imported parameters to the geometry
  80514. * @param parsedVertexData the parsed data from an imported file
  80515. * @param geometry the geometry to apply the VertexData to
  80516. */
  80517. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  80518. }
  80519. }
  80520. declare module BABYLON {
  80521. /**
  80522. * Class containing static functions to help procedurally build meshes
  80523. */
  80524. export class DiscBuilder {
  80525. /**
  80526. * Creates a plane polygonal mesh. By default, this is a disc
  80527. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  80528. * * 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
  80529. * * 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
  80530. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  80531. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  80532. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80533. * @param name defines the name of the mesh
  80534. * @param options defines the options used to create the mesh
  80535. * @param scene defines the hosting scene
  80536. * @returns the plane polygonal mesh
  80537. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  80538. */
  80539. static CreateDisc(name: string, options: {
  80540. radius?: number;
  80541. tessellation?: number;
  80542. arc?: number;
  80543. updatable?: boolean;
  80544. sideOrientation?: number;
  80545. frontUVs?: Vector4;
  80546. backUVs?: Vector4;
  80547. }, scene?: Nullable<Scene>): Mesh;
  80548. }
  80549. }
  80550. declare module BABYLON {
  80551. /**
  80552. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  80553. *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.
  80554. * The SPS is also a particle system. It provides some methods to manage the particles.
  80555. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  80556. *
  80557. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  80558. */
  80559. export class SolidParticleSystem implements IDisposable {
  80560. /**
  80561. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  80562. * Example : var p = SPS.particles[i];
  80563. */
  80564. particles: SolidParticle[];
  80565. /**
  80566. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  80567. */
  80568. nbParticles: number;
  80569. /**
  80570. * If the particles must ever face the camera (default false). Useful for planar particles.
  80571. */
  80572. billboard: boolean;
  80573. /**
  80574. * Recompute normals when adding a shape
  80575. */
  80576. recomputeNormals: boolean;
  80577. /**
  80578. * This a counter ofr your own usage. It's not set by any SPS functions.
  80579. */
  80580. counter: number;
  80581. /**
  80582. * The SPS name. This name is also given to the underlying mesh.
  80583. */
  80584. name: string;
  80585. /**
  80586. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  80587. */
  80588. mesh: Mesh;
  80589. /**
  80590. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  80591. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  80592. */
  80593. vars: any;
  80594. /**
  80595. * This array is populated when the SPS is set as 'pickable'.
  80596. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  80597. * Each element of this array is an object `{idx: int, faceId: int}`.
  80598. * `idx` is the picked particle index in the `SPS.particles` array
  80599. * `faceId` is the picked face index counted within this particle.
  80600. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  80601. */
  80602. pickedParticles: {
  80603. idx: number;
  80604. faceId: number;
  80605. }[];
  80606. /**
  80607. * This array is populated when `enableDepthSort` is set to true.
  80608. * Each element of this array is an instance of the class DepthSortedParticle.
  80609. */
  80610. depthSortedParticles: DepthSortedParticle[];
  80611. /**
  80612. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  80613. * @hidden
  80614. */
  80615. _bSphereOnly: boolean;
  80616. /**
  80617. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  80618. * @hidden
  80619. */
  80620. _bSphereRadiusFactor: number;
  80621. private _scene;
  80622. private _positions;
  80623. private _indices;
  80624. private _normals;
  80625. private _colors;
  80626. private _uvs;
  80627. private _indices32;
  80628. private _positions32;
  80629. private _normals32;
  80630. private _fixedNormal32;
  80631. private _colors32;
  80632. private _uvs32;
  80633. private _index;
  80634. private _updatable;
  80635. private _pickable;
  80636. private _isVisibilityBoxLocked;
  80637. private _alwaysVisible;
  80638. private _depthSort;
  80639. private _shapeCounter;
  80640. private _copy;
  80641. private _color;
  80642. private _computeParticleColor;
  80643. private _computeParticleTexture;
  80644. private _computeParticleRotation;
  80645. private _computeParticleVertex;
  80646. private _computeBoundingBox;
  80647. private _depthSortParticles;
  80648. private _camera;
  80649. private _mustUnrotateFixedNormals;
  80650. private _particlesIntersect;
  80651. private _needs32Bits;
  80652. /**
  80653. * Creates a SPS (Solid Particle System) object.
  80654. * @param name (String) is the SPS name, this will be the underlying mesh name.
  80655. * @param scene (Scene) is the scene in which the SPS is added.
  80656. * @param options defines the options of the sps e.g.
  80657. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  80658. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  80659. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  80660. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  80661. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  80662. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  80663. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  80664. */
  80665. constructor(name: string, scene: Scene, options?: {
  80666. updatable?: boolean;
  80667. isPickable?: boolean;
  80668. enableDepthSort?: boolean;
  80669. particleIntersection?: boolean;
  80670. boundingSphereOnly?: boolean;
  80671. bSphereRadiusFactor?: number;
  80672. });
  80673. /**
  80674. * Builds the SPS underlying mesh. Returns a standard Mesh.
  80675. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  80676. * @returns the created mesh
  80677. */
  80678. buildMesh(): Mesh;
  80679. /**
  80680. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  80681. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  80682. * Thus the particles generated from `digest()` have their property `position` set yet.
  80683. * @param mesh ( Mesh ) is the mesh to be digested
  80684. * @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
  80685. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  80686. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  80687. * @returns the current SPS
  80688. */
  80689. digest(mesh: Mesh, options?: {
  80690. facetNb?: number;
  80691. number?: number;
  80692. delta?: number;
  80693. }): SolidParticleSystem;
  80694. private _unrotateFixedNormals;
  80695. private _resetCopy;
  80696. private _meshBuilder;
  80697. private _posToShape;
  80698. private _uvsToShapeUV;
  80699. private _addParticle;
  80700. /**
  80701. * Adds some particles to the SPS from the model shape. Returns the shape id.
  80702. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  80703. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  80704. * @param nb (positive integer) the number of particles to be created from this model
  80705. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  80706. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  80707. * @returns the number of shapes in the system
  80708. */
  80709. addShape(mesh: Mesh, nb: number, options?: {
  80710. positionFunction?: any;
  80711. vertexFunction?: any;
  80712. }): number;
  80713. private _rebuildParticle;
  80714. /**
  80715. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  80716. * @returns the SPS.
  80717. */
  80718. rebuildMesh(): SolidParticleSystem;
  80719. /**
  80720. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  80721. * This method calls `updateParticle()` for each particle of the SPS.
  80722. * For an animated SPS, it is usually called within the render loop.
  80723. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  80724. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  80725. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  80726. * @returns the SPS.
  80727. */
  80728. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  80729. /**
  80730. * Disposes the SPS.
  80731. */
  80732. dispose(): void;
  80733. /**
  80734. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  80735. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80736. * @returns the SPS.
  80737. */
  80738. refreshVisibleSize(): SolidParticleSystem;
  80739. /**
  80740. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  80741. * @param size the size (float) of the visibility box
  80742. * note : this doesn't lock the SPS mesh bounding box.
  80743. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80744. */
  80745. setVisibilityBox(size: number): void;
  80746. /**
  80747. * Gets whether the SPS as always visible or not
  80748. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80749. */
  80750. /**
  80751. * Sets the SPS as always visible or not
  80752. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80753. */
  80754. isAlwaysVisible: boolean;
  80755. /**
  80756. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  80757. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80758. */
  80759. /**
  80760. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  80761. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80762. */
  80763. isVisibilityBoxLocked: boolean;
  80764. /**
  80765. * Tells to `setParticles()` to compute the particle rotations or not.
  80766. * Default value : true. The SPS is faster when it's set to false.
  80767. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  80768. */
  80769. /**
  80770. * Gets if `setParticles()` computes the particle rotations or not.
  80771. * Default value : true. The SPS is faster when it's set to false.
  80772. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  80773. */
  80774. computeParticleRotation: boolean;
  80775. /**
  80776. * Tells to `setParticles()` to compute the particle colors or not.
  80777. * Default value : true. The SPS is faster when it's set to false.
  80778. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  80779. */
  80780. /**
  80781. * Gets if `setParticles()` computes the particle colors or not.
  80782. * Default value : true. The SPS is faster when it's set to false.
  80783. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  80784. */
  80785. computeParticleColor: boolean;
  80786. /**
  80787. * Gets if `setParticles()` computes the particle textures or not.
  80788. * Default value : true. The SPS is faster when it's set to false.
  80789. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  80790. */
  80791. computeParticleTexture: boolean;
  80792. /**
  80793. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  80794. * Default value : false. The SPS is faster when it's set to false.
  80795. * Note : the particle custom vertex positions aren't stored values.
  80796. */
  80797. /**
  80798. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  80799. * Default value : false. The SPS is faster when it's set to false.
  80800. * Note : the particle custom vertex positions aren't stored values.
  80801. */
  80802. computeParticleVertex: boolean;
  80803. /**
  80804. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  80805. */
  80806. /**
  80807. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  80808. */
  80809. computeBoundingBox: boolean;
  80810. /**
  80811. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  80812. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  80813. * Default : `true`
  80814. */
  80815. /**
  80816. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  80817. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  80818. * Default : `true`
  80819. */
  80820. depthSortParticles: boolean;
  80821. /**
  80822. * This function does nothing. It may be overwritten to set all the particle first values.
  80823. * The SPS doesn't call this function, you may have to call it by your own.
  80824. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  80825. */
  80826. initParticles(): void;
  80827. /**
  80828. * This function does nothing. It may be overwritten to recycle a particle.
  80829. * The SPS doesn't call this function, you may have to call it by your own.
  80830. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  80831. * @param particle The particle to recycle
  80832. * @returns the recycled particle
  80833. */
  80834. recycleParticle(particle: SolidParticle): SolidParticle;
  80835. /**
  80836. * Updates a particle : this function should be overwritten by the user.
  80837. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  80838. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  80839. * @example : just set a particle position or velocity and recycle conditions
  80840. * @param particle The particle to update
  80841. * @returns the updated particle
  80842. */
  80843. updateParticle(particle: SolidParticle): SolidParticle;
  80844. /**
  80845. * Updates a vertex of a particle : it can be overwritten by the user.
  80846. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  80847. * @param particle the current particle
  80848. * @param vertex the current index of the current particle
  80849. * @param pt the index of the current vertex in the particle shape
  80850. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  80851. * @example : just set a vertex particle position
  80852. * @returns the updated vertex
  80853. */
  80854. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  80855. /**
  80856. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  80857. * This does nothing and may be overwritten by the user.
  80858. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80859. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80860. * @param update the boolean update value actually passed to setParticles()
  80861. */
  80862. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  80863. /**
  80864. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  80865. * This will be passed three parameters.
  80866. * This does nothing and may be overwritten by the user.
  80867. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80868. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80869. * @param update the boolean update value actually passed to setParticles()
  80870. */
  80871. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  80872. }
  80873. }
  80874. declare module BABYLON {
  80875. /**
  80876. * Represents one particle of a solid particle system.
  80877. */
  80878. export class SolidParticle {
  80879. /**
  80880. * particle global index
  80881. */
  80882. idx: number;
  80883. /**
  80884. * The color of the particle
  80885. */
  80886. color: Nullable<Color4>;
  80887. /**
  80888. * The world space position of the particle.
  80889. */
  80890. position: Vector3;
  80891. /**
  80892. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  80893. */
  80894. rotation: Vector3;
  80895. /**
  80896. * The world space rotation quaternion of the particle.
  80897. */
  80898. rotationQuaternion: Nullable<Quaternion>;
  80899. /**
  80900. * The scaling of the particle.
  80901. */
  80902. scaling: Vector3;
  80903. /**
  80904. * The uvs of the particle.
  80905. */
  80906. uvs: Vector4;
  80907. /**
  80908. * The current speed of the particle.
  80909. */
  80910. velocity: Vector3;
  80911. /**
  80912. * The pivot point in the particle local space.
  80913. */
  80914. pivot: Vector3;
  80915. /**
  80916. * Must the particle be translated from its pivot point in its local space ?
  80917. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  80918. * Default : false
  80919. */
  80920. translateFromPivot: boolean;
  80921. /**
  80922. * Is the particle active or not ?
  80923. */
  80924. alive: boolean;
  80925. /**
  80926. * Is the particle visible or not ?
  80927. */
  80928. isVisible: boolean;
  80929. /**
  80930. * Index of this particle in the global "positions" array (Internal use)
  80931. * @hidden
  80932. */
  80933. _pos: number;
  80934. /**
  80935. * @hidden Index of this particle in the global "indices" array (Internal use)
  80936. */
  80937. _ind: number;
  80938. /**
  80939. * @hidden ModelShape of this particle (Internal use)
  80940. */
  80941. _model: ModelShape;
  80942. /**
  80943. * ModelShape id of this particle
  80944. */
  80945. shapeId: number;
  80946. /**
  80947. * Index of the particle in its shape id (Internal use)
  80948. */
  80949. idxInShape: number;
  80950. /**
  80951. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  80952. */
  80953. _modelBoundingInfo: BoundingInfo;
  80954. /**
  80955. * @hidden Particle BoundingInfo object (Internal use)
  80956. */
  80957. _boundingInfo: BoundingInfo;
  80958. /**
  80959. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  80960. */
  80961. _sps: SolidParticleSystem;
  80962. /**
  80963. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  80964. */
  80965. _stillInvisible: boolean;
  80966. /**
  80967. * @hidden Last computed particle rotation matrix
  80968. */
  80969. _rotationMatrix: number[];
  80970. /**
  80971. * Parent particle Id, if any.
  80972. * Default null.
  80973. */
  80974. parentId: Nullable<number>;
  80975. /**
  80976. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  80977. * The possible values are :
  80978. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  80979. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  80980. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  80981. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  80982. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  80983. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  80984. * */
  80985. cullingStrategy: number;
  80986. /**
  80987. * @hidden Internal global position in the SPS.
  80988. */
  80989. _globalPosition: Vector3;
  80990. /**
  80991. * Creates a Solid Particle object.
  80992. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  80993. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  80994. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  80995. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  80996. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  80997. * @param shapeId (integer) is the model shape identifier in the SPS.
  80998. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  80999. * @param sps defines the sps it is associated to
  81000. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  81001. */
  81002. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  81003. /**
  81004. * Legacy support, changed scale to scaling
  81005. */
  81006. /**
  81007. * Legacy support, changed scale to scaling
  81008. */
  81009. scale: Vector3;
  81010. /**
  81011. * Legacy support, changed quaternion to rotationQuaternion
  81012. */
  81013. /**
  81014. * Legacy support, changed quaternion to rotationQuaternion
  81015. */
  81016. quaternion: Nullable<Quaternion>;
  81017. /**
  81018. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  81019. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  81020. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  81021. * @returns true if it intersects
  81022. */
  81023. intersectsMesh(target: Mesh | SolidParticle): boolean;
  81024. /**
  81025. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  81026. * A particle is in the frustum if its bounding box intersects the frustum
  81027. * @param frustumPlanes defines the frustum to test
  81028. * @returns true if the particle is in the frustum planes
  81029. */
  81030. isInFrustum(frustumPlanes: Plane[]): boolean;
  81031. /**
  81032. * get the rotation matrix of the particle
  81033. * @hidden
  81034. */
  81035. getRotationMatrix(m: Matrix): void;
  81036. }
  81037. /**
  81038. * Represents the shape of the model used by one particle of a solid particle system.
  81039. * SPS internal tool, don't use it manually.
  81040. */
  81041. export class ModelShape {
  81042. /**
  81043. * The shape id
  81044. * @hidden
  81045. */
  81046. shapeID: number;
  81047. /**
  81048. * flat array of model positions (internal use)
  81049. * @hidden
  81050. */
  81051. _shape: Vector3[];
  81052. /**
  81053. * flat array of model UVs (internal use)
  81054. * @hidden
  81055. */
  81056. _shapeUV: number[];
  81057. /**
  81058. * length of the shape in the model indices array (internal use)
  81059. * @hidden
  81060. */
  81061. _indicesLength: number;
  81062. /**
  81063. * Custom position function (internal use)
  81064. * @hidden
  81065. */
  81066. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  81067. /**
  81068. * Custom vertex function (internal use)
  81069. * @hidden
  81070. */
  81071. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  81072. /**
  81073. * 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.
  81074. * SPS internal tool, don't use it manually.
  81075. * @hidden
  81076. */
  81077. 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>);
  81078. }
  81079. /**
  81080. * Represents a Depth Sorted Particle in the solid particle system.
  81081. */
  81082. export class DepthSortedParticle {
  81083. /**
  81084. * Index of the particle in the "indices" array
  81085. */
  81086. ind: number;
  81087. /**
  81088. * Length of the particle shape in the "indices" array
  81089. */
  81090. indicesLength: number;
  81091. /**
  81092. * Squared distance from the particle to the camera
  81093. */
  81094. sqDistance: number;
  81095. }
  81096. }
  81097. declare module BABYLON {
  81098. /**
  81099. * Class used to store all common mesh properties
  81100. */
  81101. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  81102. /** No occlusion */
  81103. static OCCLUSION_TYPE_NONE: number;
  81104. /** Occlusion set to optimisitic */
  81105. static OCCLUSION_TYPE_OPTIMISTIC: number;
  81106. /** Occlusion set to strict */
  81107. static OCCLUSION_TYPE_STRICT: number;
  81108. /** Use an accurante occlusion algorithm */
  81109. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  81110. /** Use a conservative occlusion algorithm */
  81111. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  81112. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  81113. * Test order :
  81114. * Is the bounding sphere outside the frustum ?
  81115. * If not, are the bounding box vertices outside the frustum ?
  81116. * It not, then the cullable object is in the frustum.
  81117. */
  81118. static readonly CULLINGSTRATEGY_STANDARD: number;
  81119. /** Culling strategy : Bounding Sphere Only.
  81120. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  81121. * It's also less accurate than the standard because some not visible objects can still be selected.
  81122. * Test : is the bounding sphere outside the frustum ?
  81123. * If not, then the cullable object is in the frustum.
  81124. */
  81125. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  81126. /** Culling strategy : Optimistic Inclusion.
  81127. * This in an inclusion test first, then the standard exclusion test.
  81128. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  81129. * 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.
  81130. * Anyway, it's as accurate as the standard strategy.
  81131. * Test :
  81132. * Is the cullable object bounding sphere center in the frustum ?
  81133. * If not, apply the default culling strategy.
  81134. */
  81135. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  81136. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  81137. * This in an inclusion test first, then the bounding sphere only exclusion test.
  81138. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  81139. * 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.
  81140. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  81141. * Test :
  81142. * Is the cullable object bounding sphere center in the frustum ?
  81143. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  81144. */
  81145. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  81146. /**
  81147. * No billboard
  81148. */
  81149. static readonly BILLBOARDMODE_NONE: number;
  81150. /** Billboard on X axis */
  81151. static readonly BILLBOARDMODE_X: number;
  81152. /** Billboard on Y axis */
  81153. static readonly BILLBOARDMODE_Y: number;
  81154. /** Billboard on Z axis */
  81155. static readonly BILLBOARDMODE_Z: number;
  81156. /** Billboard on all axes */
  81157. static readonly BILLBOARDMODE_ALL: number;
  81158. private _facetData;
  81159. /**
  81160. * The culling strategy to use to check whether the mesh must be rendered or not.
  81161. * This value can be changed at any time and will be used on the next render mesh selection.
  81162. * The possible values are :
  81163. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  81164. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  81165. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  81166. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  81167. * Please read each static variable documentation to get details about the culling process.
  81168. * */
  81169. cullingStrategy: number;
  81170. /**
  81171. * Gets the number of facets in the mesh
  81172. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  81173. */
  81174. readonly facetNb: number;
  81175. /**
  81176. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  81177. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  81178. */
  81179. partitioningSubdivisions: number;
  81180. /**
  81181. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  81182. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  81183. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  81184. */
  81185. partitioningBBoxRatio: number;
  81186. /**
  81187. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  81188. * Works only for updatable meshes.
  81189. * Doesn't work with multi-materials
  81190. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  81191. */
  81192. mustDepthSortFacets: boolean;
  81193. /**
  81194. * The location (Vector3) where the facet depth sort must be computed from.
  81195. * By default, the active camera position.
  81196. * Used only when facet depth sort is enabled
  81197. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  81198. */
  81199. facetDepthSortFrom: Vector3;
  81200. /**
  81201. * gets a boolean indicating if facetData is enabled
  81202. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  81203. */
  81204. readonly isFacetDataEnabled: boolean;
  81205. /** @hidden */
  81206. _updateNonUniformScalingState(value: boolean): boolean;
  81207. /**
  81208. * An event triggered when this mesh collides with another one
  81209. */
  81210. onCollideObservable: Observable<AbstractMesh>;
  81211. private _onCollideObserver;
  81212. /** Set a function to call when this mesh collides with another one */
  81213. onCollide: () => void;
  81214. /**
  81215. * An event triggered when the collision's position changes
  81216. */
  81217. onCollisionPositionChangeObservable: Observable<Vector3>;
  81218. private _onCollisionPositionChangeObserver;
  81219. /** Set a function to call when the collision's position changes */
  81220. onCollisionPositionChange: () => void;
  81221. /**
  81222. * An event triggered when material is changed
  81223. */
  81224. onMaterialChangedObservable: Observable<AbstractMesh>;
  81225. /**
  81226. * Gets or sets the orientation for POV movement & rotation
  81227. */
  81228. definedFacingForward: boolean;
  81229. /** @hidden */
  81230. _occlusionQuery: Nullable<WebGLQuery>;
  81231. private _visibility;
  81232. /**
  81233. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  81234. */
  81235. /**
  81236. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  81237. */
  81238. visibility: number;
  81239. /** Gets or sets the alpha index used to sort transparent meshes
  81240. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  81241. */
  81242. alphaIndex: number;
  81243. /**
  81244. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  81245. */
  81246. isVisible: boolean;
  81247. /**
  81248. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  81249. */
  81250. isPickable: boolean;
  81251. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  81252. showSubMeshesBoundingBox: boolean;
  81253. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  81254. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  81255. */
  81256. isBlocker: boolean;
  81257. /**
  81258. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  81259. */
  81260. enablePointerMoveEvents: boolean;
  81261. /**
  81262. * Specifies the rendering group id for this mesh (0 by default)
  81263. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  81264. */
  81265. renderingGroupId: number;
  81266. private _material;
  81267. /** Gets or sets current material */
  81268. material: Nullable<Material>;
  81269. private _receiveShadows;
  81270. /**
  81271. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  81272. * @see http://doc.babylonjs.com/babylon101/shadows
  81273. */
  81274. receiveShadows: boolean;
  81275. /** Defines color to use when rendering outline */
  81276. outlineColor: Color3;
  81277. /** Define width to use when rendering outline */
  81278. outlineWidth: number;
  81279. /** Defines color to use when rendering overlay */
  81280. overlayColor: Color3;
  81281. /** Defines alpha to use when rendering overlay */
  81282. overlayAlpha: number;
  81283. private _hasVertexAlpha;
  81284. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  81285. hasVertexAlpha: boolean;
  81286. private _useVertexColors;
  81287. /** 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) */
  81288. useVertexColors: boolean;
  81289. private _computeBonesUsingShaders;
  81290. /**
  81291. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  81292. */
  81293. computeBonesUsingShaders: boolean;
  81294. private _numBoneInfluencers;
  81295. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  81296. numBoneInfluencers: number;
  81297. private _applyFog;
  81298. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  81299. applyFog: boolean;
  81300. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  81301. useOctreeForRenderingSelection: boolean;
  81302. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  81303. useOctreeForPicking: boolean;
  81304. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  81305. useOctreeForCollisions: boolean;
  81306. private _layerMask;
  81307. /**
  81308. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  81309. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  81310. */
  81311. layerMask: number;
  81312. /**
  81313. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  81314. */
  81315. alwaysSelectAsActiveMesh: boolean;
  81316. /**
  81317. * Gets or sets the current action manager
  81318. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81319. */
  81320. actionManager: Nullable<AbstractActionManager>;
  81321. private _checkCollisions;
  81322. private _collisionMask;
  81323. private _collisionGroup;
  81324. /**
  81325. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  81326. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81327. */
  81328. ellipsoid: Vector3;
  81329. /**
  81330. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  81331. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81332. */
  81333. ellipsoidOffset: Vector3;
  81334. private _collider;
  81335. private _oldPositionForCollisions;
  81336. private _diffPositionForCollisions;
  81337. /**
  81338. * Gets or sets a collision mask used to mask collisions (default is -1).
  81339. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  81340. */
  81341. collisionMask: number;
  81342. /**
  81343. * Gets or sets the current collision group mask (-1 by default).
  81344. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  81345. */
  81346. collisionGroup: number;
  81347. /**
  81348. * Defines edge width used when edgesRenderer is enabled
  81349. * @see https://www.babylonjs-playground.com/#10OJSG#13
  81350. */
  81351. edgesWidth: number;
  81352. /**
  81353. * Defines edge color used when edgesRenderer is enabled
  81354. * @see https://www.babylonjs-playground.com/#10OJSG#13
  81355. */
  81356. edgesColor: Color4;
  81357. /** @hidden */
  81358. _edgesRenderer: Nullable<IEdgesRenderer>;
  81359. /** @hidden */
  81360. _masterMesh: Nullable<AbstractMesh>;
  81361. /** @hidden */
  81362. _boundingInfo: Nullable<BoundingInfo>;
  81363. /** @hidden */
  81364. _renderId: number;
  81365. /**
  81366. * Gets or sets the list of subMeshes
  81367. * @see http://doc.babylonjs.com/how_to/multi_materials
  81368. */
  81369. subMeshes: SubMesh[];
  81370. /** @hidden */
  81371. _intersectionsInProgress: AbstractMesh[];
  81372. /** @hidden */
  81373. _unIndexed: boolean;
  81374. /** @hidden */
  81375. _lightSources: Light[];
  81376. /** @hidden */
  81377. readonly _positions: Nullable<Vector3[]>;
  81378. /** @hidden */
  81379. _waitingActions: any;
  81380. /** @hidden */
  81381. _waitingFreezeWorldMatrix: Nullable<boolean>;
  81382. private _skeleton;
  81383. /** @hidden */
  81384. _bonesTransformMatrices: Nullable<Float32Array>;
  81385. /**
  81386. * Gets or sets a skeleton to apply skining transformations
  81387. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81388. */
  81389. skeleton: Nullable<Skeleton>;
  81390. /**
  81391. * An event triggered when the mesh is rebuilt.
  81392. */
  81393. onRebuildObservable: Observable<AbstractMesh>;
  81394. /**
  81395. * Creates a new AbstractMesh
  81396. * @param name defines the name of the mesh
  81397. * @param scene defines the hosting scene
  81398. */
  81399. constructor(name: string, scene?: Nullable<Scene>);
  81400. /**
  81401. * Returns the string "AbstractMesh"
  81402. * @returns "AbstractMesh"
  81403. */
  81404. getClassName(): string;
  81405. /**
  81406. * Gets a string representation of the current mesh
  81407. * @param fullDetails defines a boolean indicating if full details must be included
  81408. * @returns a string representation of the current mesh
  81409. */
  81410. toString(fullDetails?: boolean): string;
  81411. /** @hidden */
  81412. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  81413. /** @hidden */
  81414. _rebuild(): void;
  81415. /** @hidden */
  81416. _resyncLightSources(): void;
  81417. /** @hidden */
  81418. _resyncLighSource(light: Light): void;
  81419. /** @hidden */
  81420. _unBindEffect(): void;
  81421. /** @hidden */
  81422. _removeLightSource(light: Light): void;
  81423. private _markSubMeshesAsDirty;
  81424. /** @hidden */
  81425. _markSubMeshesAsLightDirty(): void;
  81426. /** @hidden */
  81427. _markSubMeshesAsAttributesDirty(): void;
  81428. /** @hidden */
  81429. _markSubMeshesAsMiscDirty(): void;
  81430. /**
  81431. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  81432. */
  81433. scaling: Vector3;
  81434. /**
  81435. * Returns true if the mesh is blocked. Implemented by child classes
  81436. */
  81437. readonly isBlocked: boolean;
  81438. /**
  81439. * Returns the mesh itself by default. Implemented by child classes
  81440. * @param camera defines the camera to use to pick the right LOD level
  81441. * @returns the currentAbstractMesh
  81442. */
  81443. getLOD(camera: Camera): Nullable<AbstractMesh>;
  81444. /**
  81445. * Returns 0 by default. Implemented by child classes
  81446. * @returns an integer
  81447. */
  81448. getTotalVertices(): number;
  81449. /**
  81450. * Returns a positive integer : the total number of indices in this mesh geometry.
  81451. * @returns the numner of indices or zero if the mesh has no geometry.
  81452. */
  81453. getTotalIndices(): number;
  81454. /**
  81455. * Returns null by default. Implemented by child classes
  81456. * @returns null
  81457. */
  81458. getIndices(): Nullable<IndicesArray>;
  81459. /**
  81460. * Returns the array of the requested vertex data kind. Implemented by child classes
  81461. * @param kind defines the vertex data kind to use
  81462. * @returns null
  81463. */
  81464. getVerticesData(kind: string): Nullable<FloatArray>;
  81465. /**
  81466. * Sets the vertex data of the mesh geometry for the requested `kind`.
  81467. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  81468. * Note that a new underlying VertexBuffer object is created each call.
  81469. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  81470. * @param kind defines vertex data kind:
  81471. * * VertexBuffer.PositionKind
  81472. * * VertexBuffer.UVKind
  81473. * * VertexBuffer.UV2Kind
  81474. * * VertexBuffer.UV3Kind
  81475. * * VertexBuffer.UV4Kind
  81476. * * VertexBuffer.UV5Kind
  81477. * * VertexBuffer.UV6Kind
  81478. * * VertexBuffer.ColorKind
  81479. * * VertexBuffer.MatricesIndicesKind
  81480. * * VertexBuffer.MatricesIndicesExtraKind
  81481. * * VertexBuffer.MatricesWeightsKind
  81482. * * VertexBuffer.MatricesWeightsExtraKind
  81483. * @param data defines the data source
  81484. * @param updatable defines if the data must be flagged as updatable (or static)
  81485. * @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
  81486. * @returns the current mesh
  81487. */
  81488. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  81489. /**
  81490. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  81491. * If the mesh has no geometry, it is simply returned as it is.
  81492. * @param kind defines vertex data kind:
  81493. * * VertexBuffer.PositionKind
  81494. * * VertexBuffer.UVKind
  81495. * * VertexBuffer.UV2Kind
  81496. * * VertexBuffer.UV3Kind
  81497. * * VertexBuffer.UV4Kind
  81498. * * VertexBuffer.UV5Kind
  81499. * * VertexBuffer.UV6Kind
  81500. * * VertexBuffer.ColorKind
  81501. * * VertexBuffer.MatricesIndicesKind
  81502. * * VertexBuffer.MatricesIndicesExtraKind
  81503. * * VertexBuffer.MatricesWeightsKind
  81504. * * VertexBuffer.MatricesWeightsExtraKind
  81505. * @param data defines the data source
  81506. * @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
  81507. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  81508. * @returns the current mesh
  81509. */
  81510. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  81511. /**
  81512. * Sets the mesh indices,
  81513. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  81514. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  81515. * @param totalVertices Defines the total number of vertices
  81516. * @returns the current mesh
  81517. */
  81518. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  81519. /**
  81520. * Gets a boolean indicating if specific vertex data is present
  81521. * @param kind defines the vertex data kind to use
  81522. * @returns true is data kind is present
  81523. */
  81524. isVerticesDataPresent(kind: string): boolean;
  81525. /**
  81526. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  81527. * @returns a BoundingInfo
  81528. */
  81529. getBoundingInfo(): BoundingInfo;
  81530. /**
  81531. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  81532. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  81533. * @returns the current mesh
  81534. */
  81535. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  81536. /**
  81537. * Overwrite the current bounding info
  81538. * @param boundingInfo defines the new bounding info
  81539. * @returns the current mesh
  81540. */
  81541. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  81542. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  81543. readonly useBones: boolean;
  81544. /** @hidden */
  81545. _preActivate(): void;
  81546. /** @hidden */
  81547. _preActivateForIntermediateRendering(renderId: number): void;
  81548. /** @hidden */
  81549. _activate(renderId: number): void;
  81550. /**
  81551. * Gets the current world matrix
  81552. * @returns a Matrix
  81553. */
  81554. getWorldMatrix(): Matrix;
  81555. /** @hidden */
  81556. _getWorldMatrixDeterminant(): number;
  81557. /**
  81558. * Perform relative position change from the point of view of behind the front of the mesh.
  81559. * This is performed taking into account the meshes current rotation, so you do not have to care.
  81560. * Supports definition of mesh facing forward or backward
  81561. * @param amountRight defines the distance on the right axis
  81562. * @param amountUp defines the distance on the up axis
  81563. * @param amountForward defines the distance on the forward axis
  81564. * @returns the current mesh
  81565. */
  81566. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  81567. /**
  81568. * Calculate relative position change from the point of view of behind the front of the mesh.
  81569. * This is performed taking into account the meshes current rotation, so you do not have to care.
  81570. * Supports definition of mesh facing forward or backward
  81571. * @param amountRight defines the distance on the right axis
  81572. * @param amountUp defines the distance on the up axis
  81573. * @param amountForward defines the distance on the forward axis
  81574. * @returns the new displacement vector
  81575. */
  81576. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  81577. /**
  81578. * Perform relative rotation change from the point of view of behind the front of the mesh.
  81579. * Supports definition of mesh facing forward or backward
  81580. * @param flipBack defines the flip
  81581. * @param twirlClockwise defines the twirl
  81582. * @param tiltRight defines the tilt
  81583. * @returns the current mesh
  81584. */
  81585. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  81586. /**
  81587. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  81588. * Supports definition of mesh facing forward or backward.
  81589. * @param flipBack defines the flip
  81590. * @param twirlClockwise defines the twirl
  81591. * @param tiltRight defines the tilt
  81592. * @returns the new rotation vector
  81593. */
  81594. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  81595. /**
  81596. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  81597. * @param includeDescendants Include bounding info from descendants as well (true by default)
  81598. * @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
  81599. * @returns the new bounding vectors
  81600. */
  81601. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  81602. min: Vector3;
  81603. max: Vector3;
  81604. };
  81605. /**
  81606. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  81607. * This means the mesh underlying bounding box and sphere are recomputed.
  81608. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  81609. * @returns the current mesh
  81610. */
  81611. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  81612. /** @hidden */
  81613. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  81614. /** @hidden */
  81615. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  81616. /** @hidden */
  81617. _updateBoundingInfo(): AbstractMesh;
  81618. /** @hidden */
  81619. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  81620. /** @hidden */
  81621. protected _afterComputeWorldMatrix(): void;
  81622. /**
  81623. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  81624. * A mesh is in the frustum if its bounding box intersects the frustum
  81625. * @param frustumPlanes defines the frustum to test
  81626. * @returns true if the mesh is in the frustum planes
  81627. */
  81628. isInFrustum(frustumPlanes: Plane[]): boolean;
  81629. /**
  81630. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  81631. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  81632. * @param frustumPlanes defines the frustum to test
  81633. * @returns true if the mesh is completely in the frustum planes
  81634. */
  81635. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  81636. /**
  81637. * True if the mesh intersects another mesh or a SolidParticle object
  81638. * @param mesh defines a target mesh or SolidParticle to test
  81639. * @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)
  81640. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  81641. * @returns true if there is an intersection
  81642. */
  81643. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  81644. /**
  81645. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  81646. * @param point defines the point to test
  81647. * @returns true if there is an intersection
  81648. */
  81649. intersectsPoint(point: Vector3): boolean;
  81650. /**
  81651. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  81652. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81653. */
  81654. checkCollisions: boolean;
  81655. /**
  81656. * Gets Collider object used to compute collisions (not physics)
  81657. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81658. */
  81659. readonly collider: Collider;
  81660. /**
  81661. * Move the mesh using collision engine
  81662. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81663. * @param displacement defines the requested displacement vector
  81664. * @returns the current mesh
  81665. */
  81666. moveWithCollisions(displacement: Vector3): AbstractMesh;
  81667. private _onCollisionPositionChange;
  81668. /** @hidden */
  81669. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  81670. /** @hidden */
  81671. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  81672. /** @hidden */
  81673. _checkCollision(collider: Collider): AbstractMesh;
  81674. /** @hidden */
  81675. _generatePointsArray(): boolean;
  81676. /**
  81677. * Checks if the passed Ray intersects with the mesh
  81678. * @param ray defines the ray to use
  81679. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  81680. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  81681. * @returns the picking info
  81682. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  81683. */
  81684. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  81685. /**
  81686. * Clones the current mesh
  81687. * @param name defines the mesh name
  81688. * @param newParent defines the new mesh parent
  81689. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  81690. * @returns the new mesh
  81691. */
  81692. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  81693. /**
  81694. * Disposes all the submeshes of the current meshnp
  81695. * @returns the current mesh
  81696. */
  81697. releaseSubMeshes(): AbstractMesh;
  81698. /**
  81699. * Releases resources associated with this abstract mesh.
  81700. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81701. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81702. */
  81703. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81704. /**
  81705. * Adds the passed mesh as a child to the current mesh
  81706. * @param mesh defines the child mesh
  81707. * @returns the current mesh
  81708. */
  81709. addChild(mesh: AbstractMesh): AbstractMesh;
  81710. /**
  81711. * Removes the passed mesh from the current mesh children list
  81712. * @param mesh defines the child mesh
  81713. * @returns the current mesh
  81714. */
  81715. removeChild(mesh: AbstractMesh): AbstractMesh;
  81716. /** @hidden */
  81717. private _initFacetData;
  81718. /**
  81719. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  81720. * This method can be called within the render loop.
  81721. * 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
  81722. * @returns the current mesh
  81723. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81724. */
  81725. updateFacetData(): AbstractMesh;
  81726. /**
  81727. * Returns the facetLocalNormals array.
  81728. * The normals are expressed in the mesh local spac
  81729. * @returns an array of Vector3
  81730. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81731. */
  81732. getFacetLocalNormals(): Vector3[];
  81733. /**
  81734. * Returns the facetLocalPositions array.
  81735. * The facet positions are expressed in the mesh local space
  81736. * @returns an array of Vector3
  81737. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81738. */
  81739. getFacetLocalPositions(): Vector3[];
  81740. /**
  81741. * Returns the facetLocalPartioning array
  81742. * @returns an array of array of numbers
  81743. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81744. */
  81745. getFacetLocalPartitioning(): number[][];
  81746. /**
  81747. * Returns the i-th facet position in the world system.
  81748. * This method allocates a new Vector3 per call
  81749. * @param i defines the facet index
  81750. * @returns a new Vector3
  81751. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81752. */
  81753. getFacetPosition(i: number): Vector3;
  81754. /**
  81755. * Sets the reference Vector3 with the i-th facet position in the world system
  81756. * @param i defines the facet index
  81757. * @param ref defines the target vector
  81758. * @returns the current mesh
  81759. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81760. */
  81761. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  81762. /**
  81763. * Returns the i-th facet normal in the world system.
  81764. * This method allocates a new Vector3 per call
  81765. * @param i defines the facet index
  81766. * @returns a new Vector3
  81767. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81768. */
  81769. getFacetNormal(i: number): Vector3;
  81770. /**
  81771. * Sets the reference Vector3 with the i-th facet normal in the world system
  81772. * @param i defines the facet index
  81773. * @param ref defines the target vector
  81774. * @returns the current mesh
  81775. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81776. */
  81777. getFacetNormalToRef(i: number, ref: Vector3): this;
  81778. /**
  81779. * 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)
  81780. * @param x defines x coordinate
  81781. * @param y defines y coordinate
  81782. * @param z defines z coordinate
  81783. * @returns the array of facet indexes
  81784. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81785. */
  81786. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  81787. /**
  81788. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  81789. * @param projected sets as the (x,y,z) world projection on the facet
  81790. * @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
  81791. * @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
  81792. * @param x defines x coordinate
  81793. * @param y defines y coordinate
  81794. * @param z defines z coordinate
  81795. * @returns the face index if found (or null instead)
  81796. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81797. */
  81798. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  81799. /**
  81800. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  81801. * @param projected sets as the (x,y,z) local projection on the facet
  81802. * @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
  81803. * @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
  81804. * @param x defines x coordinate
  81805. * @param y defines y coordinate
  81806. * @param z defines z coordinate
  81807. * @returns the face index if found (or null instead)
  81808. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81809. */
  81810. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  81811. /**
  81812. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  81813. * @returns the parameters
  81814. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81815. */
  81816. getFacetDataParameters(): any;
  81817. /**
  81818. * Disables the feature FacetData and frees the related memory
  81819. * @returns the current mesh
  81820. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81821. */
  81822. disableFacetData(): AbstractMesh;
  81823. /**
  81824. * Updates the AbstractMesh indices array
  81825. * @param indices defines the data source
  81826. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  81827. * @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)
  81828. * @returns the current mesh
  81829. */
  81830. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  81831. /**
  81832. * Creates new normals data for the mesh
  81833. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  81834. * @returns the current mesh
  81835. */
  81836. createNormals(updatable: boolean): AbstractMesh;
  81837. /**
  81838. * Align the mesh with a normal
  81839. * @param normal defines the normal to use
  81840. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  81841. * @returns the current mesh
  81842. */
  81843. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  81844. /** @hidden */
  81845. _checkOcclusionQuery(): boolean;
  81846. }
  81847. }
  81848. declare module BABYLON {
  81849. /**
  81850. * Interface used to define ActionEvent
  81851. */
  81852. export interface IActionEvent {
  81853. /** The mesh or sprite that triggered the action */
  81854. source: any;
  81855. /** The X mouse cursor position at the time of the event */
  81856. pointerX: number;
  81857. /** The Y mouse cursor position at the time of the event */
  81858. pointerY: number;
  81859. /** The mesh that is currently pointed at (can be null) */
  81860. meshUnderPointer: Nullable<AbstractMesh>;
  81861. /** the original (browser) event that triggered the ActionEvent */
  81862. sourceEvent?: any;
  81863. /** additional data for the event */
  81864. additionalData?: any;
  81865. }
  81866. /**
  81867. * ActionEvent is the event being sent when an action is triggered.
  81868. */
  81869. export class ActionEvent implements IActionEvent {
  81870. /** The mesh or sprite that triggered the action */
  81871. source: any;
  81872. /** The X mouse cursor position at the time of the event */
  81873. pointerX: number;
  81874. /** The Y mouse cursor position at the time of the event */
  81875. pointerY: number;
  81876. /** The mesh that is currently pointed at (can be null) */
  81877. meshUnderPointer: Nullable<AbstractMesh>;
  81878. /** the original (browser) event that triggered the ActionEvent */
  81879. sourceEvent?: any;
  81880. /** additional data for the event */
  81881. additionalData?: any;
  81882. /**
  81883. * Creates a new ActionEvent
  81884. * @param source The mesh or sprite that triggered the action
  81885. * @param pointerX The X mouse cursor position at the time of the event
  81886. * @param pointerY The Y mouse cursor position at the time of the event
  81887. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  81888. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  81889. * @param additionalData additional data for the event
  81890. */
  81891. constructor(
  81892. /** The mesh or sprite that triggered the action */
  81893. source: any,
  81894. /** The X mouse cursor position at the time of the event */
  81895. pointerX: number,
  81896. /** The Y mouse cursor position at the time of the event */
  81897. pointerY: number,
  81898. /** The mesh that is currently pointed at (can be null) */
  81899. meshUnderPointer: Nullable<AbstractMesh>,
  81900. /** the original (browser) event that triggered the ActionEvent */
  81901. sourceEvent?: any,
  81902. /** additional data for the event */
  81903. additionalData?: any);
  81904. /**
  81905. * Helper function to auto-create an ActionEvent from a source mesh.
  81906. * @param source The source mesh that triggered the event
  81907. * @param evt The original (browser) event
  81908. * @param additionalData additional data for the event
  81909. * @returns the new ActionEvent
  81910. */
  81911. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  81912. /**
  81913. * Helper function to auto-create an ActionEvent from a source sprite
  81914. * @param source The source sprite that triggered the event
  81915. * @param scene Scene associated with the sprite
  81916. * @param evt The original (browser) event
  81917. * @param additionalData additional data for the event
  81918. * @returns the new ActionEvent
  81919. */
  81920. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  81921. /**
  81922. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  81923. * @param scene the scene where the event occurred
  81924. * @param evt The original (browser) event
  81925. * @returns the new ActionEvent
  81926. */
  81927. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  81928. /**
  81929. * Helper function to auto-create an ActionEvent from a primitive
  81930. * @param prim defines the target primitive
  81931. * @param pointerPos defines the pointer position
  81932. * @param evt The original (browser) event
  81933. * @param additionalData additional data for the event
  81934. * @returns the new ActionEvent
  81935. */
  81936. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  81937. }
  81938. }
  81939. declare module BABYLON {
  81940. /**
  81941. * Abstract class used to decouple action Manager from scene and meshes.
  81942. * Do not instantiate.
  81943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81944. */
  81945. export abstract class AbstractActionManager implements IDisposable {
  81946. /** Gets the list of active triggers */
  81947. static Triggers: {
  81948. [key: string]: number;
  81949. };
  81950. /** Gets the cursor to use when hovering items */
  81951. hoverCursor: string;
  81952. /** Gets the list of actions */
  81953. actions: IAction[];
  81954. /**
  81955. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  81956. */
  81957. isRecursive: boolean;
  81958. /**
  81959. * Releases all associated resources
  81960. */
  81961. abstract dispose(): void;
  81962. /**
  81963. * Does this action manager has pointer triggers
  81964. */
  81965. abstract readonly hasPointerTriggers: boolean;
  81966. /**
  81967. * Does this action manager has pick triggers
  81968. */
  81969. abstract readonly hasPickTriggers: boolean;
  81970. /**
  81971. * Process a specific trigger
  81972. * @param trigger defines the trigger to process
  81973. * @param evt defines the event details to be processed
  81974. */
  81975. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  81976. /**
  81977. * Does this action manager handles actions of any of the given triggers
  81978. * @param triggers defines the triggers to be tested
  81979. * @return a boolean indicating whether one (or more) of the triggers is handled
  81980. */
  81981. abstract hasSpecificTriggers(triggers: number[]): boolean;
  81982. /**
  81983. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  81984. * speed.
  81985. * @param triggerA defines the trigger to be tested
  81986. * @param triggerB defines the trigger to be tested
  81987. * @return a boolean indicating whether one (or more) of the triggers is handled
  81988. */
  81989. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  81990. /**
  81991. * Does this action manager handles actions of a given trigger
  81992. * @param trigger defines the trigger to be tested
  81993. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  81994. * @return whether the trigger is handled
  81995. */
  81996. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  81997. /**
  81998. * Serialize this manager to a JSON object
  81999. * @param name defines the property name to store this manager
  82000. * @returns a JSON representation of this manager
  82001. */
  82002. abstract serialize(name: string): any;
  82003. /**
  82004. * Registers an action to this action manager
  82005. * @param action defines the action to be registered
  82006. * @return the action amended (prepared) after registration
  82007. */
  82008. abstract registerAction(action: IAction): Nullable<IAction>;
  82009. /**
  82010. * Unregisters an action to this action manager
  82011. * @param action defines the action to be unregistered
  82012. * @return a boolean indicating whether the action has been unregistered
  82013. */
  82014. abstract unregisterAction(action: IAction): Boolean;
  82015. /**
  82016. * Does exist one action manager with at least one trigger
  82017. **/
  82018. static readonly HasTriggers: boolean;
  82019. /**
  82020. * Does exist one action manager with at least one pick trigger
  82021. **/
  82022. static readonly HasPickTriggers: boolean;
  82023. /**
  82024. * Does exist one action manager that handles actions of a given trigger
  82025. * @param trigger defines the trigger to be tested
  82026. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  82027. **/
  82028. static HasSpecificTrigger(trigger: number): boolean;
  82029. }
  82030. }
  82031. declare module BABYLON {
  82032. /**
  82033. * Defines how a node can be built from a string name.
  82034. */
  82035. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  82036. /**
  82037. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  82038. */
  82039. export class Node implements IBehaviorAware<Node> {
  82040. /** @hidden */
  82041. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  82042. private static _NodeConstructors;
  82043. /**
  82044. * Add a new node constructor
  82045. * @param type defines the type name of the node to construct
  82046. * @param constructorFunc defines the constructor function
  82047. */
  82048. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  82049. /**
  82050. * Returns a node constructor based on type name
  82051. * @param type defines the type name
  82052. * @param name defines the new node name
  82053. * @param scene defines the hosting scene
  82054. * @param options defines optional options to transmit to constructors
  82055. * @returns the new constructor or null
  82056. */
  82057. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  82058. /**
  82059. * Gets or sets the name of the node
  82060. */
  82061. name: string;
  82062. /**
  82063. * Gets or sets the id of the node
  82064. */
  82065. id: string;
  82066. /**
  82067. * Gets or sets the unique id of the node
  82068. */
  82069. uniqueId: number;
  82070. /**
  82071. * Gets or sets a string used to store user defined state for the node
  82072. */
  82073. state: string;
  82074. /**
  82075. * Gets or sets an object used to store user defined information for the node
  82076. */
  82077. metadata: any;
  82078. /**
  82079. * For internal use only. Please do not use.
  82080. */
  82081. reservedDataStore: any;
  82082. /**
  82083. * Gets or sets a boolean used to define if the node must be serialized
  82084. */
  82085. doNotSerialize: boolean;
  82086. /** @hidden */
  82087. _isDisposed: boolean;
  82088. /**
  82089. * Gets a list of Animations associated with the node
  82090. */
  82091. animations: Animation[];
  82092. protected _ranges: {
  82093. [name: string]: Nullable<AnimationRange>;
  82094. };
  82095. /**
  82096. * Callback raised when the node is ready to be used
  82097. */
  82098. onReady: (node: Node) => void;
  82099. private _isEnabled;
  82100. private _isParentEnabled;
  82101. private _isReady;
  82102. /** @hidden */
  82103. _currentRenderId: number;
  82104. private _parentRenderId;
  82105. protected _childRenderId: number;
  82106. /** @hidden */
  82107. _waitingParentId: Nullable<string>;
  82108. /** @hidden */
  82109. _scene: Scene;
  82110. /** @hidden */
  82111. _cache: any;
  82112. private _parentNode;
  82113. private _children;
  82114. /** @hidden */
  82115. _worldMatrix: Matrix;
  82116. /** @hidden */
  82117. _worldMatrixDeterminant: number;
  82118. /** @hidden */
  82119. private _sceneRootNodesIndex;
  82120. /**
  82121. * Gets a boolean indicating if the node has been disposed
  82122. * @returns true if the node was disposed
  82123. */
  82124. isDisposed(): boolean;
  82125. /**
  82126. * Gets or sets the parent of the node
  82127. */
  82128. parent: Nullable<Node>;
  82129. private addToSceneRootNodes;
  82130. private removeFromSceneRootNodes;
  82131. private _animationPropertiesOverride;
  82132. /**
  82133. * Gets or sets the animation properties override
  82134. */
  82135. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  82136. /**
  82137. * Gets a string idenfifying the name of the class
  82138. * @returns "Node" string
  82139. */
  82140. getClassName(): string;
  82141. /** @hidden */
  82142. readonly _isNode: boolean;
  82143. /**
  82144. * An event triggered when the mesh is disposed
  82145. */
  82146. onDisposeObservable: Observable<Node>;
  82147. private _onDisposeObserver;
  82148. /**
  82149. * Sets a callback that will be raised when the node will be disposed
  82150. */
  82151. onDispose: () => void;
  82152. /**
  82153. * Creates a new Node
  82154. * @param name the name and id to be given to this node
  82155. * @param scene the scene this node will be added to
  82156. * @param addToRootNodes the node will be added to scene.rootNodes
  82157. */
  82158. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  82159. /**
  82160. * Gets the scene of the node
  82161. * @returns a scene
  82162. */
  82163. getScene(): Scene;
  82164. /**
  82165. * Gets the engine of the node
  82166. * @returns a Engine
  82167. */
  82168. getEngine(): Engine;
  82169. private _behaviors;
  82170. /**
  82171. * Attach a behavior to the node
  82172. * @see http://doc.babylonjs.com/features/behaviour
  82173. * @param behavior defines the behavior to attach
  82174. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  82175. * @returns the current Node
  82176. */
  82177. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  82178. /**
  82179. * Remove an attached behavior
  82180. * @see http://doc.babylonjs.com/features/behaviour
  82181. * @param behavior defines the behavior to attach
  82182. * @returns the current Node
  82183. */
  82184. removeBehavior(behavior: Behavior<Node>): Node;
  82185. /**
  82186. * Gets the list of attached behaviors
  82187. * @see http://doc.babylonjs.com/features/behaviour
  82188. */
  82189. readonly behaviors: Behavior<Node>[];
  82190. /**
  82191. * Gets an attached behavior by name
  82192. * @param name defines the name of the behavior to look for
  82193. * @see http://doc.babylonjs.com/features/behaviour
  82194. * @returns null if behavior was not found else the requested behavior
  82195. */
  82196. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  82197. /**
  82198. * Returns the latest update of the World matrix
  82199. * @returns a Matrix
  82200. */
  82201. getWorldMatrix(): Matrix;
  82202. /** @hidden */
  82203. _getWorldMatrixDeterminant(): number;
  82204. /**
  82205. * Returns directly the latest state of the mesh World matrix.
  82206. * A Matrix is returned.
  82207. */
  82208. readonly worldMatrixFromCache: Matrix;
  82209. /** @hidden */
  82210. _initCache(): void;
  82211. /** @hidden */
  82212. updateCache(force?: boolean): void;
  82213. /** @hidden */
  82214. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  82215. /** @hidden */
  82216. _updateCache(ignoreParentClass?: boolean): void;
  82217. /** @hidden */
  82218. _isSynchronized(): boolean;
  82219. /** @hidden */
  82220. _markSyncedWithParent(): void;
  82221. /** @hidden */
  82222. isSynchronizedWithParent(): boolean;
  82223. /** @hidden */
  82224. isSynchronized(): boolean;
  82225. /**
  82226. * Is this node ready to be used/rendered
  82227. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  82228. * @return true if the node is ready
  82229. */
  82230. isReady(completeCheck?: boolean): boolean;
  82231. /**
  82232. * Is this node enabled?
  82233. * 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
  82234. * @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
  82235. * @return whether this node (and its parent) is enabled
  82236. */
  82237. isEnabled(checkAncestors?: boolean): boolean;
  82238. /** @hidden */
  82239. protected _syncParentEnabledState(): void;
  82240. /**
  82241. * Set the enabled state of this node
  82242. * @param value defines the new enabled state
  82243. */
  82244. setEnabled(value: boolean): void;
  82245. /**
  82246. * Is this node a descendant of the given node?
  82247. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  82248. * @param ancestor defines the parent node to inspect
  82249. * @returns a boolean indicating if this node is a descendant of the given node
  82250. */
  82251. isDescendantOf(ancestor: Node): boolean;
  82252. /** @hidden */
  82253. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  82254. /**
  82255. * Will return all nodes that have this node as ascendant
  82256. * @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
  82257. * @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
  82258. * @return all children nodes of all types
  82259. */
  82260. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  82261. /**
  82262. * Get all child-meshes of this node
  82263. * @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)
  82264. * @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
  82265. * @returns an array of AbstractMesh
  82266. */
  82267. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  82268. /**
  82269. * Get all direct children of this node
  82270. * @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
  82271. * @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)
  82272. * @returns an array of Node
  82273. */
  82274. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  82275. /** @hidden */
  82276. _setReady(state: boolean): void;
  82277. /**
  82278. * Get an animation by name
  82279. * @param name defines the name of the animation to look for
  82280. * @returns null if not found else the requested animation
  82281. */
  82282. getAnimationByName(name: string): Nullable<Animation>;
  82283. /**
  82284. * Creates an animation range for this node
  82285. * @param name defines the name of the range
  82286. * @param from defines the starting key
  82287. * @param to defines the end key
  82288. */
  82289. createAnimationRange(name: string, from: number, to: number): void;
  82290. /**
  82291. * Delete a specific animation range
  82292. * @param name defines the name of the range to delete
  82293. * @param deleteFrames defines if animation frames from the range must be deleted as well
  82294. */
  82295. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  82296. /**
  82297. * Get an animation range by name
  82298. * @param name defines the name of the animation range to look for
  82299. * @returns null if not found else the requested animation range
  82300. */
  82301. getAnimationRange(name: string): Nullable<AnimationRange>;
  82302. /**
  82303. * Gets the list of all animation ranges defined on this node
  82304. * @returns an array
  82305. */
  82306. getAnimationRanges(): Nullable<AnimationRange>[];
  82307. /**
  82308. * Will start the animation sequence
  82309. * @param name defines the range frames for animation sequence
  82310. * @param loop defines if the animation should loop (false by default)
  82311. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  82312. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  82313. * @returns the object created for this animation. If range does not exist, it will return null
  82314. */
  82315. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  82316. /**
  82317. * Serialize animation ranges into a JSON compatible object
  82318. * @returns serialization object
  82319. */
  82320. serializeAnimationRanges(): any;
  82321. /**
  82322. * Computes the world matrix of the node
  82323. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82324. * @returns the world matrix
  82325. */
  82326. computeWorldMatrix(force?: boolean): Matrix;
  82327. /**
  82328. * Releases resources associated with this node.
  82329. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  82330. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  82331. */
  82332. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  82333. /**
  82334. * Parse animation range data from a serialization object and store them into a given node
  82335. * @param node defines where to store the animation ranges
  82336. * @param parsedNode defines the serialization object to read data from
  82337. * @param scene defines the hosting scene
  82338. */
  82339. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  82340. }
  82341. }
  82342. declare module BABYLON {
  82343. /**
  82344. * Class used to store any kind of animation
  82345. */
  82346. export class Animation {
  82347. /**Name of the animation */
  82348. name: string;
  82349. /**Property to animate */
  82350. targetProperty: string;
  82351. /**The frames per second of the animation */
  82352. framePerSecond: number;
  82353. /**The data type of the animation */
  82354. dataType: number;
  82355. /**The loop mode of the animation */
  82356. loopMode?: number | undefined;
  82357. /**Specifies if blending should be enabled */
  82358. enableBlending?: boolean | undefined;
  82359. /**
  82360. * Use matrix interpolation instead of using direct key value when animating matrices
  82361. */
  82362. static AllowMatricesInterpolation: boolean;
  82363. /**
  82364. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  82365. */
  82366. static AllowMatrixDecomposeForInterpolation: boolean;
  82367. /**
  82368. * Stores the key frames of the animation
  82369. */
  82370. private _keys;
  82371. /**
  82372. * Stores the easing function of the animation
  82373. */
  82374. private _easingFunction;
  82375. /**
  82376. * @hidden Internal use only
  82377. */
  82378. _runtimeAnimations: RuntimeAnimation[];
  82379. /**
  82380. * The set of event that will be linked to this animation
  82381. */
  82382. private _events;
  82383. /**
  82384. * Stores an array of target property paths
  82385. */
  82386. targetPropertyPath: string[];
  82387. /**
  82388. * Stores the blending speed of the animation
  82389. */
  82390. blendingSpeed: number;
  82391. /**
  82392. * Stores the animation ranges for the animation
  82393. */
  82394. private _ranges;
  82395. /**
  82396. * @hidden Internal use
  82397. */
  82398. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  82399. /**
  82400. * Sets up an animation
  82401. * @param property The property to animate
  82402. * @param animationType The animation type to apply
  82403. * @param framePerSecond The frames per second of the animation
  82404. * @param easingFunction The easing function used in the animation
  82405. * @returns The created animation
  82406. */
  82407. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  82408. /**
  82409. * Create and start an animation on a node
  82410. * @param name defines the name of the global animation that will be run on all nodes
  82411. * @param node defines the root node where the animation will take place
  82412. * @param targetProperty defines property to animate
  82413. * @param framePerSecond defines the number of frame per second yo use
  82414. * @param totalFrame defines the number of frames in total
  82415. * @param from defines the initial value
  82416. * @param to defines the final value
  82417. * @param loopMode defines which loop mode you want to use (off by default)
  82418. * @param easingFunction defines the easing function to use (linear by default)
  82419. * @param onAnimationEnd defines the callback to call when animation end
  82420. * @returns the animatable created for this animation
  82421. */
  82422. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  82423. /**
  82424. * Create and start an animation on a node and its descendants
  82425. * @param name defines the name of the global animation that will be run on all nodes
  82426. * @param node defines the root node where the animation will take place
  82427. * @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
  82428. * @param targetProperty defines property to animate
  82429. * @param framePerSecond defines the number of frame per second to use
  82430. * @param totalFrame defines the number of frames in total
  82431. * @param from defines the initial value
  82432. * @param to defines the final value
  82433. * @param loopMode defines which loop mode you want to use (off by default)
  82434. * @param easingFunction defines the easing function to use (linear by default)
  82435. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  82436. * @returns the list of animatables created for all nodes
  82437. * @example https://www.babylonjs-playground.com/#MH0VLI
  82438. */
  82439. 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[]>;
  82440. /**
  82441. * Creates a new animation, merges it with the existing animations and starts it
  82442. * @param name Name of the animation
  82443. * @param node Node which contains the scene that begins the animations
  82444. * @param targetProperty Specifies which property to animate
  82445. * @param framePerSecond The frames per second of the animation
  82446. * @param totalFrame The total number of frames
  82447. * @param from The frame at the beginning of the animation
  82448. * @param to The frame at the end of the animation
  82449. * @param loopMode Specifies the loop mode of the animation
  82450. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  82451. * @param onAnimationEnd Callback to run once the animation is complete
  82452. * @returns Nullable animation
  82453. */
  82454. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  82455. /**
  82456. * Transition property of an host to the target Value
  82457. * @param property The property to transition
  82458. * @param targetValue The target Value of the property
  82459. * @param host The object where the property to animate belongs
  82460. * @param scene Scene used to run the animation
  82461. * @param frameRate Framerate (in frame/s) to use
  82462. * @param transition The transition type we want to use
  82463. * @param duration The duration of the animation, in milliseconds
  82464. * @param onAnimationEnd Callback trigger at the end of the animation
  82465. * @returns Nullable animation
  82466. */
  82467. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  82468. /**
  82469. * Return the array of runtime animations currently using this animation
  82470. */
  82471. readonly runtimeAnimations: RuntimeAnimation[];
  82472. /**
  82473. * Specifies if any of the runtime animations are currently running
  82474. */
  82475. readonly hasRunningRuntimeAnimations: boolean;
  82476. /**
  82477. * Initializes the animation
  82478. * @param name Name of the animation
  82479. * @param targetProperty Property to animate
  82480. * @param framePerSecond The frames per second of the animation
  82481. * @param dataType The data type of the animation
  82482. * @param loopMode The loop mode of the animation
  82483. * @param enableBlending Specifies if blending should be enabled
  82484. */
  82485. constructor(
  82486. /**Name of the animation */
  82487. name: string,
  82488. /**Property to animate */
  82489. targetProperty: string,
  82490. /**The frames per second of the animation */
  82491. framePerSecond: number,
  82492. /**The data type of the animation */
  82493. dataType: number,
  82494. /**The loop mode of the animation */
  82495. loopMode?: number | undefined,
  82496. /**Specifies if blending should be enabled */
  82497. enableBlending?: boolean | undefined);
  82498. /**
  82499. * Converts the animation to a string
  82500. * @param fullDetails support for multiple levels of logging within scene loading
  82501. * @returns String form of the animation
  82502. */
  82503. toString(fullDetails?: boolean): string;
  82504. /**
  82505. * Add an event to this animation
  82506. * @param event Event to add
  82507. */
  82508. addEvent(event: AnimationEvent): void;
  82509. /**
  82510. * Remove all events found at the given frame
  82511. * @param frame The frame to remove events from
  82512. */
  82513. removeEvents(frame: number): void;
  82514. /**
  82515. * Retrieves all the events from the animation
  82516. * @returns Events from the animation
  82517. */
  82518. getEvents(): AnimationEvent[];
  82519. /**
  82520. * Creates an animation range
  82521. * @param name Name of the animation range
  82522. * @param from Starting frame of the animation range
  82523. * @param to Ending frame of the animation
  82524. */
  82525. createRange(name: string, from: number, to: number): void;
  82526. /**
  82527. * Deletes an animation range by name
  82528. * @param name Name of the animation range to delete
  82529. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  82530. */
  82531. deleteRange(name: string, deleteFrames?: boolean): void;
  82532. /**
  82533. * Gets the animation range by name, or null if not defined
  82534. * @param name Name of the animation range
  82535. * @returns Nullable animation range
  82536. */
  82537. getRange(name: string): Nullable<AnimationRange>;
  82538. /**
  82539. * Gets the key frames from the animation
  82540. * @returns The key frames of the animation
  82541. */
  82542. getKeys(): Array<IAnimationKey>;
  82543. /**
  82544. * Gets the highest frame rate of the animation
  82545. * @returns Highest frame rate of the animation
  82546. */
  82547. getHighestFrame(): number;
  82548. /**
  82549. * Gets the easing function of the animation
  82550. * @returns Easing function of the animation
  82551. */
  82552. getEasingFunction(): IEasingFunction;
  82553. /**
  82554. * Sets the easing function of the animation
  82555. * @param easingFunction A custom mathematical formula for animation
  82556. */
  82557. setEasingFunction(easingFunction: EasingFunction): void;
  82558. /**
  82559. * Interpolates a scalar linearly
  82560. * @param startValue Start value of the animation curve
  82561. * @param endValue End value of the animation curve
  82562. * @param gradient Scalar amount to interpolate
  82563. * @returns Interpolated scalar value
  82564. */
  82565. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  82566. /**
  82567. * Interpolates a scalar cubically
  82568. * @param startValue Start value of the animation curve
  82569. * @param outTangent End tangent of the animation
  82570. * @param endValue End value of the animation curve
  82571. * @param inTangent Start tangent of the animation curve
  82572. * @param gradient Scalar amount to interpolate
  82573. * @returns Interpolated scalar value
  82574. */
  82575. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  82576. /**
  82577. * Interpolates a quaternion using a spherical linear interpolation
  82578. * @param startValue Start value of the animation curve
  82579. * @param endValue End value of the animation curve
  82580. * @param gradient Scalar amount to interpolate
  82581. * @returns Interpolated quaternion value
  82582. */
  82583. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  82584. /**
  82585. * Interpolates a quaternion cubically
  82586. * @param startValue Start value of the animation curve
  82587. * @param outTangent End tangent of the animation curve
  82588. * @param endValue End value of the animation curve
  82589. * @param inTangent Start tangent of the animation curve
  82590. * @param gradient Scalar amount to interpolate
  82591. * @returns Interpolated quaternion value
  82592. */
  82593. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  82594. /**
  82595. * Interpolates a Vector3 linearl
  82596. * @param startValue Start value of the animation curve
  82597. * @param endValue End value of the animation curve
  82598. * @param gradient Scalar amount to interpolate
  82599. * @returns Interpolated scalar value
  82600. */
  82601. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  82602. /**
  82603. * Interpolates a Vector3 cubically
  82604. * @param startValue Start value of the animation curve
  82605. * @param outTangent End tangent of the animation
  82606. * @param endValue End value of the animation curve
  82607. * @param inTangent Start tangent of the animation curve
  82608. * @param gradient Scalar amount to interpolate
  82609. * @returns InterpolatedVector3 value
  82610. */
  82611. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  82612. /**
  82613. * Interpolates a Vector2 linearly
  82614. * @param startValue Start value of the animation curve
  82615. * @param endValue End value of the animation curve
  82616. * @param gradient Scalar amount to interpolate
  82617. * @returns Interpolated Vector2 value
  82618. */
  82619. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  82620. /**
  82621. * Interpolates a Vector2 cubically
  82622. * @param startValue Start value of the animation curve
  82623. * @param outTangent End tangent of the animation
  82624. * @param endValue End value of the animation curve
  82625. * @param inTangent Start tangent of the animation curve
  82626. * @param gradient Scalar amount to interpolate
  82627. * @returns Interpolated Vector2 value
  82628. */
  82629. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  82630. /**
  82631. * Interpolates a size linearly
  82632. * @param startValue Start value of the animation curve
  82633. * @param endValue End value of the animation curve
  82634. * @param gradient Scalar amount to interpolate
  82635. * @returns Interpolated Size value
  82636. */
  82637. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  82638. /**
  82639. * Interpolates a Color3 linearly
  82640. * @param startValue Start value of the animation curve
  82641. * @param endValue End value of the animation curve
  82642. * @param gradient Scalar amount to interpolate
  82643. * @returns Interpolated Color3 value
  82644. */
  82645. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  82646. /**
  82647. * @hidden Internal use only
  82648. */
  82649. _getKeyValue(value: any): any;
  82650. /**
  82651. * @hidden Internal use only
  82652. */
  82653. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  82654. /**
  82655. * Defines the function to use to interpolate matrices
  82656. * @param startValue defines the start matrix
  82657. * @param endValue defines the end matrix
  82658. * @param gradient defines the gradient between both matrices
  82659. * @param result defines an optional target matrix where to store the interpolation
  82660. * @returns the interpolated matrix
  82661. */
  82662. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  82663. /**
  82664. * Makes a copy of the animation
  82665. * @returns Cloned animation
  82666. */
  82667. clone(): Animation;
  82668. /**
  82669. * Sets the key frames of the animation
  82670. * @param values The animation key frames to set
  82671. */
  82672. setKeys(values: Array<IAnimationKey>): void;
  82673. /**
  82674. * Serializes the animation to an object
  82675. * @returns Serialized object
  82676. */
  82677. serialize(): any;
  82678. /**
  82679. * Float animation type
  82680. */
  82681. private static _ANIMATIONTYPE_FLOAT;
  82682. /**
  82683. * Vector3 animation type
  82684. */
  82685. private static _ANIMATIONTYPE_VECTOR3;
  82686. /**
  82687. * Quaternion animation type
  82688. */
  82689. private static _ANIMATIONTYPE_QUATERNION;
  82690. /**
  82691. * Matrix animation type
  82692. */
  82693. private static _ANIMATIONTYPE_MATRIX;
  82694. /**
  82695. * Color3 animation type
  82696. */
  82697. private static _ANIMATIONTYPE_COLOR3;
  82698. /**
  82699. * Vector2 animation type
  82700. */
  82701. private static _ANIMATIONTYPE_VECTOR2;
  82702. /**
  82703. * Size animation type
  82704. */
  82705. private static _ANIMATIONTYPE_SIZE;
  82706. /**
  82707. * Relative Loop Mode
  82708. */
  82709. private static _ANIMATIONLOOPMODE_RELATIVE;
  82710. /**
  82711. * Cycle Loop Mode
  82712. */
  82713. private static _ANIMATIONLOOPMODE_CYCLE;
  82714. /**
  82715. * Constant Loop Mode
  82716. */
  82717. private static _ANIMATIONLOOPMODE_CONSTANT;
  82718. /**
  82719. * Get the float animation type
  82720. */
  82721. static readonly ANIMATIONTYPE_FLOAT: number;
  82722. /**
  82723. * Get the Vector3 animation type
  82724. */
  82725. static readonly ANIMATIONTYPE_VECTOR3: number;
  82726. /**
  82727. * Get the Vector2 animation type
  82728. */
  82729. static readonly ANIMATIONTYPE_VECTOR2: number;
  82730. /**
  82731. * Get the Size animation type
  82732. */
  82733. static readonly ANIMATIONTYPE_SIZE: number;
  82734. /**
  82735. * Get the Quaternion animation type
  82736. */
  82737. static readonly ANIMATIONTYPE_QUATERNION: number;
  82738. /**
  82739. * Get the Matrix animation type
  82740. */
  82741. static readonly ANIMATIONTYPE_MATRIX: number;
  82742. /**
  82743. * Get the Color3 animation type
  82744. */
  82745. static readonly ANIMATIONTYPE_COLOR3: number;
  82746. /**
  82747. * Get the Relative Loop Mode
  82748. */
  82749. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  82750. /**
  82751. * Get the Cycle Loop Mode
  82752. */
  82753. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  82754. /**
  82755. * Get the Constant Loop Mode
  82756. */
  82757. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  82758. /** @hidden */
  82759. static _UniversalLerp(left: any, right: any, amount: number): any;
  82760. /**
  82761. * Parses an animation object and creates an animation
  82762. * @param parsedAnimation Parsed animation object
  82763. * @returns Animation object
  82764. */
  82765. static Parse(parsedAnimation: any): Animation;
  82766. /**
  82767. * Appends the serialized animations from the source animations
  82768. * @param source Source containing the animations
  82769. * @param destination Target to store the animations
  82770. */
  82771. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  82772. }
  82773. }
  82774. declare module BABYLON {
  82775. /**
  82776. * Base class of all the textures in babylon.
  82777. * It groups all the common properties the materials, post process, lights... might need
  82778. * in order to make a correct use of the texture.
  82779. */
  82780. export class BaseTexture implements IAnimatable {
  82781. /**
  82782. * Default anisotropic filtering level for the application.
  82783. * It is set to 4 as a good tradeoff between perf and quality.
  82784. */
  82785. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  82786. /**
  82787. * Gets or sets the unique id of the texture
  82788. */
  82789. uniqueId: number;
  82790. /**
  82791. * Define the name of the texture.
  82792. */
  82793. name: string;
  82794. /**
  82795. * Gets or sets an object used to store user defined information.
  82796. */
  82797. metadata: any;
  82798. /**
  82799. * For internal use only. Please do not use.
  82800. */
  82801. reservedDataStore: any;
  82802. private _hasAlpha;
  82803. /**
  82804. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  82805. */
  82806. hasAlpha: boolean;
  82807. /**
  82808. * Defines if the alpha value should be determined via the rgb values.
  82809. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  82810. */
  82811. getAlphaFromRGB: boolean;
  82812. /**
  82813. * Intensity or strength of the texture.
  82814. * It is commonly used by materials to fine tune the intensity of the texture
  82815. */
  82816. level: number;
  82817. /**
  82818. * Define the UV chanel to use starting from 0 and defaulting to 0.
  82819. * This is part of the texture as textures usually maps to one uv set.
  82820. */
  82821. coordinatesIndex: number;
  82822. private _coordinatesMode;
  82823. /**
  82824. * How a texture is mapped.
  82825. *
  82826. * | Value | Type | Description |
  82827. * | ----- | ----------------------------------- | ----------- |
  82828. * | 0 | EXPLICIT_MODE | |
  82829. * | 1 | SPHERICAL_MODE | |
  82830. * | 2 | PLANAR_MODE | |
  82831. * | 3 | CUBIC_MODE | |
  82832. * | 4 | PROJECTION_MODE | |
  82833. * | 5 | SKYBOX_MODE | |
  82834. * | 6 | INVCUBIC_MODE | |
  82835. * | 7 | EQUIRECTANGULAR_MODE | |
  82836. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  82837. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  82838. */
  82839. coordinatesMode: number;
  82840. /**
  82841. * | Value | Type | Description |
  82842. * | ----- | ------------------ | ----------- |
  82843. * | 0 | CLAMP_ADDRESSMODE | |
  82844. * | 1 | WRAP_ADDRESSMODE | |
  82845. * | 2 | MIRROR_ADDRESSMODE | |
  82846. */
  82847. wrapU: number;
  82848. /**
  82849. * | Value | Type | Description |
  82850. * | ----- | ------------------ | ----------- |
  82851. * | 0 | CLAMP_ADDRESSMODE | |
  82852. * | 1 | WRAP_ADDRESSMODE | |
  82853. * | 2 | MIRROR_ADDRESSMODE | |
  82854. */
  82855. wrapV: number;
  82856. /**
  82857. * | Value | Type | Description |
  82858. * | ----- | ------------------ | ----------- |
  82859. * | 0 | CLAMP_ADDRESSMODE | |
  82860. * | 1 | WRAP_ADDRESSMODE | |
  82861. * | 2 | MIRROR_ADDRESSMODE | |
  82862. */
  82863. wrapR: number;
  82864. /**
  82865. * With compliant hardware and browser (supporting anisotropic filtering)
  82866. * this defines the level of anisotropic filtering in the texture.
  82867. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  82868. */
  82869. anisotropicFilteringLevel: number;
  82870. /**
  82871. * Define if the texture is a cube texture or if false a 2d texture.
  82872. */
  82873. isCube: boolean;
  82874. /**
  82875. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  82876. */
  82877. is3D: boolean;
  82878. /**
  82879. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  82880. * HDR texture are usually stored in linear space.
  82881. * This only impacts the PBR and Background materials
  82882. */
  82883. gammaSpace: boolean;
  82884. /**
  82885. * Gets whether or not the texture contains RGBD data.
  82886. */
  82887. readonly isRGBD: boolean;
  82888. /**
  82889. * Is Z inverted in the texture (useful in a cube texture).
  82890. */
  82891. invertZ: boolean;
  82892. /**
  82893. * Are mip maps generated for this texture or not.
  82894. */
  82895. readonly noMipmap: boolean;
  82896. /**
  82897. * @hidden
  82898. */
  82899. lodLevelInAlpha: boolean;
  82900. /**
  82901. * With prefiltered texture, defined the offset used during the prefiltering steps.
  82902. */
  82903. lodGenerationOffset: number;
  82904. /**
  82905. * With prefiltered texture, defined the scale used during the prefiltering steps.
  82906. */
  82907. lodGenerationScale: number;
  82908. /**
  82909. * Define if the texture is a render target.
  82910. */
  82911. isRenderTarget: boolean;
  82912. /**
  82913. * Define the unique id of the texture in the scene.
  82914. */
  82915. readonly uid: string;
  82916. /**
  82917. * Return a string representation of the texture.
  82918. * @returns the texture as a string
  82919. */
  82920. toString(): string;
  82921. /**
  82922. * Get the class name of the texture.
  82923. * @returns "BaseTexture"
  82924. */
  82925. getClassName(): string;
  82926. /**
  82927. * Define the list of animation attached to the texture.
  82928. */
  82929. animations: Animation[];
  82930. /**
  82931. * An event triggered when the texture is disposed.
  82932. */
  82933. onDisposeObservable: Observable<BaseTexture>;
  82934. private _onDisposeObserver;
  82935. /**
  82936. * Callback triggered when the texture has been disposed.
  82937. * Kept for back compatibility, you can use the onDisposeObservable instead.
  82938. */
  82939. onDispose: () => void;
  82940. /**
  82941. * Define the current state of the loading sequence when in delayed load mode.
  82942. */
  82943. delayLoadState: number;
  82944. private _scene;
  82945. /** @hidden */
  82946. _texture: Nullable<InternalTexture>;
  82947. private _uid;
  82948. /**
  82949. * Define if the texture is preventinga material to render or not.
  82950. * If not and the texture is not ready, the engine will use a default black texture instead.
  82951. */
  82952. readonly isBlocking: boolean;
  82953. /**
  82954. * Instantiates a new BaseTexture.
  82955. * Base class of all the textures in babylon.
  82956. * It groups all the common properties the materials, post process, lights... might need
  82957. * in order to make a correct use of the texture.
  82958. * @param scene Define the scene the texture blongs to
  82959. */
  82960. constructor(scene: Nullable<Scene>);
  82961. /**
  82962. * Get the scene the texture belongs to.
  82963. * @returns the scene or null if undefined
  82964. */
  82965. getScene(): Nullable<Scene>;
  82966. /**
  82967. * Get the texture transform matrix used to offset tile the texture for istance.
  82968. * @returns the transformation matrix
  82969. */
  82970. getTextureMatrix(): Matrix;
  82971. /**
  82972. * Get the texture reflection matrix used to rotate/transform the reflection.
  82973. * @returns the reflection matrix
  82974. */
  82975. getReflectionTextureMatrix(): Matrix;
  82976. /**
  82977. * Get the underlying lower level texture from Babylon.
  82978. * @returns the insternal texture
  82979. */
  82980. getInternalTexture(): Nullable<InternalTexture>;
  82981. /**
  82982. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  82983. * @returns true if ready or not blocking
  82984. */
  82985. isReadyOrNotBlocking(): boolean;
  82986. /**
  82987. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  82988. * @returns true if fully ready
  82989. */
  82990. isReady(): boolean;
  82991. private _cachedSize;
  82992. /**
  82993. * Get the size of the texture.
  82994. * @returns the texture size.
  82995. */
  82996. getSize(): ISize;
  82997. /**
  82998. * Get the base size of the texture.
  82999. * It can be different from the size if the texture has been resized for POT for instance
  83000. * @returns the base size
  83001. */
  83002. getBaseSize(): ISize;
  83003. /**
  83004. * Update the sampling mode of the texture.
  83005. * Default is Trilinear mode.
  83006. *
  83007. * | Value | Type | Description |
  83008. * | ----- | ------------------ | ----------- |
  83009. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  83010. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  83011. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  83012. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  83013. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  83014. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  83015. * | 7 | NEAREST_LINEAR | |
  83016. * | 8 | NEAREST_NEAREST | |
  83017. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  83018. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  83019. * | 11 | LINEAR_LINEAR | |
  83020. * | 12 | LINEAR_NEAREST | |
  83021. *
  83022. * > _mag_: magnification filter (close to the viewer)
  83023. * > _min_: minification filter (far from the viewer)
  83024. * > _mip_: filter used between mip map levels
  83025. *@param samplingMode Define the new sampling mode of the texture
  83026. */
  83027. updateSamplingMode(samplingMode: number): void;
  83028. /**
  83029. * Scales the texture if is `canRescale()`
  83030. * @param ratio the resize factor we want to use to rescale
  83031. */
  83032. scale(ratio: number): void;
  83033. /**
  83034. * Get if the texture can rescale.
  83035. */
  83036. readonly canRescale: boolean;
  83037. /** @hidden */
  83038. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  83039. /** @hidden */
  83040. _rebuild(): void;
  83041. /**
  83042. * Triggers the load sequence in delayed load mode.
  83043. */
  83044. delayLoad(): void;
  83045. /**
  83046. * Clones the texture.
  83047. * @returns the cloned texture
  83048. */
  83049. clone(): Nullable<BaseTexture>;
  83050. /**
  83051. * Get the texture underlying type (INT, FLOAT...)
  83052. */
  83053. readonly textureType: number;
  83054. /**
  83055. * Get the texture underlying format (RGB, RGBA...)
  83056. */
  83057. readonly textureFormat: number;
  83058. /**
  83059. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  83060. * This will returns an RGBA array buffer containing either in values (0-255) or
  83061. * float values (0-1) depending of the underlying buffer type.
  83062. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  83063. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  83064. * @param buffer defines a user defined buffer to fill with data (can be null)
  83065. * @returns The Array buffer containing the pixels data.
  83066. */
  83067. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  83068. /**
  83069. * Release and destroy the underlying lower level texture aka internalTexture.
  83070. */
  83071. releaseInternalTexture(): void;
  83072. /**
  83073. * Get the polynomial representation of the texture data.
  83074. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  83075. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  83076. */
  83077. sphericalPolynomial: Nullable<SphericalPolynomial>;
  83078. /** @hidden */
  83079. readonly _lodTextureHigh: Nullable<BaseTexture>;
  83080. /** @hidden */
  83081. readonly _lodTextureMid: Nullable<BaseTexture>;
  83082. /** @hidden */
  83083. readonly _lodTextureLow: Nullable<BaseTexture>;
  83084. /**
  83085. * Dispose the texture and release its associated resources.
  83086. */
  83087. dispose(): void;
  83088. /**
  83089. * Serialize the texture into a JSON representation that can be parsed later on.
  83090. * @returns the JSON representation of the texture
  83091. */
  83092. serialize(): any;
  83093. /**
  83094. * Helper function to be called back once a list of texture contains only ready textures.
  83095. * @param textures Define the list of textures to wait for
  83096. * @param callback Define the callback triggered once the entire list will be ready
  83097. */
  83098. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  83099. }
  83100. }
  83101. declare module BABYLON {
  83102. /**
  83103. * Uniform buffer objects.
  83104. *
  83105. * Handles blocks of uniform on the GPU.
  83106. *
  83107. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  83108. *
  83109. * For more information, please refer to :
  83110. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  83111. */
  83112. export class UniformBuffer {
  83113. private _engine;
  83114. private _buffer;
  83115. private _data;
  83116. private _bufferData;
  83117. private _dynamic?;
  83118. private _uniformLocations;
  83119. private _uniformSizes;
  83120. private _uniformLocationPointer;
  83121. private _needSync;
  83122. private _noUBO;
  83123. private _currentEffect;
  83124. private static _MAX_UNIFORM_SIZE;
  83125. private static _tempBuffer;
  83126. /**
  83127. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  83128. * This is dynamic to allow compat with webgl 1 and 2.
  83129. * You will need to pass the name of the uniform as well as the value.
  83130. */
  83131. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  83132. /**
  83133. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  83134. * This is dynamic to allow compat with webgl 1 and 2.
  83135. * You will need to pass the name of the uniform as well as the value.
  83136. */
  83137. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  83138. /**
  83139. * Lambda to Update a single float in a uniform buffer.
  83140. * This is dynamic to allow compat with webgl 1 and 2.
  83141. * You will need to pass the name of the uniform as well as the value.
  83142. */
  83143. updateFloat: (name: string, x: number) => void;
  83144. /**
  83145. * Lambda to Update a vec2 of float in a uniform buffer.
  83146. * This is dynamic to allow compat with webgl 1 and 2.
  83147. * You will need to pass the name of the uniform as well as the value.
  83148. */
  83149. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  83150. /**
  83151. * Lambda to Update a vec3 of float in a uniform buffer.
  83152. * This is dynamic to allow compat with webgl 1 and 2.
  83153. * You will need to pass the name of the uniform as well as the value.
  83154. */
  83155. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  83156. /**
  83157. * Lambda to Update a vec4 of float in a uniform buffer.
  83158. * This is dynamic to allow compat with webgl 1 and 2.
  83159. * You will need to pass the name of the uniform as well as the value.
  83160. */
  83161. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  83162. /**
  83163. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  83164. * This is dynamic to allow compat with webgl 1 and 2.
  83165. * You will need to pass the name of the uniform as well as the value.
  83166. */
  83167. updateMatrix: (name: string, mat: Matrix) => void;
  83168. /**
  83169. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  83170. * This is dynamic to allow compat with webgl 1 and 2.
  83171. * You will need to pass the name of the uniform as well as the value.
  83172. */
  83173. updateVector3: (name: string, vector: Vector3) => void;
  83174. /**
  83175. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  83176. * This is dynamic to allow compat with webgl 1 and 2.
  83177. * You will need to pass the name of the uniform as well as the value.
  83178. */
  83179. updateVector4: (name: string, vector: Vector4) => void;
  83180. /**
  83181. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  83182. * This is dynamic to allow compat with webgl 1 and 2.
  83183. * You will need to pass the name of the uniform as well as the value.
  83184. */
  83185. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  83186. /**
  83187. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  83188. * This is dynamic to allow compat with webgl 1 and 2.
  83189. * You will need to pass the name of the uniform as well as the value.
  83190. */
  83191. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  83192. /**
  83193. * Instantiates a new Uniform buffer objects.
  83194. *
  83195. * Handles blocks of uniform on the GPU.
  83196. *
  83197. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  83198. *
  83199. * For more information, please refer to :
  83200. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  83201. * @param engine Define the engine the buffer is associated with
  83202. * @param data Define the data contained in the buffer
  83203. * @param dynamic Define if the buffer is updatable
  83204. */
  83205. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  83206. /**
  83207. * Indicates if the buffer is using the WebGL2 UBO implementation,
  83208. * or just falling back on setUniformXXX calls.
  83209. */
  83210. readonly useUbo: boolean;
  83211. /**
  83212. * Indicates if the WebGL underlying uniform buffer is in sync
  83213. * with the javascript cache data.
  83214. */
  83215. readonly isSync: boolean;
  83216. /**
  83217. * Indicates if the WebGL underlying uniform buffer is dynamic.
  83218. * Also, a dynamic UniformBuffer will disable cache verification and always
  83219. * update the underlying WebGL uniform buffer to the GPU.
  83220. * @returns if Dynamic, otherwise false
  83221. */
  83222. isDynamic(): boolean;
  83223. /**
  83224. * The data cache on JS side.
  83225. * @returns the underlying data as a float array
  83226. */
  83227. getData(): Float32Array;
  83228. /**
  83229. * The underlying WebGL Uniform buffer.
  83230. * @returns the webgl buffer
  83231. */
  83232. getBuffer(): Nullable<WebGLBuffer>;
  83233. /**
  83234. * std140 layout specifies how to align data within an UBO structure.
  83235. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  83236. * for specs.
  83237. */
  83238. private _fillAlignment;
  83239. /**
  83240. * Adds an uniform in the buffer.
  83241. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  83242. * for the layout to be correct !
  83243. * @param name Name of the uniform, as used in the uniform block in the shader.
  83244. * @param size Data size, or data directly.
  83245. */
  83246. addUniform(name: string, size: number | number[]): void;
  83247. /**
  83248. * Adds a Matrix 4x4 to the uniform buffer.
  83249. * @param name Name of the uniform, as used in the uniform block in the shader.
  83250. * @param mat A 4x4 matrix.
  83251. */
  83252. addMatrix(name: string, mat: Matrix): void;
  83253. /**
  83254. * Adds a vec2 to the uniform buffer.
  83255. * @param name Name of the uniform, as used in the uniform block in the shader.
  83256. * @param x Define the x component value of the vec2
  83257. * @param y Define the y component value of the vec2
  83258. */
  83259. addFloat2(name: string, x: number, y: number): void;
  83260. /**
  83261. * Adds a vec3 to the uniform buffer.
  83262. * @param name Name of the uniform, as used in the uniform block in the shader.
  83263. * @param x Define the x component value of the vec3
  83264. * @param y Define the y component value of the vec3
  83265. * @param z Define the z component value of the vec3
  83266. */
  83267. addFloat3(name: string, x: number, y: number, z: number): void;
  83268. /**
  83269. * Adds a vec3 to the uniform buffer.
  83270. * @param name Name of the uniform, as used in the uniform block in the shader.
  83271. * @param color Define the vec3 from a Color
  83272. */
  83273. addColor3(name: string, color: Color3): void;
  83274. /**
  83275. * Adds a vec4 to the uniform buffer.
  83276. * @param name Name of the uniform, as used in the uniform block in the shader.
  83277. * @param color Define the rgb components from a Color
  83278. * @param alpha Define the a component of the vec4
  83279. */
  83280. addColor4(name: string, color: Color3, alpha: number): void;
  83281. /**
  83282. * Adds a vec3 to the uniform buffer.
  83283. * @param name Name of the uniform, as used in the uniform block in the shader.
  83284. * @param vector Define the vec3 components from a Vector
  83285. */
  83286. addVector3(name: string, vector: Vector3): void;
  83287. /**
  83288. * Adds a Matrix 3x3 to the uniform buffer.
  83289. * @param name Name of the uniform, as used in the uniform block in the shader.
  83290. */
  83291. addMatrix3x3(name: string): void;
  83292. /**
  83293. * Adds a Matrix 2x2 to the uniform buffer.
  83294. * @param name Name of the uniform, as used in the uniform block in the shader.
  83295. */
  83296. addMatrix2x2(name: string): void;
  83297. /**
  83298. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  83299. */
  83300. create(): void;
  83301. /** @hidden */
  83302. _rebuild(): void;
  83303. /**
  83304. * Updates the WebGL Uniform Buffer on the GPU.
  83305. * If the `dynamic` flag is set to true, no cache comparison is done.
  83306. * Otherwise, the buffer will be updated only if the cache differs.
  83307. */
  83308. update(): void;
  83309. /**
  83310. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  83311. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  83312. * @param data Define the flattened data
  83313. * @param size Define the size of the data.
  83314. */
  83315. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  83316. private _updateMatrix3x3ForUniform;
  83317. private _updateMatrix3x3ForEffect;
  83318. private _updateMatrix2x2ForEffect;
  83319. private _updateMatrix2x2ForUniform;
  83320. private _updateFloatForEffect;
  83321. private _updateFloatForUniform;
  83322. private _updateFloat2ForEffect;
  83323. private _updateFloat2ForUniform;
  83324. private _updateFloat3ForEffect;
  83325. private _updateFloat3ForUniform;
  83326. private _updateFloat4ForEffect;
  83327. private _updateFloat4ForUniform;
  83328. private _updateMatrixForEffect;
  83329. private _updateMatrixForUniform;
  83330. private _updateVector3ForEffect;
  83331. private _updateVector3ForUniform;
  83332. private _updateVector4ForEffect;
  83333. private _updateVector4ForUniform;
  83334. private _updateColor3ForEffect;
  83335. private _updateColor3ForUniform;
  83336. private _updateColor4ForEffect;
  83337. private _updateColor4ForUniform;
  83338. /**
  83339. * Sets a sampler uniform on the effect.
  83340. * @param name Define the name of the sampler.
  83341. * @param texture Define the texture to set in the sampler
  83342. */
  83343. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  83344. /**
  83345. * Directly updates the value of the uniform in the cache AND on the GPU.
  83346. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  83347. * @param data Define the flattened data
  83348. */
  83349. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  83350. /**
  83351. * Binds this uniform buffer to an effect.
  83352. * @param effect Define the effect to bind the buffer to
  83353. * @param name Name of the uniform block in the shader.
  83354. */
  83355. bindToEffect(effect: Effect, name: string): void;
  83356. /**
  83357. * Disposes the uniform buffer.
  83358. */
  83359. dispose(): void;
  83360. }
  83361. }
  83362. declare module BABYLON {
  83363. /**
  83364. * This represents the required contract to create a new type of texture loader.
  83365. */
  83366. export interface IInternalTextureLoader {
  83367. /**
  83368. * Defines wether the loader supports cascade loading the different faces.
  83369. */
  83370. supportCascades: boolean;
  83371. /**
  83372. * This returns if the loader support the current file information.
  83373. * @param extension defines the file extension of the file being loaded
  83374. * @param textureFormatInUse defines the current compressed format in use iun the engine
  83375. * @param fallback defines the fallback internal texture if any
  83376. * @param isBase64 defines whether the texture is encoded as a base64
  83377. * @param isBuffer defines whether the texture data are stored as a buffer
  83378. * @returns true if the loader can load the specified file
  83379. */
  83380. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  83381. /**
  83382. * Transform the url before loading if required.
  83383. * @param rootUrl the url of the texture
  83384. * @param textureFormatInUse defines the current compressed format in use iun the engine
  83385. * @returns the transformed texture
  83386. */
  83387. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  83388. /**
  83389. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  83390. * @param rootUrl the url of the texture
  83391. * @param textureFormatInUse defines the current compressed format in use iun the engine
  83392. * @returns the fallback texture
  83393. */
  83394. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  83395. /**
  83396. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  83397. * @param data contains the texture data
  83398. * @param texture defines the BabylonJS internal texture
  83399. * @param createPolynomials will be true if polynomials have been requested
  83400. * @param onLoad defines the callback to trigger once the texture is ready
  83401. * @param onError defines the callback to trigger in case of error
  83402. */
  83403. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  83404. /**
  83405. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  83406. * @param data contains the texture data
  83407. * @param texture defines the BabylonJS internal texture
  83408. * @param callback defines the method to call once ready to upload
  83409. */
  83410. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  83411. }
  83412. }
  83413. declare module BABYLON {
  83414. /**
  83415. * Creation options of the multi render target texture.
  83416. */
  83417. export interface IMultiRenderTargetOptions {
  83418. /**
  83419. * Define if the texture needs to create mip maps after render.
  83420. */
  83421. generateMipMaps?: boolean;
  83422. /**
  83423. * Define the types of all the draw buffers we want to create
  83424. */
  83425. types?: number[];
  83426. /**
  83427. * Define the sampling modes of all the draw buffers we want to create
  83428. */
  83429. samplingModes?: number[];
  83430. /**
  83431. * Define if a depth buffer is required
  83432. */
  83433. generateDepthBuffer?: boolean;
  83434. /**
  83435. * Define if a stencil buffer is required
  83436. */
  83437. generateStencilBuffer?: boolean;
  83438. /**
  83439. * Define if a depth texture is required instead of a depth buffer
  83440. */
  83441. generateDepthTexture?: boolean;
  83442. /**
  83443. * Define the number of desired draw buffers
  83444. */
  83445. textureCount?: number;
  83446. /**
  83447. * Define if aspect ratio should be adapted to the texture or stay the scene one
  83448. */
  83449. doNotChangeAspectRatio?: boolean;
  83450. /**
  83451. * Define the default type of the buffers we are creating
  83452. */
  83453. defaultType?: number;
  83454. }
  83455. /**
  83456. * A multi render target, like a render target provides the ability to render to a texture.
  83457. * Unlike the render target, it can render to several draw buffers in one draw.
  83458. * This is specially interesting in deferred rendering or for any effects requiring more than
  83459. * just one color from a single pass.
  83460. */
  83461. export class MultiRenderTarget extends RenderTargetTexture {
  83462. private _internalTextures;
  83463. private _textures;
  83464. private _multiRenderTargetOptions;
  83465. /**
  83466. * Get if draw buffers are currently supported by the used hardware and browser.
  83467. */
  83468. readonly isSupported: boolean;
  83469. /**
  83470. * Get the list of textures generated by the multi render target.
  83471. */
  83472. readonly textures: Texture[];
  83473. /**
  83474. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  83475. */
  83476. readonly depthTexture: Texture;
  83477. /**
  83478. * Set the wrapping mode on U of all the textures we are rendering to.
  83479. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  83480. */
  83481. wrapU: number;
  83482. /**
  83483. * Set the wrapping mode on V of all the textures we are rendering to.
  83484. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  83485. */
  83486. wrapV: number;
  83487. /**
  83488. * Instantiate a new multi render target texture.
  83489. * A multi render target, like a render target provides the ability to render to a texture.
  83490. * Unlike the render target, it can render to several draw buffers in one draw.
  83491. * This is specially interesting in deferred rendering or for any effects requiring more than
  83492. * just one color from a single pass.
  83493. * @param name Define the name of the texture
  83494. * @param size Define the size of the buffers to render to
  83495. * @param count Define the number of target we are rendering into
  83496. * @param scene Define the scene the texture belongs to
  83497. * @param options Define the options used to create the multi render target
  83498. */
  83499. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  83500. /** @hidden */
  83501. _rebuild(): void;
  83502. private _createInternalTextures;
  83503. private _createTextures;
  83504. /**
  83505. * Define the number of samples used if MSAA is enabled.
  83506. */
  83507. samples: number;
  83508. /**
  83509. * Resize all the textures in the multi render target.
  83510. * Be carrefull as it will recreate all the data in the new texture.
  83511. * @param size Define the new size
  83512. */
  83513. resize(size: any): void;
  83514. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  83515. /**
  83516. * Dispose the render targets and their associated resources
  83517. */
  83518. dispose(): void;
  83519. /**
  83520. * Release all the underlying texture used as draw buffers.
  83521. */
  83522. releaseInternalTextures(): void;
  83523. }
  83524. }
  83525. declare module BABYLON {
  83526. /**
  83527. * Class used to work with sound analyzer using fast fourier transform (FFT)
  83528. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83529. */
  83530. export class Analyser {
  83531. /**
  83532. * Gets or sets the smoothing
  83533. * @ignorenaming
  83534. */
  83535. SMOOTHING: number;
  83536. /**
  83537. * Gets or sets the FFT table size
  83538. * @ignorenaming
  83539. */
  83540. FFT_SIZE: number;
  83541. /**
  83542. * Gets or sets the bar graph amplitude
  83543. * @ignorenaming
  83544. */
  83545. BARGRAPHAMPLITUDE: number;
  83546. /**
  83547. * Gets or sets the position of the debug canvas
  83548. * @ignorenaming
  83549. */
  83550. DEBUGCANVASPOS: {
  83551. x: number;
  83552. y: number;
  83553. };
  83554. /**
  83555. * Gets or sets the debug canvas size
  83556. * @ignorenaming
  83557. */
  83558. DEBUGCANVASSIZE: {
  83559. width: number;
  83560. height: number;
  83561. };
  83562. private _byteFreqs;
  83563. private _byteTime;
  83564. private _floatFreqs;
  83565. private _webAudioAnalyser;
  83566. private _debugCanvas;
  83567. private _debugCanvasContext;
  83568. private _scene;
  83569. private _registerFunc;
  83570. private _audioEngine;
  83571. /**
  83572. * Creates a new analyser
  83573. * @param scene defines hosting scene
  83574. */
  83575. constructor(scene: Scene);
  83576. /**
  83577. * Get the number of data values you will have to play with for the visualization
  83578. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  83579. * @returns a number
  83580. */
  83581. getFrequencyBinCount(): number;
  83582. /**
  83583. * Gets the current frequency data as a byte array
  83584. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  83585. * @returns a Uint8Array
  83586. */
  83587. getByteFrequencyData(): Uint8Array;
  83588. /**
  83589. * Gets the current waveform as a byte array
  83590. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  83591. * @returns a Uint8Array
  83592. */
  83593. getByteTimeDomainData(): Uint8Array;
  83594. /**
  83595. * Gets the current frequency data as a float array
  83596. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  83597. * @returns a Float32Array
  83598. */
  83599. getFloatFrequencyData(): Float32Array;
  83600. /**
  83601. * Renders the debug canvas
  83602. */
  83603. drawDebugCanvas(): void;
  83604. /**
  83605. * Stops rendering the debug canvas and removes it
  83606. */
  83607. stopDebugCanvas(): void;
  83608. /**
  83609. * Connects two audio nodes
  83610. * @param inputAudioNode defines first node to connect
  83611. * @param outputAudioNode defines second node to connect
  83612. */
  83613. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  83614. /**
  83615. * Releases all associated resources
  83616. */
  83617. dispose(): void;
  83618. }
  83619. }
  83620. declare module BABYLON {
  83621. /**
  83622. * This represents an audio engine and it is responsible
  83623. * to play, synchronize and analyse sounds throughout the application.
  83624. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83625. */
  83626. export interface IAudioEngine extends IDisposable {
  83627. /**
  83628. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  83629. */
  83630. readonly canUseWebAudio: boolean;
  83631. /**
  83632. * Gets the current AudioContext if available.
  83633. */
  83634. readonly audioContext: Nullable<AudioContext>;
  83635. /**
  83636. * The master gain node defines the global audio volume of your audio engine.
  83637. */
  83638. readonly masterGain: GainNode;
  83639. /**
  83640. * Gets whether or not mp3 are supported by your browser.
  83641. */
  83642. readonly isMP3supported: boolean;
  83643. /**
  83644. * Gets whether or not ogg are supported by your browser.
  83645. */
  83646. readonly isOGGsupported: boolean;
  83647. /**
  83648. * Defines if Babylon should emit a warning if WebAudio is not supported.
  83649. * @ignoreNaming
  83650. */
  83651. WarnedWebAudioUnsupported: boolean;
  83652. /**
  83653. * Defines if the audio engine relies on a custom unlocked button.
  83654. * In this case, the embedded button will not be displayed.
  83655. */
  83656. useCustomUnlockedButton: boolean;
  83657. /**
  83658. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  83659. */
  83660. readonly unlocked: boolean;
  83661. /**
  83662. * Event raised when audio has been unlocked on the browser.
  83663. */
  83664. onAudioUnlockedObservable: Observable<AudioEngine>;
  83665. /**
  83666. * Event raised when audio has been locked on the browser.
  83667. */
  83668. onAudioLockedObservable: Observable<AudioEngine>;
  83669. /**
  83670. * Flags the audio engine in Locked state.
  83671. * This happens due to new browser policies preventing audio to autoplay.
  83672. */
  83673. lock(): void;
  83674. /**
  83675. * Unlocks the audio engine once a user action has been done on the dom.
  83676. * This is helpful to resume play once browser policies have been satisfied.
  83677. */
  83678. unlock(): void;
  83679. }
  83680. /**
  83681. * This represents the default audio engine used in babylon.
  83682. * It is responsible to play, synchronize and analyse sounds throughout the application.
  83683. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83684. */
  83685. export class AudioEngine implements IAudioEngine {
  83686. private _audioContext;
  83687. private _audioContextInitialized;
  83688. private _muteButton;
  83689. private _hostElement;
  83690. /**
  83691. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  83692. */
  83693. canUseWebAudio: boolean;
  83694. /**
  83695. * The master gain node defines the global audio volume of your audio engine.
  83696. */
  83697. masterGain: GainNode;
  83698. /**
  83699. * Defines if Babylon should emit a warning if WebAudio is not supported.
  83700. * @ignoreNaming
  83701. */
  83702. WarnedWebAudioUnsupported: boolean;
  83703. /**
  83704. * Gets whether or not mp3 are supported by your browser.
  83705. */
  83706. isMP3supported: boolean;
  83707. /**
  83708. * Gets whether or not ogg are supported by your browser.
  83709. */
  83710. isOGGsupported: boolean;
  83711. /**
  83712. * Gets whether audio has been unlocked on the device.
  83713. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  83714. * a user interaction has happened.
  83715. */
  83716. unlocked: boolean;
  83717. /**
  83718. * Defines if the audio engine relies on a custom unlocked button.
  83719. * In this case, the embedded button will not be displayed.
  83720. */
  83721. useCustomUnlockedButton: boolean;
  83722. /**
  83723. * Event raised when audio has been unlocked on the browser.
  83724. */
  83725. onAudioUnlockedObservable: Observable<AudioEngine>;
  83726. /**
  83727. * Event raised when audio has been locked on the browser.
  83728. */
  83729. onAudioLockedObservable: Observable<AudioEngine>;
  83730. /**
  83731. * Gets the current AudioContext if available.
  83732. */
  83733. readonly audioContext: Nullable<AudioContext>;
  83734. private _connectedAnalyser;
  83735. /**
  83736. * Instantiates a new audio engine.
  83737. *
  83738. * There should be only one per page as some browsers restrict the number
  83739. * of audio contexts you can create.
  83740. * @param hostElement defines the host element where to display the mute icon if necessary
  83741. */
  83742. constructor(hostElement?: Nullable<HTMLElement>);
  83743. /**
  83744. * Flags the audio engine in Locked state.
  83745. * This happens due to new browser policies preventing audio to autoplay.
  83746. */
  83747. lock(): void;
  83748. /**
  83749. * Unlocks the audio engine once a user action has been done on the dom.
  83750. * This is helpful to resume play once browser policies have been satisfied.
  83751. */
  83752. unlock(): void;
  83753. private _resumeAudioContext;
  83754. private _initializeAudioContext;
  83755. private _tryToRun;
  83756. private _triggerRunningState;
  83757. private _triggerSuspendedState;
  83758. private _displayMuteButton;
  83759. private _moveButtonToTopLeft;
  83760. private _onResize;
  83761. private _hideMuteButton;
  83762. /**
  83763. * Destroy and release the resources associated with the audio ccontext.
  83764. */
  83765. dispose(): void;
  83766. /**
  83767. * Gets the global volume sets on the master gain.
  83768. * @returns the global volume if set or -1 otherwise
  83769. */
  83770. getGlobalVolume(): number;
  83771. /**
  83772. * Sets the global volume of your experience (sets on the master gain).
  83773. * @param newVolume Defines the new global volume of the application
  83774. */
  83775. setGlobalVolume(newVolume: number): void;
  83776. /**
  83777. * Connect the audio engine to an audio analyser allowing some amazing
  83778. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  83779. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  83780. * @param analyser The analyser to connect to the engine
  83781. */
  83782. connectToAnalyser(analyser: Analyser): void;
  83783. }
  83784. }
  83785. declare module BABYLON {
  83786. /**
  83787. * Interface used to present a loading screen while loading a scene
  83788. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  83789. */
  83790. export interface ILoadingScreen {
  83791. /**
  83792. * Function called to display the loading screen
  83793. */
  83794. displayLoadingUI: () => void;
  83795. /**
  83796. * Function called to hide the loading screen
  83797. */
  83798. hideLoadingUI: () => void;
  83799. /**
  83800. * Gets or sets the color to use for the background
  83801. */
  83802. loadingUIBackgroundColor: string;
  83803. /**
  83804. * Gets or sets the text to display while loading
  83805. */
  83806. loadingUIText: string;
  83807. }
  83808. /**
  83809. * Class used for the default loading screen
  83810. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  83811. */
  83812. export class DefaultLoadingScreen implements ILoadingScreen {
  83813. private _renderingCanvas;
  83814. private _loadingText;
  83815. private _loadingDivBackgroundColor;
  83816. private _loadingDiv;
  83817. private _loadingTextDiv;
  83818. /**
  83819. * Creates a new default loading screen
  83820. * @param _renderingCanvas defines the canvas used to render the scene
  83821. * @param _loadingText defines the default text to display
  83822. * @param _loadingDivBackgroundColor defines the default background color
  83823. */
  83824. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  83825. /**
  83826. * Function called to display the loading screen
  83827. */
  83828. displayLoadingUI(): void;
  83829. /**
  83830. * Function called to hide the loading screen
  83831. */
  83832. hideLoadingUI(): void;
  83833. /**
  83834. * Gets or sets the text to display while loading
  83835. */
  83836. loadingUIText: string;
  83837. /**
  83838. * Gets or sets the color to use for the background
  83839. */
  83840. loadingUIBackgroundColor: string;
  83841. private _resizeLoadingUI;
  83842. }
  83843. }
  83844. declare module BABYLON {
  83845. /**
  83846. * Settings for finer control over video usage
  83847. */
  83848. export interface VideoTextureSettings {
  83849. /**
  83850. * Applies `autoplay` to video, if specified
  83851. */
  83852. autoPlay?: boolean;
  83853. /**
  83854. * Applies `loop` to video, if specified
  83855. */
  83856. loop?: boolean;
  83857. /**
  83858. * Automatically updates internal texture from video at every frame in the render loop
  83859. */
  83860. autoUpdateTexture: boolean;
  83861. /**
  83862. * Image src displayed during the video loading or until the user interacts with the video.
  83863. */
  83864. poster?: string;
  83865. }
  83866. /**
  83867. * If you want to display a video in your scene, this is the special texture for that.
  83868. * This special texture works similar to other textures, with the exception of a few parameters.
  83869. * @see https://doc.babylonjs.com/how_to/video_texture
  83870. */
  83871. export class VideoTexture extends Texture {
  83872. /**
  83873. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  83874. */
  83875. readonly autoUpdateTexture: boolean;
  83876. /**
  83877. * The video instance used by the texture internally
  83878. */
  83879. readonly video: HTMLVideoElement;
  83880. private _onUserActionRequestedObservable;
  83881. /**
  83882. * Event triggerd when a dom action is required by the user to play the video.
  83883. * This happens due to recent changes in browser policies preventing video to auto start.
  83884. */
  83885. readonly onUserActionRequestedObservable: Observable<Texture>;
  83886. private _generateMipMaps;
  83887. private _engine;
  83888. private _stillImageCaptured;
  83889. private _displayingPosterTexture;
  83890. private _settings;
  83891. private _createInternalTextureOnEvent;
  83892. /**
  83893. * Creates a video texture.
  83894. * If you want to display a video in your scene, this is the special texture for that.
  83895. * This special texture works similar to other textures, with the exception of a few parameters.
  83896. * @see https://doc.babylonjs.com/how_to/video_texture
  83897. * @param name optional name, will detect from video source, if not defined
  83898. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  83899. * @param scene is obviously the current scene.
  83900. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  83901. * @param invertY is false by default but can be used to invert video on Y axis
  83902. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  83903. * @param settings allows finer control over video usage
  83904. */
  83905. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  83906. private _getName;
  83907. private _getVideo;
  83908. private _createInternalTexture;
  83909. private reset;
  83910. /**
  83911. * @hidden Internal method to initiate `update`.
  83912. */
  83913. _rebuild(): void;
  83914. /**
  83915. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  83916. */
  83917. update(): void;
  83918. /**
  83919. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  83920. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  83921. */
  83922. updateTexture(isVisible: boolean): void;
  83923. protected _updateInternalTexture: () => void;
  83924. /**
  83925. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  83926. * @param url New url.
  83927. */
  83928. updateURL(url: string): void;
  83929. /**
  83930. * Dispose the texture and release its associated resources.
  83931. */
  83932. dispose(): void;
  83933. /**
  83934. * Creates a video texture straight from a stream.
  83935. * @param scene Define the scene the texture should be created in
  83936. * @param stream Define the stream the texture should be created from
  83937. * @returns The created video texture as a promise
  83938. */
  83939. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  83940. /**
  83941. * Creates a video texture straight from your WebCam video feed.
  83942. * @param scene Define the scene the texture should be created in
  83943. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  83944. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  83945. * @returns The created video texture as a promise
  83946. */
  83947. static CreateFromWebCamAsync(scene: Scene, constraints: {
  83948. minWidth: number;
  83949. maxWidth: number;
  83950. minHeight: number;
  83951. maxHeight: number;
  83952. deviceId: string;
  83953. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  83954. /**
  83955. * Creates a video texture straight from your WebCam video feed.
  83956. * @param scene Define the scene the texture should be created in
  83957. * @param onReady Define a callback to triggered once the texture will be ready
  83958. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  83959. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  83960. */
  83961. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  83962. minWidth: number;
  83963. maxWidth: number;
  83964. minHeight: number;
  83965. maxHeight: number;
  83966. deviceId: string;
  83967. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  83968. }
  83969. }
  83970. declare module BABYLON {
  83971. /**
  83972. * Interface for attribute information associated with buffer instanciation
  83973. */
  83974. export class InstancingAttributeInfo {
  83975. /**
  83976. * Index/offset of the attribute in the vertex shader
  83977. */
  83978. index: number;
  83979. /**
  83980. * size of the attribute, 1, 2, 3 or 4
  83981. */
  83982. attributeSize: number;
  83983. /**
  83984. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  83985. * default is FLOAT
  83986. */
  83987. attribyteType: number;
  83988. /**
  83989. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  83990. */
  83991. normalized: boolean;
  83992. /**
  83993. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  83994. */
  83995. offset: number;
  83996. /**
  83997. * Name of the GLSL attribute, for debugging purpose only
  83998. */
  83999. attributeName: string;
  84000. }
  84001. /**
  84002. * Define options used to create a depth texture
  84003. */
  84004. export class DepthTextureCreationOptions {
  84005. /** Specifies whether or not a stencil should be allocated in the texture */
  84006. generateStencil?: boolean;
  84007. /** Specifies whether or not bilinear filtering is enable on the texture */
  84008. bilinearFiltering?: boolean;
  84009. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  84010. comparisonFunction?: number;
  84011. /** Specifies if the created texture is a cube texture */
  84012. isCube?: boolean;
  84013. }
  84014. /**
  84015. * Class used to describe the capabilities of the engine relatively to the current browser
  84016. */
  84017. export class EngineCapabilities {
  84018. /** Maximum textures units per fragment shader */
  84019. maxTexturesImageUnits: number;
  84020. /** Maximum texture units per vertex shader */
  84021. maxVertexTextureImageUnits: number;
  84022. /** Maximum textures units in the entire pipeline */
  84023. maxCombinedTexturesImageUnits: number;
  84024. /** Maximum texture size */
  84025. maxTextureSize: number;
  84026. /** Maximum cube texture size */
  84027. maxCubemapTextureSize: number;
  84028. /** Maximum render texture size */
  84029. maxRenderTextureSize: number;
  84030. /** Maximum number of vertex attributes */
  84031. maxVertexAttribs: number;
  84032. /** Maximum number of varyings */
  84033. maxVaryingVectors: number;
  84034. /** Maximum number of uniforms per vertex shader */
  84035. maxVertexUniformVectors: number;
  84036. /** Maximum number of uniforms per fragment shader */
  84037. maxFragmentUniformVectors: number;
  84038. /** Defines if standard derivates (dx/dy) are supported */
  84039. standardDerivatives: boolean;
  84040. /** Defines if s3tc texture compression is supported */
  84041. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  84042. /** Defines if pvrtc texture compression is supported */
  84043. pvrtc: any;
  84044. /** Defines if etc1 texture compression is supported */
  84045. etc1: any;
  84046. /** Defines if etc2 texture compression is supported */
  84047. etc2: any;
  84048. /** Defines if astc texture compression is supported */
  84049. astc: any;
  84050. /** Defines if float textures are supported */
  84051. textureFloat: boolean;
  84052. /** Defines if vertex array objects are supported */
  84053. vertexArrayObject: boolean;
  84054. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  84055. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  84056. /** Gets the maximum level of anisotropy supported */
  84057. maxAnisotropy: number;
  84058. /** Defines if instancing is supported */
  84059. instancedArrays: boolean;
  84060. /** Defines if 32 bits indices are supported */
  84061. uintIndices: boolean;
  84062. /** Defines if high precision shaders are supported */
  84063. highPrecisionShaderSupported: boolean;
  84064. /** Defines if depth reading in the fragment shader is supported */
  84065. fragmentDepthSupported: boolean;
  84066. /** Defines if float texture linear filtering is supported*/
  84067. textureFloatLinearFiltering: boolean;
  84068. /** Defines if rendering to float textures is supported */
  84069. textureFloatRender: boolean;
  84070. /** Defines if half float textures are supported*/
  84071. textureHalfFloat: boolean;
  84072. /** Defines if half float texture linear filtering is supported*/
  84073. textureHalfFloatLinearFiltering: boolean;
  84074. /** Defines if rendering to half float textures is supported */
  84075. textureHalfFloatRender: boolean;
  84076. /** Defines if textureLOD shader command is supported */
  84077. textureLOD: boolean;
  84078. /** Defines if draw buffers extension is supported */
  84079. drawBuffersExtension: boolean;
  84080. /** Defines if depth textures are supported */
  84081. depthTextureExtension: boolean;
  84082. /** Defines if float color buffer are supported */
  84083. colorBufferFloat: boolean;
  84084. /** Gets disjoint timer query extension (null if not supported) */
  84085. timerQuery: EXT_disjoint_timer_query;
  84086. /** Defines if timestamp can be used with timer query */
  84087. canUseTimestampForTimerQuery: boolean;
  84088. /** Function used to let the system compiles shaders in background */
  84089. parallelShaderCompile: {
  84090. MAX_SHADER_COMPILER_THREADS_KHR: number;
  84091. maxShaderCompilerThreadsKHR: (thread: number) => void;
  84092. COMPLETION_STATUS_KHR: number;
  84093. };
  84094. }
  84095. /** Interface defining initialization parameters for Engine class */
  84096. export interface EngineOptions extends WebGLContextAttributes {
  84097. /**
  84098. * Defines if the engine should no exceed a specified device ratio
  84099. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  84100. */
  84101. limitDeviceRatio?: number;
  84102. /**
  84103. * Defines if webvr should be enabled automatically
  84104. * @see http://doc.babylonjs.com/how_to/webvr_camera
  84105. */
  84106. autoEnableWebVR?: boolean;
  84107. /**
  84108. * Defines if webgl2 should be turned off even if supported
  84109. * @see http://doc.babylonjs.com/features/webgl2
  84110. */
  84111. disableWebGL2Support?: boolean;
  84112. /**
  84113. * Defines if webaudio should be initialized as well
  84114. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  84115. */
  84116. audioEngine?: boolean;
  84117. /**
  84118. * Defines if animations should run using a deterministic lock step
  84119. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  84120. */
  84121. deterministicLockstep?: boolean;
  84122. /** Defines the maximum steps to use with deterministic lock step mode */
  84123. lockstepMaxSteps?: number;
  84124. /**
  84125. * Defines that engine should ignore context lost events
  84126. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  84127. */
  84128. doNotHandleContextLost?: boolean;
  84129. /**
  84130. * Defines that engine should ignore modifying touch action attribute and style
  84131. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  84132. */
  84133. doNotHandleTouchAction?: boolean;
  84134. /**
  84135. * Defines that engine should compile shaders with high precision floats (if supported). False by default
  84136. */
  84137. useHighPrecisionFloats?: boolean;
  84138. }
  84139. /**
  84140. * Defines the interface used by display changed events
  84141. */
  84142. export interface IDisplayChangedEventArgs {
  84143. /** Gets the vrDisplay object (if any) */
  84144. vrDisplay: Nullable<any>;
  84145. /** Gets a boolean indicating if webVR is supported */
  84146. vrSupported: boolean;
  84147. }
  84148. /**
  84149. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  84150. */
  84151. export class Engine {
  84152. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  84153. static ExceptionList: ({
  84154. key: string;
  84155. capture: string;
  84156. captureConstraint: number;
  84157. targets: string[];
  84158. } | {
  84159. key: string;
  84160. capture: null;
  84161. captureConstraint: null;
  84162. targets: string[];
  84163. })[];
  84164. /** Gets the list of created engines */
  84165. static readonly Instances: Engine[];
  84166. /**
  84167. * Gets the latest created engine
  84168. */
  84169. static readonly LastCreatedEngine: Nullable<Engine>;
  84170. /**
  84171. * Gets the latest created scene
  84172. */
  84173. static readonly LastCreatedScene: Nullable<Scene>;
  84174. /**
  84175. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  84176. * @param flag defines which part of the materials must be marked as dirty
  84177. * @param predicate defines a predicate used to filter which materials should be affected
  84178. */
  84179. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  84180. /**
  84181. * Hidden
  84182. */
  84183. static _TextureLoaders: IInternalTextureLoader[];
  84184. /** Defines that alpha blending is disabled */
  84185. static readonly ALPHA_DISABLE: number;
  84186. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  84187. static readonly ALPHA_ADD: number;
  84188. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  84189. static readonly ALPHA_COMBINE: number;
  84190. /** Defines that alpha blending to DEST - SRC * DEST */
  84191. static readonly ALPHA_SUBTRACT: number;
  84192. /** Defines that alpha blending to SRC * DEST */
  84193. static readonly ALPHA_MULTIPLY: number;
  84194. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  84195. static readonly ALPHA_MAXIMIZED: number;
  84196. /** Defines that alpha blending to SRC + DEST */
  84197. static readonly ALPHA_ONEONE: number;
  84198. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  84199. static readonly ALPHA_PREMULTIPLIED: number;
  84200. /**
  84201. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  84202. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  84203. */
  84204. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  84205. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  84206. static readonly ALPHA_INTERPOLATE: number;
  84207. /**
  84208. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  84209. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  84210. */
  84211. static readonly ALPHA_SCREENMODE: number;
  84212. /** Defines that the ressource is not delayed*/
  84213. static readonly DELAYLOADSTATE_NONE: number;
  84214. /** Defines that the ressource was successfully delay loaded */
  84215. static readonly DELAYLOADSTATE_LOADED: number;
  84216. /** Defines that the ressource is currently delay loading */
  84217. static readonly DELAYLOADSTATE_LOADING: number;
  84218. /** Defines that the ressource is delayed and has not started loading */
  84219. static readonly DELAYLOADSTATE_NOTLOADED: number;
  84220. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  84221. static readonly NEVER: number;
  84222. /** 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 */
  84223. static readonly ALWAYS: number;
  84224. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  84225. static readonly LESS: number;
  84226. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  84227. static readonly EQUAL: number;
  84228. /** 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 */
  84229. static readonly LEQUAL: number;
  84230. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  84231. static readonly GREATER: number;
  84232. /** 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 */
  84233. static readonly GEQUAL: number;
  84234. /** 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 */
  84235. static readonly NOTEQUAL: number;
  84236. /** Passed to stencilOperation to specify that stencil value must be kept */
  84237. static readonly KEEP: number;
  84238. /** Passed to stencilOperation to specify that stencil value must be replaced */
  84239. static readonly REPLACE: number;
  84240. /** Passed to stencilOperation to specify that stencil value must be incremented */
  84241. static readonly INCR: number;
  84242. /** Passed to stencilOperation to specify that stencil value must be decremented */
  84243. static readonly DECR: number;
  84244. /** Passed to stencilOperation to specify that stencil value must be inverted */
  84245. static readonly INVERT: number;
  84246. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  84247. static readonly INCR_WRAP: number;
  84248. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  84249. static readonly DECR_WRAP: number;
  84250. /** Texture is not repeating outside of 0..1 UVs */
  84251. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  84252. /** Texture is repeating outside of 0..1 UVs */
  84253. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  84254. /** Texture is repeating and mirrored */
  84255. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  84256. /** ALPHA */
  84257. static readonly TEXTUREFORMAT_ALPHA: number;
  84258. /** LUMINANCE */
  84259. static readonly TEXTUREFORMAT_LUMINANCE: number;
  84260. /** LUMINANCE_ALPHA */
  84261. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  84262. /** RGB */
  84263. static readonly TEXTUREFORMAT_RGB: number;
  84264. /** RGBA */
  84265. static readonly TEXTUREFORMAT_RGBA: number;
  84266. /** RED */
  84267. static readonly TEXTUREFORMAT_RED: number;
  84268. /** RED (2nd reference) */
  84269. static readonly TEXTUREFORMAT_R: number;
  84270. /** RG */
  84271. static readonly TEXTUREFORMAT_RG: number;
  84272. /** RED_INTEGER */
  84273. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  84274. /** RED_INTEGER (2nd reference) */
  84275. static readonly TEXTUREFORMAT_R_INTEGER: number;
  84276. /** RG_INTEGER */
  84277. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  84278. /** RGB_INTEGER */
  84279. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  84280. /** RGBA_INTEGER */
  84281. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  84282. /** UNSIGNED_BYTE */
  84283. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  84284. /** UNSIGNED_BYTE (2nd reference) */
  84285. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  84286. /** FLOAT */
  84287. static readonly TEXTURETYPE_FLOAT: number;
  84288. /** HALF_FLOAT */
  84289. static readonly TEXTURETYPE_HALF_FLOAT: number;
  84290. /** BYTE */
  84291. static readonly TEXTURETYPE_BYTE: number;
  84292. /** SHORT */
  84293. static readonly TEXTURETYPE_SHORT: number;
  84294. /** UNSIGNED_SHORT */
  84295. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  84296. /** INT */
  84297. static readonly TEXTURETYPE_INT: number;
  84298. /** UNSIGNED_INT */
  84299. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  84300. /** UNSIGNED_SHORT_4_4_4_4 */
  84301. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  84302. /** UNSIGNED_SHORT_5_5_5_1 */
  84303. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  84304. /** UNSIGNED_SHORT_5_6_5 */
  84305. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  84306. /** UNSIGNED_INT_2_10_10_10_REV */
  84307. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  84308. /** UNSIGNED_INT_24_8 */
  84309. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  84310. /** UNSIGNED_INT_10F_11F_11F_REV */
  84311. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  84312. /** UNSIGNED_INT_5_9_9_9_REV */
  84313. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  84314. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  84315. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  84316. /** nearest is mag = nearest and min = nearest and mip = linear */
  84317. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  84318. /** Bilinear is mag = linear and min = linear and mip = nearest */
  84319. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  84320. /** Trilinear is mag = linear and min = linear and mip = linear */
  84321. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  84322. /** nearest is mag = nearest and min = nearest and mip = linear */
  84323. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  84324. /** Bilinear is mag = linear and min = linear and mip = nearest */
  84325. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  84326. /** Trilinear is mag = linear and min = linear and mip = linear */
  84327. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  84328. /** mag = nearest and min = nearest and mip = nearest */
  84329. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  84330. /** mag = nearest and min = linear and mip = nearest */
  84331. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  84332. /** mag = nearest and min = linear and mip = linear */
  84333. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  84334. /** mag = nearest and min = linear and mip = none */
  84335. static readonly TEXTURE_NEAREST_LINEAR: number;
  84336. /** mag = nearest and min = nearest and mip = none */
  84337. static readonly TEXTURE_NEAREST_NEAREST: number;
  84338. /** mag = linear and min = nearest and mip = nearest */
  84339. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  84340. /** mag = linear and min = nearest and mip = linear */
  84341. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  84342. /** mag = linear and min = linear and mip = none */
  84343. static readonly TEXTURE_LINEAR_LINEAR: number;
  84344. /** mag = linear and min = nearest and mip = none */
  84345. static readonly TEXTURE_LINEAR_NEAREST: number;
  84346. /** Explicit coordinates mode */
  84347. static readonly TEXTURE_EXPLICIT_MODE: number;
  84348. /** Spherical coordinates mode */
  84349. static readonly TEXTURE_SPHERICAL_MODE: number;
  84350. /** Planar coordinates mode */
  84351. static readonly TEXTURE_PLANAR_MODE: number;
  84352. /** Cubic coordinates mode */
  84353. static readonly TEXTURE_CUBIC_MODE: number;
  84354. /** Projection coordinates mode */
  84355. static readonly TEXTURE_PROJECTION_MODE: number;
  84356. /** Skybox coordinates mode */
  84357. static readonly TEXTURE_SKYBOX_MODE: number;
  84358. /** Inverse Cubic coordinates mode */
  84359. static readonly TEXTURE_INVCUBIC_MODE: number;
  84360. /** Equirectangular coordinates mode */
  84361. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  84362. /** Equirectangular Fixed coordinates mode */
  84363. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  84364. /** Equirectangular Fixed Mirrored coordinates mode */
  84365. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  84366. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  84367. static readonly SCALEMODE_FLOOR: number;
  84368. /** Defines that texture rescaling will look for the nearest power of 2 size */
  84369. static readonly SCALEMODE_NEAREST: number;
  84370. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  84371. static readonly SCALEMODE_CEILING: number;
  84372. /**
  84373. * Returns the current version of the framework
  84374. */
  84375. static readonly Version: string;
  84376. /**
  84377. * Returns a string describing the current engine
  84378. */
  84379. readonly description: string;
  84380. /**
  84381. * Gets or sets the epsilon value used by collision engine
  84382. */
  84383. static CollisionsEpsilon: number;
  84384. /**
  84385. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  84386. */
  84387. static ShadersRepository: string;
  84388. /**
  84389. * Method called to create the default loading screen.
  84390. * This can be overriden in your own app.
  84391. * @param canvas The rendering canvas element
  84392. * @returns The loading screen
  84393. */
  84394. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  84395. /**
  84396. * Method called to create the default rescale post process on each engine.
  84397. */
  84398. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  84399. /**
  84400. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  84401. */
  84402. forcePOTTextures: boolean;
  84403. /**
  84404. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  84405. */
  84406. isFullscreen: boolean;
  84407. /**
  84408. * Gets a boolean indicating if the pointer is currently locked
  84409. */
  84410. isPointerLock: boolean;
  84411. /**
  84412. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  84413. */
  84414. cullBackFaces: boolean;
  84415. /**
  84416. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  84417. */
  84418. renderEvenInBackground: boolean;
  84419. /**
  84420. * Gets or sets a boolean indicating that cache can be kept between frames
  84421. */
  84422. preventCacheWipeBetweenFrames: boolean;
  84423. /**
  84424. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  84425. **/
  84426. enableOfflineSupport: boolean;
  84427. /**
  84428. * 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)
  84429. **/
  84430. disableManifestCheck: boolean;
  84431. /**
  84432. * Gets the list of created scenes
  84433. */
  84434. scenes: Scene[];
  84435. /**
  84436. * Event raised when a new scene is created
  84437. */
  84438. onNewSceneAddedObservable: Observable<Scene>;
  84439. /**
  84440. * Gets the list of created postprocesses
  84441. */
  84442. postProcesses: PostProcess[];
  84443. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  84444. validateShaderPrograms: boolean;
  84445. /**
  84446. * Observable event triggered each time the rendering canvas is resized
  84447. */
  84448. onResizeObservable: Observable<Engine>;
  84449. /**
  84450. * Observable event triggered each time the canvas loses focus
  84451. */
  84452. onCanvasBlurObservable: Observable<Engine>;
  84453. /**
  84454. * Observable event triggered each time the canvas gains focus
  84455. */
  84456. onCanvasFocusObservable: Observable<Engine>;
  84457. /**
  84458. * Observable event triggered each time the canvas receives pointerout event
  84459. */
  84460. onCanvasPointerOutObservable: Observable<PointerEvent>;
  84461. /**
  84462. * Observable event triggered before each texture is initialized
  84463. */
  84464. onBeforeTextureInitObservable: Observable<Texture>;
  84465. private _vrDisplay;
  84466. private _vrSupported;
  84467. private _oldSize;
  84468. private _oldHardwareScaleFactor;
  84469. private _vrExclusivePointerMode;
  84470. private _webVRInitPromise;
  84471. /**
  84472. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  84473. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  84474. */
  84475. readonly isInVRExclusivePointerMode: boolean;
  84476. /**
  84477. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  84478. */
  84479. disableUniformBuffers: boolean;
  84480. /** @hidden */
  84481. _uniformBuffers: UniformBuffer[];
  84482. /**
  84483. * Gets a boolean indicating that the engine supports uniform buffers
  84484. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84485. */
  84486. readonly supportsUniformBuffers: boolean;
  84487. /**
  84488. * Observable raised when the engine begins a new frame
  84489. */
  84490. onBeginFrameObservable: Observable<Engine>;
  84491. /**
  84492. * If set, will be used to request the next animation frame for the render loop
  84493. */
  84494. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  84495. /**
  84496. * Observable raised when the engine ends the current frame
  84497. */
  84498. onEndFrameObservable: Observable<Engine>;
  84499. /**
  84500. * Observable raised when the engine is about to compile a shader
  84501. */
  84502. onBeforeShaderCompilationObservable: Observable<Engine>;
  84503. /**
  84504. * Observable raised when the engine has jsut compiled a shader
  84505. */
  84506. onAfterShaderCompilationObservable: Observable<Engine>;
  84507. /** @hidden */
  84508. _gl: WebGLRenderingContext;
  84509. private _renderingCanvas;
  84510. private _windowIsBackground;
  84511. private _webGLVersion;
  84512. private _highPrecisionShadersAllowed;
  84513. /** @hidden */
  84514. readonly _shouldUseHighPrecisionShader: boolean;
  84515. /**
  84516. * Gets a boolean indicating that only power of 2 textures are supported
  84517. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  84518. */
  84519. readonly needPOTTextures: boolean;
  84520. /** @hidden */
  84521. _badOS: boolean;
  84522. /** @hidden */
  84523. _badDesktopOS: boolean;
  84524. /**
  84525. * Gets or sets a value indicating if we want to disable texture binding optimization.
  84526. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  84527. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  84528. */
  84529. disableTextureBindingOptimization: boolean;
  84530. /**
  84531. * Gets the audio engine
  84532. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  84533. * @ignorenaming
  84534. */
  84535. static audioEngine: IAudioEngine;
  84536. /**
  84537. * Default AudioEngine factory responsible of creating the Audio Engine.
  84538. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  84539. */
  84540. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  84541. /**
  84542. * Default offline support factory responsible of creating a tool used to store data locally.
  84543. * By default, this will create a Database object if the workload has been embedded.
  84544. */
  84545. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  84546. private _onFocus;
  84547. private _onBlur;
  84548. private _onCanvasPointerOut;
  84549. private _onCanvasBlur;
  84550. private _onCanvasFocus;
  84551. private _onFullscreenChange;
  84552. private _onPointerLockChange;
  84553. private _onVRDisplayPointerRestricted;
  84554. private _onVRDisplayPointerUnrestricted;
  84555. private _onVrDisplayConnect;
  84556. private _onVrDisplayDisconnect;
  84557. private _onVrDisplayPresentChange;
  84558. /**
  84559. * Observable signaled when VR display mode changes
  84560. */
  84561. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  84562. /**
  84563. * Observable signaled when VR request present is complete
  84564. */
  84565. onVRRequestPresentComplete: Observable<boolean>;
  84566. /**
  84567. * Observable signaled when VR request present starts
  84568. */
  84569. onVRRequestPresentStart: Observable<Engine>;
  84570. private _hardwareScalingLevel;
  84571. /** @hidden */
  84572. protected _caps: EngineCapabilities;
  84573. private _pointerLockRequested;
  84574. private _isStencilEnable;
  84575. private _colorWrite;
  84576. private _loadingScreen;
  84577. /** @hidden */
  84578. _drawCalls: PerfCounter;
  84579. /** @hidden */
  84580. _textureCollisions: PerfCounter;
  84581. private _glVersion;
  84582. private _glRenderer;
  84583. private _glVendor;
  84584. private _videoTextureSupported;
  84585. private _renderingQueueLaunched;
  84586. private _activeRenderLoops;
  84587. private _deterministicLockstep;
  84588. private _lockstepMaxSteps;
  84589. /**
  84590. * Observable signaled when a context lost event is raised
  84591. */
  84592. onContextLostObservable: Observable<Engine>;
  84593. /**
  84594. * Observable signaled when a context restored event is raised
  84595. */
  84596. onContextRestoredObservable: Observable<Engine>;
  84597. private _onContextLost;
  84598. private _onContextRestored;
  84599. private _contextWasLost;
  84600. private _doNotHandleContextLost;
  84601. /**
  84602. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  84603. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  84604. */
  84605. doNotHandleContextLost: boolean;
  84606. private _performanceMonitor;
  84607. private _fps;
  84608. private _deltaTime;
  84609. /**
  84610. * Turn this value on if you want to pause FPS computation when in background
  84611. */
  84612. disablePerformanceMonitorInBackground: boolean;
  84613. /**
  84614. * Gets the performance monitor attached to this engine
  84615. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  84616. */
  84617. readonly performanceMonitor: PerformanceMonitor;
  84618. /** @hidden */
  84619. protected _depthCullingState: _DepthCullingState;
  84620. /** @hidden */
  84621. protected _stencilState: _StencilState;
  84622. /** @hidden */
  84623. protected _alphaState: _AlphaState;
  84624. /** @hidden */
  84625. protected _alphaMode: number;
  84626. protected _internalTexturesCache: InternalTexture[];
  84627. /** @hidden */
  84628. protected _activeChannel: number;
  84629. private _currentTextureChannel;
  84630. /** @hidden */
  84631. protected _boundTexturesCache: {
  84632. [key: string]: Nullable<InternalTexture>;
  84633. };
  84634. /** @hidden */
  84635. protected _currentEffect: Nullable<Effect>;
  84636. /** @hidden */
  84637. protected _currentProgram: Nullable<WebGLProgram>;
  84638. private _compiledEffects;
  84639. private _vertexAttribArraysEnabled;
  84640. /** @hidden */
  84641. protected _cachedViewport: Nullable<Viewport>;
  84642. private _cachedVertexArrayObject;
  84643. /** @hidden */
  84644. protected _cachedVertexBuffers: any;
  84645. /** @hidden */
  84646. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  84647. /** @hidden */
  84648. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  84649. /** @hidden */
  84650. protected _currentRenderTarget: Nullable<InternalTexture>;
  84651. private _uintIndicesCurrentlySet;
  84652. private _currentBoundBuffer;
  84653. /** @hidden */
  84654. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  84655. private _currentBufferPointers;
  84656. private _currentInstanceLocations;
  84657. private _currentInstanceBuffers;
  84658. private _textureUnits;
  84659. private _firstBoundInternalTextureTracker;
  84660. private _lastBoundInternalTextureTracker;
  84661. private _workingCanvas;
  84662. private _workingContext;
  84663. private _rescalePostProcess;
  84664. private _dummyFramebuffer;
  84665. private _externalData;
  84666. private _bindedRenderFunction;
  84667. private _vaoRecordInProgress;
  84668. private _mustWipeVertexAttributes;
  84669. private _emptyTexture;
  84670. private _emptyCubeTexture;
  84671. private _emptyTexture3D;
  84672. /** @hidden */
  84673. _frameHandler: number;
  84674. private _nextFreeTextureSlots;
  84675. private _maxSimultaneousTextures;
  84676. private _activeRequests;
  84677. private _texturesSupported;
  84678. private _textureFormatInUse;
  84679. /**
  84680. * Gets the list of texture formats supported
  84681. */
  84682. readonly texturesSupported: Array<string>;
  84683. /**
  84684. * Gets the list of texture formats in use
  84685. */
  84686. readonly textureFormatInUse: Nullable<string>;
  84687. /**
  84688. * Gets the current viewport
  84689. */
  84690. readonly currentViewport: Nullable<Viewport>;
  84691. /**
  84692. * Gets the default empty texture
  84693. */
  84694. readonly emptyTexture: InternalTexture;
  84695. /**
  84696. * Gets the default empty 3D texture
  84697. */
  84698. readonly emptyTexture3D: InternalTexture;
  84699. /**
  84700. * Gets the default empty cube texture
  84701. */
  84702. readonly emptyCubeTexture: InternalTexture;
  84703. /**
  84704. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  84705. */
  84706. readonly premultipliedAlpha: boolean;
  84707. /**
  84708. * Creates a new engine
  84709. * @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
  84710. * @param antialias defines enable antialiasing (default: false)
  84711. * @param options defines further options to be sent to the getContext() function
  84712. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  84713. */
  84714. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  84715. private _disableTouchAction;
  84716. private _rebuildInternalTextures;
  84717. private _rebuildEffects;
  84718. /**
  84719. * Gets a boolean indicating if all created effects are ready
  84720. * @returns true if all effects are ready
  84721. */
  84722. areAllEffectsReady(): boolean;
  84723. private _rebuildBuffers;
  84724. private _initGLContext;
  84725. /**
  84726. * Gets version of the current webGL context
  84727. */
  84728. readonly webGLVersion: number;
  84729. /**
  84730. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  84731. */
  84732. readonly isStencilEnable: boolean;
  84733. private _prepareWorkingCanvas;
  84734. /**
  84735. * Reset the texture cache to empty state
  84736. */
  84737. resetTextureCache(): void;
  84738. /**
  84739. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  84740. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  84741. * @returns true if engine is in deterministic lock step mode
  84742. */
  84743. isDeterministicLockStep(): boolean;
  84744. /**
  84745. * Gets the max steps when engine is running in deterministic lock step
  84746. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  84747. * @returns the max steps
  84748. */
  84749. getLockstepMaxSteps(): number;
  84750. /**
  84751. * Gets an object containing information about the current webGL context
  84752. * @returns an object containing the vender, the renderer and the version of the current webGL context
  84753. */
  84754. getGlInfo(): {
  84755. vendor: string;
  84756. renderer: string;
  84757. version: string;
  84758. };
  84759. /**
  84760. * Gets current aspect ratio
  84761. * @param camera defines the camera to use to get the aspect ratio
  84762. * @param useScreen defines if screen size must be used (or the current render target if any)
  84763. * @returns a number defining the aspect ratio
  84764. */
  84765. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  84766. /**
  84767. * Gets current screen aspect ratio
  84768. * @returns a number defining the aspect ratio
  84769. */
  84770. getScreenAspectRatio(): number;
  84771. /**
  84772. * Gets the current render width
  84773. * @param useScreen defines if screen size must be used (or the current render target if any)
  84774. * @returns a number defining the current render width
  84775. */
  84776. getRenderWidth(useScreen?: boolean): number;
  84777. /**
  84778. * Gets the current render height
  84779. * @param useScreen defines if screen size must be used (or the current render target if any)
  84780. * @returns a number defining the current render height
  84781. */
  84782. getRenderHeight(useScreen?: boolean): number;
  84783. /**
  84784. * Gets the HTML canvas attached with the current webGL context
  84785. * @returns a HTML canvas
  84786. */
  84787. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  84788. /**
  84789. * Gets the client rect of the HTML canvas attached with the current webGL context
  84790. * @returns a client rectanglee
  84791. */
  84792. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  84793. /**
  84794. * Defines the hardware scaling level.
  84795. * By default the hardware scaling level is computed from the window device ratio.
  84796. * 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.
  84797. * @param level defines the level to use
  84798. */
  84799. setHardwareScalingLevel(level: number): void;
  84800. /**
  84801. * Gets the current hardware scaling level.
  84802. * By default the hardware scaling level is computed from the window device ratio.
  84803. * 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.
  84804. * @returns a number indicating the current hardware scaling level
  84805. */
  84806. getHardwareScalingLevel(): number;
  84807. /**
  84808. * Gets the list of loaded textures
  84809. * @returns an array containing all loaded textures
  84810. */
  84811. getLoadedTexturesCache(): InternalTexture[];
  84812. /**
  84813. * Gets the object containing all engine capabilities
  84814. * @returns the EngineCapabilities object
  84815. */
  84816. getCaps(): EngineCapabilities;
  84817. /**
  84818. * Gets the current depth function
  84819. * @returns a number defining the depth function
  84820. */
  84821. getDepthFunction(): Nullable<number>;
  84822. /**
  84823. * Sets the current depth function
  84824. * @param depthFunc defines the function to use
  84825. */
  84826. setDepthFunction(depthFunc: number): void;
  84827. /**
  84828. * Sets the current depth function to GREATER
  84829. */
  84830. setDepthFunctionToGreater(): void;
  84831. /**
  84832. * Sets the current depth function to GEQUAL
  84833. */
  84834. setDepthFunctionToGreaterOrEqual(): void;
  84835. /**
  84836. * Sets the current depth function to LESS
  84837. */
  84838. setDepthFunctionToLess(): void;
  84839. /**
  84840. * Sets the current depth function to LEQUAL
  84841. */
  84842. setDepthFunctionToLessOrEqual(): void;
  84843. /**
  84844. * Gets a boolean indicating if stencil buffer is enabled
  84845. * @returns the current stencil buffer state
  84846. */
  84847. getStencilBuffer(): boolean;
  84848. /**
  84849. * Enable or disable the stencil buffer
  84850. * @param enable defines if the stencil buffer must be enabled or disabled
  84851. */
  84852. setStencilBuffer(enable: boolean): void;
  84853. /**
  84854. * Gets the current stencil mask
  84855. * @returns a number defining the new stencil mask to use
  84856. */
  84857. getStencilMask(): number;
  84858. /**
  84859. * Sets the current stencil mask
  84860. * @param mask defines the new stencil mask to use
  84861. */
  84862. setStencilMask(mask: number): void;
  84863. /**
  84864. * Gets the current stencil function
  84865. * @returns a number defining the stencil function to use
  84866. */
  84867. getStencilFunction(): number;
  84868. /**
  84869. * Gets the current stencil reference value
  84870. * @returns a number defining the stencil reference value to use
  84871. */
  84872. getStencilFunctionReference(): number;
  84873. /**
  84874. * Gets the current stencil mask
  84875. * @returns a number defining the stencil mask to use
  84876. */
  84877. getStencilFunctionMask(): number;
  84878. /**
  84879. * Sets the current stencil function
  84880. * @param stencilFunc defines the new stencil function to use
  84881. */
  84882. setStencilFunction(stencilFunc: number): void;
  84883. /**
  84884. * Sets the current stencil reference
  84885. * @param reference defines the new stencil reference to use
  84886. */
  84887. setStencilFunctionReference(reference: number): void;
  84888. /**
  84889. * Sets the current stencil mask
  84890. * @param mask defines the new stencil mask to use
  84891. */
  84892. setStencilFunctionMask(mask: number): void;
  84893. /**
  84894. * Gets the current stencil operation when stencil fails
  84895. * @returns a number defining stencil operation to use when stencil fails
  84896. */
  84897. getStencilOperationFail(): number;
  84898. /**
  84899. * Gets the current stencil operation when depth fails
  84900. * @returns a number defining stencil operation to use when depth fails
  84901. */
  84902. getStencilOperationDepthFail(): number;
  84903. /**
  84904. * Gets the current stencil operation when stencil passes
  84905. * @returns a number defining stencil operation to use when stencil passes
  84906. */
  84907. getStencilOperationPass(): number;
  84908. /**
  84909. * Sets the stencil operation to use when stencil fails
  84910. * @param operation defines the stencil operation to use when stencil fails
  84911. */
  84912. setStencilOperationFail(operation: number): void;
  84913. /**
  84914. * Sets the stencil operation to use when depth fails
  84915. * @param operation defines the stencil operation to use when depth fails
  84916. */
  84917. setStencilOperationDepthFail(operation: number): void;
  84918. /**
  84919. * Sets the stencil operation to use when stencil passes
  84920. * @param operation defines the stencil operation to use when stencil passes
  84921. */
  84922. setStencilOperationPass(operation: number): void;
  84923. /**
  84924. * Sets a boolean indicating if the dithering state is enabled or disabled
  84925. * @param value defines the dithering state
  84926. */
  84927. setDitheringState(value: boolean): void;
  84928. /**
  84929. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  84930. * @param value defines the rasterizer state
  84931. */
  84932. setRasterizerState(value: boolean): void;
  84933. /**
  84934. * stop executing a render loop function and remove it from the execution array
  84935. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  84936. */
  84937. stopRenderLoop(renderFunction?: () => void): void;
  84938. /** @hidden */
  84939. _renderLoop(): void;
  84940. /**
  84941. * Register and execute a render loop. The engine can have more than one render function
  84942. * @param renderFunction defines the function to continuously execute
  84943. */
  84944. runRenderLoop(renderFunction: () => void): void;
  84945. /**
  84946. * Toggle full screen mode
  84947. * @param requestPointerLock defines if a pointer lock should be requested from the user
  84948. */
  84949. switchFullscreen(requestPointerLock: boolean): void;
  84950. /**
  84951. * Enters full screen mode
  84952. * @param requestPointerLock defines if a pointer lock should be requested from the user
  84953. */
  84954. enterFullscreen(requestPointerLock: boolean): void;
  84955. /**
  84956. * Exits full screen mode
  84957. */
  84958. exitFullscreen(): void;
  84959. /**
  84960. * Clear the current render buffer or the current render target (if any is set up)
  84961. * @param color defines the color to use
  84962. * @param backBuffer defines if the back buffer must be cleared
  84963. * @param depth defines if the depth buffer must be cleared
  84964. * @param stencil defines if the stencil buffer must be cleared
  84965. */
  84966. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  84967. /**
  84968. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  84969. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  84970. * @param y defines the y-coordinate of the corner of the clear rectangle
  84971. * @param width defines the width of the clear rectangle
  84972. * @param height defines the height of the clear rectangle
  84973. * @param clearColor defines the clear color
  84974. */
  84975. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  84976. /**
  84977. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  84978. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  84979. * @param y defines the y-coordinate of the corner of the clear rectangle
  84980. * @param width defines the width of the clear rectangle
  84981. * @param height defines the height of the clear rectangle
  84982. */
  84983. enableScissor(x: number, y: number, width: number, height: number): void;
  84984. /**
  84985. * Disable previously set scissor test rectangle
  84986. */
  84987. disableScissor(): void;
  84988. private _viewportCached;
  84989. /** @hidden */
  84990. _viewport(x: number, y: number, width: number, height: number): void;
  84991. /**
  84992. * Set the WebGL's viewport
  84993. * @param viewport defines the viewport element to be used
  84994. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  84995. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  84996. */
  84997. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  84998. /**
  84999. * Directly set the WebGL Viewport
  85000. * @param x defines the x coordinate of the viewport (in screen space)
  85001. * @param y defines the y coordinate of the viewport (in screen space)
  85002. * @param width defines the width of the viewport (in screen space)
  85003. * @param height defines the height of the viewport (in screen space)
  85004. * @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
  85005. */
  85006. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  85007. /**
  85008. * Begin a new frame
  85009. */
  85010. beginFrame(): void;
  85011. /**
  85012. * Enf the current frame
  85013. */
  85014. endFrame(): void;
  85015. /**
  85016. * Resize the view according to the canvas' size
  85017. */
  85018. resize(): void;
  85019. /**
  85020. * Force a specific size of the canvas
  85021. * @param width defines the new canvas' width
  85022. * @param height defines the new canvas' height
  85023. */
  85024. setSize(width: number, height: number): void;
  85025. /**
  85026. * Gets a boolean indicating if a webVR device was detected
  85027. * @returns true if a webVR device was detected
  85028. */
  85029. isVRDevicePresent(): boolean;
  85030. /**
  85031. * Gets the current webVR device
  85032. * @returns the current webVR device (or null)
  85033. */
  85034. getVRDevice(): any;
  85035. /**
  85036. * Initializes a webVR display and starts listening to display change events
  85037. * The onVRDisplayChangedObservable will be notified upon these changes
  85038. * @returns The onVRDisplayChangedObservable
  85039. */
  85040. initWebVR(): Observable<IDisplayChangedEventArgs>;
  85041. /**
  85042. * Initializes a webVR display and starts listening to display change events
  85043. * The onVRDisplayChangedObservable will be notified upon these changes
  85044. * @returns A promise containing a VRDisplay and if vr is supported
  85045. */
  85046. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  85047. /**
  85048. * Call this function to switch to webVR mode
  85049. * Will do nothing if webVR is not supported or if there is no webVR device
  85050. * @see http://doc.babylonjs.com/how_to/webvr_camera
  85051. */
  85052. enableVR(): void;
  85053. /**
  85054. * Call this function to leave webVR mode
  85055. * Will do nothing if webVR is not supported or if there is no webVR device
  85056. * @see http://doc.babylonjs.com/how_to/webvr_camera
  85057. */
  85058. disableVR(): void;
  85059. private _onVRFullScreenTriggered;
  85060. private _getVRDisplaysAsync;
  85061. /**
  85062. * Binds the frame buffer to the specified texture.
  85063. * @param texture The texture to render to or null for the default canvas
  85064. * @param faceIndex The face of the texture to render to in case of cube texture
  85065. * @param requiredWidth The width of the target to render to
  85066. * @param requiredHeight The height of the target to render to
  85067. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  85068. * @param depthStencilTexture The depth stencil texture to use to render
  85069. * @param lodLevel defines le lod level to bind to the frame buffer
  85070. */
  85071. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  85072. private bindUnboundFramebuffer;
  85073. /**
  85074. * Unbind the current render target texture from the webGL context
  85075. * @param texture defines the render target texture to unbind
  85076. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  85077. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  85078. */
  85079. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  85080. /**
  85081. * Unbind a list of render target textures from the webGL context
  85082. * This is used only when drawBuffer extension or webGL2 are active
  85083. * @param textures defines the render target textures to unbind
  85084. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  85085. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  85086. */
  85087. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  85088. /**
  85089. * Force the mipmap generation for the given render target texture
  85090. * @param texture defines the render target texture to use
  85091. */
  85092. generateMipMapsForCubemap(texture: InternalTexture): void;
  85093. /**
  85094. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  85095. */
  85096. flushFramebuffer(): void;
  85097. /**
  85098. * Unbind the current render target and bind the default framebuffer
  85099. */
  85100. restoreDefaultFramebuffer(): void;
  85101. /**
  85102. * Create an uniform buffer
  85103. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85104. * @param elements defines the content of the uniform buffer
  85105. * @returns the webGL uniform buffer
  85106. */
  85107. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  85108. /**
  85109. * Create a dynamic uniform buffer
  85110. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85111. * @param elements defines the content of the uniform buffer
  85112. * @returns the webGL uniform buffer
  85113. */
  85114. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  85115. /**
  85116. * Update an existing uniform buffer
  85117. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85118. * @param uniformBuffer defines the target uniform buffer
  85119. * @param elements defines the content to update
  85120. * @param offset defines the offset in the uniform buffer where update should start
  85121. * @param count defines the size of the data to update
  85122. */
  85123. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  85124. private _resetVertexBufferBinding;
  85125. /**
  85126. * Creates a vertex buffer
  85127. * @param data the data for the vertex buffer
  85128. * @returns the new WebGL static buffer
  85129. */
  85130. createVertexBuffer(data: DataArray): WebGLBuffer;
  85131. /**
  85132. * Creates a dynamic vertex buffer
  85133. * @param data the data for the dynamic vertex buffer
  85134. * @returns the new WebGL dynamic buffer
  85135. */
  85136. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  85137. /**
  85138. * Update a dynamic index buffer
  85139. * @param indexBuffer defines the target index buffer
  85140. * @param indices defines the data to update
  85141. * @param offset defines the offset in the target index buffer where update should start
  85142. */
  85143. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  85144. /**
  85145. * Updates a dynamic vertex buffer.
  85146. * @param vertexBuffer the vertex buffer to update
  85147. * @param data the data used to update the vertex buffer
  85148. * @param byteOffset the byte offset of the data
  85149. * @param byteLength the byte length of the data
  85150. */
  85151. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  85152. private _resetIndexBufferBinding;
  85153. /**
  85154. * Creates a new index buffer
  85155. * @param indices defines the content of the index buffer
  85156. * @param updatable defines if the index buffer must be updatable
  85157. * @returns a new webGL buffer
  85158. */
  85159. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  85160. /**
  85161. * Bind a webGL buffer to the webGL context
  85162. * @param buffer defines the buffer to bind
  85163. */
  85164. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  85165. /**
  85166. * Bind an uniform buffer to the current webGL context
  85167. * @param buffer defines the buffer to bind
  85168. */
  85169. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  85170. /**
  85171. * Bind a buffer to the current webGL context at a given location
  85172. * @param buffer defines the buffer to bind
  85173. * @param location defines the index where to bind the buffer
  85174. */
  85175. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  85176. /**
  85177. * Bind a specific block at a given index in a specific shader program
  85178. * @param shaderProgram defines the shader program
  85179. * @param blockName defines the block name
  85180. * @param index defines the index where to bind the block
  85181. */
  85182. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  85183. private bindIndexBuffer;
  85184. private bindBuffer;
  85185. /**
  85186. * update the bound buffer with the given data
  85187. * @param data defines the data to update
  85188. */
  85189. updateArrayBuffer(data: Float32Array): void;
  85190. private _vertexAttribPointer;
  85191. private _bindIndexBufferWithCache;
  85192. private _bindVertexBuffersAttributes;
  85193. /**
  85194. * Records a vertex array object
  85195. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  85196. * @param vertexBuffers defines the list of vertex buffers to store
  85197. * @param indexBuffer defines the index buffer to store
  85198. * @param effect defines the effect to store
  85199. * @returns the new vertex array object
  85200. */
  85201. recordVertexArrayObject(vertexBuffers: {
  85202. [key: string]: VertexBuffer;
  85203. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  85204. /**
  85205. * Bind a specific vertex array object
  85206. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  85207. * @param vertexArrayObject defines the vertex array object to bind
  85208. * @param indexBuffer defines the index buffer to bind
  85209. */
  85210. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  85211. /**
  85212. * Bind webGl buffers directly to the webGL context
  85213. * @param vertexBuffer defines the vertex buffer to bind
  85214. * @param indexBuffer defines the index buffer to bind
  85215. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  85216. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  85217. * @param effect defines the effect associated with the vertex buffer
  85218. */
  85219. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  85220. private _unbindVertexArrayObject;
  85221. /**
  85222. * Bind a list of vertex buffers to the webGL context
  85223. * @param vertexBuffers defines the list of vertex buffers to bind
  85224. * @param indexBuffer defines the index buffer to bind
  85225. * @param effect defines the effect associated with the vertex buffers
  85226. */
  85227. bindBuffers(vertexBuffers: {
  85228. [key: string]: Nullable<VertexBuffer>;
  85229. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  85230. /**
  85231. * Unbind all instance attributes
  85232. */
  85233. unbindInstanceAttributes(): void;
  85234. /**
  85235. * Release and free the memory of a vertex array object
  85236. * @param vao defines the vertex array object to delete
  85237. */
  85238. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  85239. /** @hidden */
  85240. _releaseBuffer(buffer: WebGLBuffer): boolean;
  85241. /**
  85242. * Creates a webGL buffer to use with instanciation
  85243. * @param capacity defines the size of the buffer
  85244. * @returns the webGL buffer
  85245. */
  85246. createInstancesBuffer(capacity: number): WebGLBuffer;
  85247. /**
  85248. * Delete a webGL buffer used with instanciation
  85249. * @param buffer defines the webGL buffer to delete
  85250. */
  85251. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  85252. /**
  85253. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  85254. * @param instancesBuffer defines the webGL buffer to update and bind
  85255. * @param data defines the data to store in the buffer
  85256. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  85257. */
  85258. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  85259. /**
  85260. * Apply all cached states (depth, culling, stencil and alpha)
  85261. */
  85262. applyStates(): void;
  85263. /**
  85264. * Send a draw order
  85265. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  85266. * @param indexStart defines the starting index
  85267. * @param indexCount defines the number of index to draw
  85268. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  85269. */
  85270. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  85271. /**
  85272. * Draw a list of points
  85273. * @param verticesStart defines the index of first vertex to draw
  85274. * @param verticesCount defines the count of vertices to draw
  85275. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  85276. */
  85277. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  85278. /**
  85279. * Draw a list of unindexed primitives
  85280. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  85281. * @param verticesStart defines the index of first vertex to draw
  85282. * @param verticesCount defines the count of vertices to draw
  85283. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  85284. */
  85285. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  85286. /**
  85287. * Draw a list of indexed primitives
  85288. * @param fillMode defines the primitive to use
  85289. * @param indexStart defines the starting index
  85290. * @param indexCount defines the number of index to draw
  85291. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  85292. */
  85293. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  85294. /**
  85295. * Draw a list of unindexed primitives
  85296. * @param fillMode defines the primitive to use
  85297. * @param verticesStart defines the index of first vertex to draw
  85298. * @param verticesCount defines the count of vertices to draw
  85299. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  85300. */
  85301. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  85302. private _drawMode;
  85303. /** @hidden */
  85304. _releaseEffect(effect: Effect): void;
  85305. /** @hidden */
  85306. _deleteProgram(program: WebGLProgram): void;
  85307. /**
  85308. * Create a new effect (used to store vertex/fragment shaders)
  85309. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  85310. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  85311. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  85312. * @param samplers defines an array of string used to represent textures
  85313. * @param defines defines the string containing the defines to use to compile the shaders
  85314. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  85315. * @param onCompiled defines a function to call when the effect creation is successful
  85316. * @param onError defines a function to call when the effect creation has failed
  85317. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  85318. * @returns the new Effect
  85319. */
  85320. 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;
  85321. private _compileShader;
  85322. private _compileRawShader;
  85323. /**
  85324. * Directly creates a webGL program
  85325. * @param vertexCode defines the vertex shader code to use
  85326. * @param fragmentCode defines the fragment shader code to use
  85327. * @param context defines the webGL context to use (if not set, the current one will be used)
  85328. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  85329. * @returns the new webGL program
  85330. */
  85331. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  85332. /**
  85333. * Creates a webGL program
  85334. * @param vertexCode defines the vertex shader code to use
  85335. * @param fragmentCode defines the fragment shader code to use
  85336. * @param defines defines the string containing the defines to use to compile the shaders
  85337. * @param context defines the webGL context to use (if not set, the current one will be used)
  85338. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  85339. * @returns the new webGL program
  85340. */
  85341. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  85342. private _createShaderProgram;
  85343. private _finalizeProgram;
  85344. /** @hidden */
  85345. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  85346. /** @hidden */
  85347. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  85348. /**
  85349. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  85350. * @param shaderProgram defines the webGL program to use
  85351. * @param uniformsNames defines the list of uniform names
  85352. * @returns an array of webGL uniform locations
  85353. */
  85354. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  85355. /**
  85356. * Gets the lsit of active attributes for a given webGL program
  85357. * @param shaderProgram defines the webGL program to use
  85358. * @param attributesNames defines the list of attribute names to get
  85359. * @returns an array of indices indicating the offset of each attribute
  85360. */
  85361. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  85362. /**
  85363. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  85364. * @param effect defines the effect to activate
  85365. */
  85366. enableEffect(effect: Nullable<Effect>): void;
  85367. /**
  85368. * Set the value of an uniform to an array of int32
  85369. * @param uniform defines the webGL uniform location where to store the value
  85370. * @param array defines the array of int32 to store
  85371. */
  85372. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  85373. /**
  85374. * Set the value of an uniform to an array of int32 (stored as vec2)
  85375. * @param uniform defines the webGL uniform location where to store the value
  85376. * @param array defines the array of int32 to store
  85377. */
  85378. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  85379. /**
  85380. * Set the value of an uniform to an array of int32 (stored as vec3)
  85381. * @param uniform defines the webGL uniform location where to store the value
  85382. * @param array defines the array of int32 to store
  85383. */
  85384. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  85385. /**
  85386. * Set the value of an uniform to an array of int32 (stored as vec4)
  85387. * @param uniform defines the webGL uniform location where to store the value
  85388. * @param array defines the array of int32 to store
  85389. */
  85390. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  85391. /**
  85392. * Set the value of an uniform to an array of float32
  85393. * @param uniform defines the webGL uniform location where to store the value
  85394. * @param array defines the array of float32 to store
  85395. */
  85396. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  85397. /**
  85398. * Set the value of an uniform to an array of float32 (stored as vec2)
  85399. * @param uniform defines the webGL uniform location where to store the value
  85400. * @param array defines the array of float32 to store
  85401. */
  85402. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  85403. /**
  85404. * Set the value of an uniform to an array of float32 (stored as vec3)
  85405. * @param uniform defines the webGL uniform location where to store the value
  85406. * @param array defines the array of float32 to store
  85407. */
  85408. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  85409. /**
  85410. * Set the value of an uniform to an array of float32 (stored as vec4)
  85411. * @param uniform defines the webGL uniform location where to store the value
  85412. * @param array defines the array of float32 to store
  85413. */
  85414. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  85415. /**
  85416. * Set the value of an uniform to an array of number
  85417. * @param uniform defines the webGL uniform location where to store the value
  85418. * @param array defines the array of number to store
  85419. */
  85420. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  85421. /**
  85422. * Set the value of an uniform to an array of number (stored as vec2)
  85423. * @param uniform defines the webGL uniform location where to store the value
  85424. * @param array defines the array of number to store
  85425. */
  85426. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  85427. /**
  85428. * Set the value of an uniform to an array of number (stored as vec3)
  85429. * @param uniform defines the webGL uniform location where to store the value
  85430. * @param array defines the array of number to store
  85431. */
  85432. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  85433. /**
  85434. * Set the value of an uniform to an array of number (stored as vec4)
  85435. * @param uniform defines the webGL uniform location where to store the value
  85436. * @param array defines the array of number to store
  85437. */
  85438. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  85439. /**
  85440. * Set the value of an uniform to an array of float32 (stored as matrices)
  85441. * @param uniform defines the webGL uniform location where to store the value
  85442. * @param matrices defines the array of float32 to store
  85443. */
  85444. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  85445. /**
  85446. * Set the value of an uniform to a matrix
  85447. * @param uniform defines the webGL uniform location where to store the value
  85448. * @param matrix defines the matrix to store
  85449. */
  85450. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  85451. /**
  85452. * Set the value of an uniform to a matrix (3x3)
  85453. * @param uniform defines the webGL uniform location where to store the value
  85454. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  85455. */
  85456. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  85457. /**
  85458. * Set the value of an uniform to a matrix (2x2)
  85459. * @param uniform defines the webGL uniform location where to store the value
  85460. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  85461. */
  85462. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  85463. /**
  85464. * Set the value of an uniform to a number (int)
  85465. * @param uniform defines the webGL uniform location where to store the value
  85466. * @param value defines the int number to store
  85467. */
  85468. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  85469. /**
  85470. * Set the value of an uniform to a number (float)
  85471. * @param uniform defines the webGL uniform location where to store the value
  85472. * @param value defines the float number to store
  85473. */
  85474. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  85475. /**
  85476. * Set the value of an uniform to a vec2
  85477. * @param uniform defines the webGL uniform location where to store the value
  85478. * @param x defines the 1st component of the value
  85479. * @param y defines the 2nd component of the value
  85480. */
  85481. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  85482. /**
  85483. * Set the value of an uniform to a vec3
  85484. * @param uniform defines the webGL uniform location where to store the value
  85485. * @param x defines the 1st component of the value
  85486. * @param y defines the 2nd component of the value
  85487. * @param z defines the 3rd component of the value
  85488. */
  85489. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  85490. /**
  85491. * Set the value of an uniform to a boolean
  85492. * @param uniform defines the webGL uniform location where to store the value
  85493. * @param bool defines the boolean to store
  85494. */
  85495. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  85496. /**
  85497. * Set the value of an uniform to a vec4
  85498. * @param uniform defines the webGL uniform location where to store the value
  85499. * @param x defines the 1st component of the value
  85500. * @param y defines the 2nd component of the value
  85501. * @param z defines the 3rd component of the value
  85502. * @param w defines the 4th component of the value
  85503. */
  85504. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  85505. /**
  85506. * Set the value of an uniform to a Color3
  85507. * @param uniform defines the webGL uniform location where to store the value
  85508. * @param color3 defines the color to store
  85509. */
  85510. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  85511. /**
  85512. * Set the value of an uniform to a Color3 and an alpha value
  85513. * @param uniform defines the webGL uniform location where to store the value
  85514. * @param color3 defines the color to store
  85515. * @param alpha defines the alpha component to store
  85516. */
  85517. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  85518. /**
  85519. * Sets a Color4 on a uniform variable
  85520. * @param uniform defines the uniform location
  85521. * @param color4 defines the value to be set
  85522. */
  85523. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  85524. /**
  85525. * Set various states to the webGL context
  85526. * @param culling defines backface culling state
  85527. * @param zOffset defines the value to apply to zOffset (0 by default)
  85528. * @param force defines if states must be applied even if cache is up to date
  85529. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  85530. */
  85531. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  85532. /**
  85533. * Set the z offset to apply to current rendering
  85534. * @param value defines the offset to apply
  85535. */
  85536. setZOffset(value: number): void;
  85537. /**
  85538. * Gets the current value of the zOffset
  85539. * @returns the current zOffset state
  85540. */
  85541. getZOffset(): number;
  85542. /**
  85543. * Enable or disable depth buffering
  85544. * @param enable defines the state to set
  85545. */
  85546. setDepthBuffer(enable: boolean): void;
  85547. /**
  85548. * Gets a boolean indicating if depth writing is enabled
  85549. * @returns the current depth writing state
  85550. */
  85551. getDepthWrite(): boolean;
  85552. /**
  85553. * Enable or disable depth writing
  85554. * @param enable defines the state to set
  85555. */
  85556. setDepthWrite(enable: boolean): void;
  85557. /**
  85558. * Enable or disable color writing
  85559. * @param enable defines the state to set
  85560. */
  85561. setColorWrite(enable: boolean): void;
  85562. /**
  85563. * Gets a boolean indicating if color writing is enabled
  85564. * @returns the current color writing state
  85565. */
  85566. getColorWrite(): boolean;
  85567. /**
  85568. * Sets alpha constants used by some alpha blending modes
  85569. * @param r defines the red component
  85570. * @param g defines the green component
  85571. * @param b defines the blue component
  85572. * @param a defines the alpha component
  85573. */
  85574. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  85575. /**
  85576. * Sets the current alpha mode
  85577. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  85578. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  85579. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  85580. */
  85581. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  85582. /**
  85583. * Gets the current alpha mode
  85584. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  85585. * @returns the current alpha mode
  85586. */
  85587. getAlphaMode(): number;
  85588. /**
  85589. * Clears the list of texture accessible through engine.
  85590. * This can help preventing texture load conflict due to name collision.
  85591. */
  85592. clearInternalTexturesCache(): void;
  85593. /**
  85594. * Force the entire cache to be cleared
  85595. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  85596. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  85597. */
  85598. wipeCaches(bruteForce?: boolean): void;
  85599. /**
  85600. * Set the compressed texture format to use, based on the formats you have, and the formats
  85601. * supported by the hardware / browser.
  85602. *
  85603. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  85604. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  85605. * to API arguments needed to compressed textures. This puts the burden on the container
  85606. * generator to house the arcane code for determining these for current & future formats.
  85607. *
  85608. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  85609. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  85610. *
  85611. * Note: The result of this call is not taken into account when a texture is base64.
  85612. *
  85613. * @param formatsAvailable defines the list of those format families you have created
  85614. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  85615. *
  85616. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  85617. * @returns The extension selected.
  85618. */
  85619. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  85620. private _getSamplingParameters;
  85621. private _partialLoadImg;
  85622. private _cascadeLoadImgs;
  85623. /** @hidden */
  85624. _createTexture(): WebGLTexture;
  85625. /**
  85626. * Usually called from Texture.ts.
  85627. * Passed information to create a WebGLTexture
  85628. * @param urlArg defines a value which contains one of the following:
  85629. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  85630. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  85631. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  85632. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  85633. * @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)
  85634. * @param scene needed for loading to the correct scene
  85635. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  85636. * @param onLoad optional callback to be called upon successful completion
  85637. * @param onError optional callback to be called upon failure
  85638. * @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
  85639. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  85640. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  85641. * @param forcedExtension defines the extension to use to pick the right loader
  85642. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  85643. * @returns a InternalTexture for assignment back into BABYLON.Texture
  85644. */
  85645. 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;
  85646. private _rescaleTexture;
  85647. /**
  85648. * Update a raw texture
  85649. * @param texture defines the texture to update
  85650. * @param data defines the data to store in the texture
  85651. * @param format defines the format of the data
  85652. * @param invertY defines if data must be stored with Y axis inverted
  85653. * @param compression defines the compression used (null by default)
  85654. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85655. */
  85656. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  85657. /**
  85658. * Creates a raw texture
  85659. * @param data defines the data to store in the texture
  85660. * @param width defines the width of the texture
  85661. * @param height defines the height of the texture
  85662. * @param format defines the format of the data
  85663. * @param generateMipMaps defines if the engine should generate the mip levels
  85664. * @param invertY defines if data must be stored with Y axis inverted
  85665. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85666. * @param compression defines the compression used (null by default)
  85667. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85668. * @returns the raw texture inside an InternalTexture
  85669. */
  85670. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  85671. private _unpackFlipYCached;
  85672. /**
  85673. * In case you are sharing the context with other applications, it might
  85674. * be interested to not cache the unpack flip y state to ensure a consistent
  85675. * value would be set.
  85676. */
  85677. enableUnpackFlipYCached: boolean;
  85678. /** @hidden */
  85679. _unpackFlipY(value: boolean): void;
  85680. /** @hidden */
  85681. _getUnpackAlignement(): number;
  85682. /**
  85683. * Creates a dynamic texture
  85684. * @param width defines the width of the texture
  85685. * @param height defines the height of the texture
  85686. * @param generateMipMaps defines if the engine should generate the mip levels
  85687. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85688. * @returns the dynamic texture inside an InternalTexture
  85689. */
  85690. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  85691. /**
  85692. * Update the sampling mode of a given texture
  85693. * @param samplingMode defines the required sampling mode
  85694. * @param texture defines the texture to update
  85695. */
  85696. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  85697. /**
  85698. * Update the content of a dynamic texture
  85699. * @param texture defines the texture to update
  85700. * @param canvas defines the canvas containing the source
  85701. * @param invertY defines if data must be stored with Y axis inverted
  85702. * @param premulAlpha defines if alpha is stored as premultiplied
  85703. * @param format defines the format of the data
  85704. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  85705. */
  85706. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  85707. /**
  85708. * Update a video texture
  85709. * @param texture defines the texture to update
  85710. * @param video defines the video element to use
  85711. * @param invertY defines if data must be stored with Y axis inverted
  85712. */
  85713. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  85714. /**
  85715. * Updates a depth texture Comparison Mode and Function.
  85716. * If the comparison Function is equal to 0, the mode will be set to none.
  85717. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  85718. * @param texture The texture to set the comparison function for
  85719. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  85720. */
  85721. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  85722. private _setupDepthStencilTexture;
  85723. /**
  85724. * Creates a depth stencil texture.
  85725. * This is only available in WebGL 2 or with the depth texture extension available.
  85726. * @param size The size of face edge in the texture.
  85727. * @param options The options defining the texture.
  85728. * @returns The texture
  85729. */
  85730. createDepthStencilTexture(size: number | {
  85731. width: number;
  85732. height: number;
  85733. }, options: DepthTextureCreationOptions): InternalTexture;
  85734. /**
  85735. * Creates a depth stencil texture.
  85736. * This is only available in WebGL 2 or with the depth texture extension available.
  85737. * @param size The size of face edge in the texture.
  85738. * @param options The options defining the texture.
  85739. * @returns The texture
  85740. */
  85741. private _createDepthStencilTexture;
  85742. /**
  85743. * Creates a depth stencil cube texture.
  85744. * This is only available in WebGL 2.
  85745. * @param size The size of face edge in the cube texture.
  85746. * @param options The options defining the cube texture.
  85747. * @returns The cube texture
  85748. */
  85749. private _createDepthStencilCubeTexture;
  85750. /**
  85751. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  85752. * @param renderTarget The render target to set the frame buffer for
  85753. */
  85754. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  85755. /**
  85756. * Creates a new render target texture
  85757. * @param size defines the size of the texture
  85758. * @param options defines the options used to create the texture
  85759. * @returns a new render target texture stored in an InternalTexture
  85760. */
  85761. createRenderTargetTexture(size: number | {
  85762. width: number;
  85763. height: number;
  85764. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  85765. /**
  85766. * Create a multi render target texture
  85767. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  85768. * @param size defines the size of the texture
  85769. * @param options defines the creation options
  85770. * @returns the cube texture as an InternalTexture
  85771. */
  85772. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  85773. private _setupFramebufferDepthAttachments;
  85774. /**
  85775. * Updates the sample count of a render target texture
  85776. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  85777. * @param texture defines the texture to update
  85778. * @param samples defines the sample count to set
  85779. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  85780. */
  85781. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  85782. /**
  85783. * Update the sample count for a given multiple render target texture
  85784. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  85785. * @param textures defines the textures to update
  85786. * @param samples defines the sample count to set
  85787. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  85788. */
  85789. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  85790. /** @hidden */
  85791. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  85792. /** @hidden */
  85793. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  85794. /** @hidden */
  85795. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  85796. /** @hidden */
  85797. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  85798. /**
  85799. * Creates a new render target cube texture
  85800. * @param size defines the size of the texture
  85801. * @param options defines the options used to create the texture
  85802. * @returns a new render target cube texture stored in an InternalTexture
  85803. */
  85804. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  85805. /**
  85806. * Creates a cube texture
  85807. * @param rootUrl defines the url where the files to load is located
  85808. * @param scene defines the current scene
  85809. * @param files defines the list of files to load (1 per face)
  85810. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85811. * @param onLoad defines an optional callback raised when the texture is loaded
  85812. * @param onError defines an optional callback raised if there is an issue to load the texture
  85813. * @param format defines the format of the data
  85814. * @param forcedExtension defines the extension to use to pick the right loader
  85815. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  85816. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  85817. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  85818. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  85819. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  85820. * @returns the cube texture as an InternalTexture
  85821. */
  85822. 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;
  85823. /**
  85824. * @hidden
  85825. */
  85826. _setCubeMapTextureParams(loadMipmap: boolean): void;
  85827. /**
  85828. * Update a raw cube texture
  85829. * @param texture defines the texture to udpdate
  85830. * @param data defines the data to store
  85831. * @param format defines the data format
  85832. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85833. * @param invertY defines if data must be stored with Y axis inverted
  85834. * @param compression defines the compression used (null by default)
  85835. * @param level defines which level of the texture to update
  85836. */
  85837. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  85838. /**
  85839. * Creates a new raw cube texture
  85840. * @param data defines the array of data to use to create each face
  85841. * @param size defines the size of the textures
  85842. * @param format defines the format of the data
  85843. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85844. * @param generateMipMaps defines if the engine should generate the mip levels
  85845. * @param invertY defines if data must be stored with Y axis inverted
  85846. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85847. * @param compression defines the compression used (null by default)
  85848. * @returns the cube texture as an InternalTexture
  85849. */
  85850. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  85851. /**
  85852. * Creates a new raw cube texture from a specified url
  85853. * @param url defines the url where the data is located
  85854. * @param scene defines the current scene
  85855. * @param size defines the size of the textures
  85856. * @param format defines the format of the data
  85857. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85858. * @param noMipmap defines if the engine should avoid generating the mip levels
  85859. * @param callback defines a callback used to extract texture data from loaded data
  85860. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  85861. * @param onLoad defines a callback called when texture is loaded
  85862. * @param onError defines a callback called if there is an error
  85863. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85864. * @param invertY defines if data must be stored with Y axis inverted
  85865. * @returns the cube texture as an InternalTexture
  85866. */
  85867. 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;
  85868. /**
  85869. * Update a raw 3D texture
  85870. * @param texture defines the texture to update
  85871. * @param data defines the data to store
  85872. * @param format defines the data format
  85873. * @param invertY defines if data must be stored with Y axis inverted
  85874. * @param compression defines the used compression (can be null)
  85875. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  85876. */
  85877. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  85878. /**
  85879. * Creates a new raw 3D texture
  85880. * @param data defines the data used to create the texture
  85881. * @param width defines the width of the texture
  85882. * @param height defines the height of the texture
  85883. * @param depth defines the depth of the texture
  85884. * @param format defines the format of the texture
  85885. * @param generateMipMaps defines if the engine must generate mip levels
  85886. * @param invertY defines if data must be stored with Y axis inverted
  85887. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85888. * @param compression defines the compressed used (can be null)
  85889. * @param textureType defines the compressed used (can be null)
  85890. * @returns a new raw 3D texture (stored in an InternalTexture)
  85891. */
  85892. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  85893. private _prepareWebGLTextureContinuation;
  85894. private _prepareWebGLTexture;
  85895. private _convertRGBtoRGBATextureData;
  85896. /** @hidden */
  85897. _releaseFramebufferObjects(texture: InternalTexture): void;
  85898. /** @hidden */
  85899. _releaseTexture(texture: InternalTexture): void;
  85900. private setProgram;
  85901. private _boundUniforms;
  85902. /**
  85903. * Binds an effect to the webGL context
  85904. * @param effect defines the effect to bind
  85905. */
  85906. bindSamplers(effect: Effect): void;
  85907. private _moveBoundTextureOnTop;
  85908. private _getCorrectTextureChannel;
  85909. private _linkTrackers;
  85910. private _removeDesignatedSlot;
  85911. private _activateCurrentTexture;
  85912. /** @hidden */
  85913. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  85914. /** @hidden */
  85915. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  85916. /**
  85917. * Sets a texture to the webGL context from a postprocess
  85918. * @param channel defines the channel to use
  85919. * @param postProcess defines the source postprocess
  85920. */
  85921. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  85922. /**
  85923. * Binds the output of the passed in post process to the texture channel specified
  85924. * @param channel The channel the texture should be bound to
  85925. * @param postProcess The post process which's output should be bound
  85926. */
  85927. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  85928. /**
  85929. * Unbind all textures from the webGL context
  85930. */
  85931. unbindAllTextures(): void;
  85932. /**
  85933. * Sets a texture to the according uniform.
  85934. * @param channel The texture channel
  85935. * @param uniform The uniform to set
  85936. * @param texture The texture to apply
  85937. */
  85938. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  85939. /**
  85940. * Sets a depth stencil texture from a render target to the according uniform.
  85941. * @param channel The texture channel
  85942. * @param uniform The uniform to set
  85943. * @param texture The render target texture containing the depth stencil texture to apply
  85944. */
  85945. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  85946. private _bindSamplerUniformToChannel;
  85947. private _getTextureWrapMode;
  85948. private _setTexture;
  85949. /**
  85950. * Sets an array of texture to the webGL context
  85951. * @param channel defines the channel where the texture array must be set
  85952. * @param uniform defines the associated uniform location
  85953. * @param textures defines the array of textures to bind
  85954. */
  85955. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  85956. /** @hidden */
  85957. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  85958. private _setTextureParameterFloat;
  85959. private _setTextureParameterInteger;
  85960. /**
  85961. * Reads pixels from the current frame buffer. Please note that this function can be slow
  85962. * @param x defines the x coordinate of the rectangle where pixels must be read
  85963. * @param y defines the y coordinate of the rectangle where pixels must be read
  85964. * @param width defines the width of the rectangle where pixels must be read
  85965. * @param height defines the height of the rectangle where pixels must be read
  85966. * @returns a Uint8Array containing RGBA colors
  85967. */
  85968. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  85969. /**
  85970. * Add an externaly attached data from its key.
  85971. * This method call will fail and return false, if such key already exists.
  85972. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  85973. * @param key the unique key that identifies the data
  85974. * @param data the data object to associate to the key for this Engine instance
  85975. * @return true if no such key were already present and the data was added successfully, false otherwise
  85976. */
  85977. addExternalData<T>(key: string, data: T): boolean;
  85978. /**
  85979. * Get an externaly attached data from its key
  85980. * @param key the unique key that identifies the data
  85981. * @return the associated data, if present (can be null), or undefined if not present
  85982. */
  85983. getExternalData<T>(key: string): T;
  85984. /**
  85985. * Get an externaly attached data from its key, create it using a factory if it's not already present
  85986. * @param key the unique key that identifies the data
  85987. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  85988. * @return the associated data, can be null if the factory returned null.
  85989. */
  85990. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  85991. /**
  85992. * Remove an externaly attached data from the Engine instance
  85993. * @param key the unique key that identifies the data
  85994. * @return true if the data was successfully removed, false if it doesn't exist
  85995. */
  85996. removeExternalData(key: string): boolean;
  85997. /**
  85998. * Unbind all vertex attributes from the webGL context
  85999. */
  86000. unbindAllAttributes(): void;
  86001. /**
  86002. * 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
  86003. */
  86004. releaseEffects(): void;
  86005. /**
  86006. * Dispose and release all associated resources
  86007. */
  86008. dispose(): void;
  86009. /**
  86010. * Display the loading screen
  86011. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86012. */
  86013. displayLoadingUI(): void;
  86014. /**
  86015. * Hide the loading screen
  86016. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86017. */
  86018. hideLoadingUI(): void;
  86019. /**
  86020. * Gets the current loading screen object
  86021. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86022. */
  86023. /**
  86024. * Sets the current loading screen object
  86025. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86026. */
  86027. loadingScreen: ILoadingScreen;
  86028. /**
  86029. * Sets the current loading screen text
  86030. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86031. */
  86032. loadingUIText: string;
  86033. /**
  86034. * Sets the current loading screen background color
  86035. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86036. */
  86037. loadingUIBackgroundColor: string;
  86038. /**
  86039. * Attach a new callback raised when context lost event is fired
  86040. * @param callback defines the callback to call
  86041. */
  86042. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  86043. /**
  86044. * Attach a new callback raised when context restored event is fired
  86045. * @param callback defines the callback to call
  86046. */
  86047. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  86048. /**
  86049. * Gets the source code of the vertex shader associated with a specific webGL program
  86050. * @param program defines the program to use
  86051. * @returns a string containing the source code of the vertex shader associated with the program
  86052. */
  86053. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  86054. /**
  86055. * Gets the source code of the fragment shader associated with a specific webGL program
  86056. * @param program defines the program to use
  86057. * @returns a string containing the source code of the fragment shader associated with the program
  86058. */
  86059. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  86060. /**
  86061. * Get the current error code of the webGL context
  86062. * @returns the error code
  86063. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  86064. */
  86065. getError(): number;
  86066. /**
  86067. * Gets the current framerate
  86068. * @returns a number representing the framerate
  86069. */
  86070. getFps(): number;
  86071. /**
  86072. * Gets the time spent between current and previous frame
  86073. * @returns a number representing the delta time in ms
  86074. */
  86075. getDeltaTime(): number;
  86076. private _measureFps;
  86077. /** @hidden */
  86078. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  86079. private _canRenderToFloatFramebuffer;
  86080. private _canRenderToHalfFloatFramebuffer;
  86081. private _canRenderToFramebuffer;
  86082. /** @hidden */
  86083. _getWebGLTextureType(type: number): number;
  86084. private _getInternalFormat;
  86085. /** @hidden */
  86086. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  86087. /** @hidden */
  86088. _getRGBAMultiSampleBufferFormat(type: number): number;
  86089. /** @hidden */
  86090. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  86091. /** @hidden */
  86092. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  86093. private _partialLoadFile;
  86094. private _cascadeLoadFiles;
  86095. /**
  86096. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  86097. * @returns true if the engine can be created
  86098. * @ignorenaming
  86099. */
  86100. static isSupported(): boolean;
  86101. }
  86102. }
  86103. declare module BABYLON {
  86104. /**
  86105. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  86106. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  86107. */
  86108. export class EffectFallbacks {
  86109. private _defines;
  86110. private _currentRank;
  86111. private _maxRank;
  86112. private _mesh;
  86113. /**
  86114. * Removes the fallback from the bound mesh.
  86115. */
  86116. unBindMesh(): void;
  86117. /**
  86118. * Adds a fallback on the specified property.
  86119. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  86120. * @param define The name of the define in the shader
  86121. */
  86122. addFallback(rank: number, define: string): void;
  86123. /**
  86124. * Sets the mesh to use CPU skinning when needing to fallback.
  86125. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  86126. * @param mesh The mesh to use the fallbacks.
  86127. */
  86128. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  86129. /**
  86130. * Checks to see if more fallbacks are still availible.
  86131. */
  86132. readonly isMoreFallbacks: boolean;
  86133. /**
  86134. * Removes the defines that shoould be removed when falling back.
  86135. * @param currentDefines defines the current define statements for the shader.
  86136. * @param effect defines the current effect we try to compile
  86137. * @returns The resulting defines with defines of the current rank removed.
  86138. */
  86139. reduce(currentDefines: string, effect: Effect): string;
  86140. }
  86141. /**
  86142. * Options to be used when creating an effect.
  86143. */
  86144. export class EffectCreationOptions {
  86145. /**
  86146. * Atrributes that will be used in the shader.
  86147. */
  86148. attributes: string[];
  86149. /**
  86150. * Uniform varible names that will be set in the shader.
  86151. */
  86152. uniformsNames: string[];
  86153. /**
  86154. * Uniform buffer varible names that will be set in the shader.
  86155. */
  86156. uniformBuffersNames: string[];
  86157. /**
  86158. * Sampler texture variable names that will be set in the shader.
  86159. */
  86160. samplers: string[];
  86161. /**
  86162. * Define statements that will be set in the shader.
  86163. */
  86164. defines: any;
  86165. /**
  86166. * Possible fallbacks for this effect to improve performance when needed.
  86167. */
  86168. fallbacks: Nullable<EffectFallbacks>;
  86169. /**
  86170. * Callback that will be called when the shader is compiled.
  86171. */
  86172. onCompiled: Nullable<(effect: Effect) => void>;
  86173. /**
  86174. * Callback that will be called if an error occurs during shader compilation.
  86175. */
  86176. onError: Nullable<(effect: Effect, errors: string) => void>;
  86177. /**
  86178. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  86179. */
  86180. indexParameters: any;
  86181. /**
  86182. * Max number of lights that can be used in the shader.
  86183. */
  86184. maxSimultaneousLights: number;
  86185. /**
  86186. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  86187. */
  86188. transformFeedbackVaryings: Nullable<string[]>;
  86189. }
  86190. /**
  86191. * Effect containing vertex and fragment shader that can be executed on an object.
  86192. */
  86193. export class Effect {
  86194. /**
  86195. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  86196. */
  86197. static ShadersRepository: string;
  86198. /**
  86199. * Name of the effect.
  86200. */
  86201. name: any;
  86202. /**
  86203. * String container all the define statements that should be set on the shader.
  86204. */
  86205. defines: string;
  86206. /**
  86207. * Callback that will be called when the shader is compiled.
  86208. */
  86209. onCompiled: Nullable<(effect: Effect) => void>;
  86210. /**
  86211. * Callback that will be called if an error occurs during shader compilation.
  86212. */
  86213. onError: Nullable<(effect: Effect, errors: string) => void>;
  86214. /**
  86215. * Callback that will be called when effect is bound.
  86216. */
  86217. onBind: Nullable<(effect: Effect) => void>;
  86218. /**
  86219. * Unique ID of the effect.
  86220. */
  86221. uniqueId: number;
  86222. /**
  86223. * Observable that will be called when the shader is compiled.
  86224. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  86225. */
  86226. onCompileObservable: Observable<Effect>;
  86227. /**
  86228. * Observable that will be called if an error occurs during shader compilation.
  86229. */
  86230. onErrorObservable: Observable<Effect>;
  86231. /** @hidden */
  86232. _onBindObservable: Nullable<Observable<Effect>>;
  86233. /**
  86234. * Observable that will be called when effect is bound.
  86235. */
  86236. readonly onBindObservable: Observable<Effect>;
  86237. /** @hidden */
  86238. _bonesComputationForcedToCPU: boolean;
  86239. private static _uniqueIdSeed;
  86240. private _engine;
  86241. private _uniformBuffersNames;
  86242. private _uniformsNames;
  86243. private _samplers;
  86244. private _isReady;
  86245. private _compilationError;
  86246. private _attributesNames;
  86247. private _attributes;
  86248. private _uniforms;
  86249. /**
  86250. * Key for the effect.
  86251. * @hidden
  86252. */
  86253. _key: string;
  86254. private _indexParameters;
  86255. private _fallbacks;
  86256. private _vertexSourceCode;
  86257. private _fragmentSourceCode;
  86258. private _vertexSourceCodeOverride;
  86259. private _fragmentSourceCodeOverride;
  86260. private _transformFeedbackVaryings;
  86261. /**
  86262. * Compiled shader to webGL program.
  86263. * @hidden
  86264. */
  86265. _program: WebGLProgram;
  86266. private _valueCache;
  86267. private static _baseCache;
  86268. /**
  86269. * Instantiates an effect.
  86270. * An effect can be used to create/manage/execute vertex and fragment shaders.
  86271. * @param baseName Name of the effect.
  86272. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  86273. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  86274. * @param samplers List of sampler variables that will be passed to the shader.
  86275. * @param engine Engine to be used to render the effect
  86276. * @param defines Define statements to be added to the shader.
  86277. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  86278. * @param onCompiled Callback that will be called when the shader is compiled.
  86279. * @param onError Callback that will be called if an error occurs during shader compilation.
  86280. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  86281. */
  86282. 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);
  86283. /**
  86284. * Unique key for this effect
  86285. */
  86286. readonly key: string;
  86287. /**
  86288. * If the effect has been compiled and prepared.
  86289. * @returns if the effect is compiled and prepared.
  86290. */
  86291. isReady(): boolean;
  86292. /**
  86293. * The engine the effect was initialized with.
  86294. * @returns the engine.
  86295. */
  86296. getEngine(): Engine;
  86297. /**
  86298. * The compiled webGL program for the effect
  86299. * @returns the webGL program.
  86300. */
  86301. getProgram(): WebGLProgram;
  86302. /**
  86303. * The set of names of attribute variables for the shader.
  86304. * @returns An array of attribute names.
  86305. */
  86306. getAttributesNames(): string[];
  86307. /**
  86308. * Returns the attribute at the given index.
  86309. * @param index The index of the attribute.
  86310. * @returns The location of the attribute.
  86311. */
  86312. getAttributeLocation(index: number): number;
  86313. /**
  86314. * Returns the attribute based on the name of the variable.
  86315. * @param name of the attribute to look up.
  86316. * @returns the attribute location.
  86317. */
  86318. getAttributeLocationByName(name: string): number;
  86319. /**
  86320. * The number of attributes.
  86321. * @returns the numnber of attributes.
  86322. */
  86323. getAttributesCount(): number;
  86324. /**
  86325. * Gets the index of a uniform variable.
  86326. * @param uniformName of the uniform to look up.
  86327. * @returns the index.
  86328. */
  86329. getUniformIndex(uniformName: string): number;
  86330. /**
  86331. * Returns the attribute based on the name of the variable.
  86332. * @param uniformName of the uniform to look up.
  86333. * @returns the location of the uniform.
  86334. */
  86335. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  86336. /**
  86337. * Returns an array of sampler variable names
  86338. * @returns The array of sampler variable neames.
  86339. */
  86340. getSamplers(): string[];
  86341. /**
  86342. * The error from the last compilation.
  86343. * @returns the error string.
  86344. */
  86345. getCompilationError(): string;
  86346. /**
  86347. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  86348. * @param func The callback to be used.
  86349. */
  86350. executeWhenCompiled(func: (effect: Effect) => void): void;
  86351. private _checkIsReady;
  86352. /** @hidden */
  86353. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  86354. /** @hidden */
  86355. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  86356. /** @hidden */
  86357. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  86358. private _processShaderConversion;
  86359. private _processIncludes;
  86360. private _processPrecision;
  86361. /**
  86362. * Recompiles the webGL program
  86363. * @param vertexSourceCode The source code for the vertex shader.
  86364. * @param fragmentSourceCode The source code for the fragment shader.
  86365. * @param onCompiled Callback called when completed.
  86366. * @param onError Callback called on error.
  86367. * @hidden
  86368. */
  86369. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  86370. /**
  86371. * Gets the uniform locations of the the specified variable names
  86372. * @param names THe names of the variables to lookup.
  86373. * @returns Array of locations in the same order as variable names.
  86374. */
  86375. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  86376. /**
  86377. * Prepares the effect
  86378. * @hidden
  86379. */
  86380. _prepareEffect(): void;
  86381. /**
  86382. * Checks if the effect is supported. (Must be called after compilation)
  86383. */
  86384. readonly isSupported: boolean;
  86385. /**
  86386. * Binds a texture to the engine to be used as output of the shader.
  86387. * @param channel Name of the output variable.
  86388. * @param texture Texture to bind.
  86389. * @hidden
  86390. */
  86391. _bindTexture(channel: string, texture: InternalTexture): void;
  86392. /**
  86393. * Sets a texture on the engine to be used in the shader.
  86394. * @param channel Name of the sampler variable.
  86395. * @param texture Texture to set.
  86396. */
  86397. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  86398. /**
  86399. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  86400. * @param channel Name of the sampler variable.
  86401. * @param texture Texture to set.
  86402. */
  86403. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  86404. /**
  86405. * Sets an array of textures on the engine to be used in the shader.
  86406. * @param channel Name of the variable.
  86407. * @param textures Textures to set.
  86408. */
  86409. setTextureArray(channel: string, textures: BaseTexture[]): void;
  86410. /**
  86411. * 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)
  86412. * @param channel Name of the sampler variable.
  86413. * @param postProcess Post process to get the input texture from.
  86414. */
  86415. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  86416. /**
  86417. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  86418. * 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)
  86419. * @param channel Name of the sampler variable.
  86420. * @param postProcess Post process to get the output texture from.
  86421. */
  86422. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  86423. /** @hidden */
  86424. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  86425. /** @hidden */
  86426. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  86427. /** @hidden */
  86428. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  86429. /** @hidden */
  86430. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  86431. /**
  86432. * Binds a buffer to a uniform.
  86433. * @param buffer Buffer to bind.
  86434. * @param name Name of the uniform variable to bind to.
  86435. */
  86436. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  86437. /**
  86438. * Binds block to a uniform.
  86439. * @param blockName Name of the block to bind.
  86440. * @param index Index to bind.
  86441. */
  86442. bindUniformBlock(blockName: string, index: number): void;
  86443. /**
  86444. * Sets an interger value on a uniform variable.
  86445. * @param uniformName Name of the variable.
  86446. * @param value Value to be set.
  86447. * @returns this effect.
  86448. */
  86449. setInt(uniformName: string, value: number): Effect;
  86450. /**
  86451. * Sets an int array on a uniform variable.
  86452. * @param uniformName Name of the variable.
  86453. * @param array array to be set.
  86454. * @returns this effect.
  86455. */
  86456. setIntArray(uniformName: string, array: Int32Array): Effect;
  86457. /**
  86458. * 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)
  86459. * @param uniformName Name of the variable.
  86460. * @param array array to be set.
  86461. * @returns this effect.
  86462. */
  86463. setIntArray2(uniformName: string, array: Int32Array): Effect;
  86464. /**
  86465. * 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)
  86466. * @param uniformName Name of the variable.
  86467. * @param array array to be set.
  86468. * @returns this effect.
  86469. */
  86470. setIntArray3(uniformName: string, array: Int32Array): Effect;
  86471. /**
  86472. * 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)
  86473. * @param uniformName Name of the variable.
  86474. * @param array array to be set.
  86475. * @returns this effect.
  86476. */
  86477. setIntArray4(uniformName: string, array: Int32Array): Effect;
  86478. /**
  86479. * Sets an float array on a uniform variable.
  86480. * @param uniformName Name of the variable.
  86481. * @param array array to be set.
  86482. * @returns this effect.
  86483. */
  86484. setFloatArray(uniformName: string, array: Float32Array): Effect;
  86485. /**
  86486. * 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)
  86487. * @param uniformName Name of the variable.
  86488. * @param array array to be set.
  86489. * @returns this effect.
  86490. */
  86491. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  86492. /**
  86493. * 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)
  86494. * @param uniformName Name of the variable.
  86495. * @param array array to be set.
  86496. * @returns this effect.
  86497. */
  86498. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  86499. /**
  86500. * 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)
  86501. * @param uniformName Name of the variable.
  86502. * @param array array to be set.
  86503. * @returns this effect.
  86504. */
  86505. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  86506. /**
  86507. * Sets an array on a uniform variable.
  86508. * @param uniformName Name of the variable.
  86509. * @param array array to be set.
  86510. * @returns this effect.
  86511. */
  86512. setArray(uniformName: string, array: number[]): Effect;
  86513. /**
  86514. * 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)
  86515. * @param uniformName Name of the variable.
  86516. * @param array array to be set.
  86517. * @returns this effect.
  86518. */
  86519. setArray2(uniformName: string, array: number[]): Effect;
  86520. /**
  86521. * 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)
  86522. * @param uniformName Name of the variable.
  86523. * @param array array to be set.
  86524. * @returns this effect.
  86525. */
  86526. setArray3(uniformName: string, array: number[]): Effect;
  86527. /**
  86528. * 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)
  86529. * @param uniformName Name of the variable.
  86530. * @param array array to be set.
  86531. * @returns this effect.
  86532. */
  86533. setArray4(uniformName: string, array: number[]): Effect;
  86534. /**
  86535. * Sets matrices on a uniform variable.
  86536. * @param uniformName Name of the variable.
  86537. * @param matrices matrices to be set.
  86538. * @returns this effect.
  86539. */
  86540. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  86541. /**
  86542. * Sets matrix on a uniform variable.
  86543. * @param uniformName Name of the variable.
  86544. * @param matrix matrix to be set.
  86545. * @returns this effect.
  86546. */
  86547. setMatrix(uniformName: string, matrix: Matrix): Effect;
  86548. /**
  86549. * 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)
  86550. * @param uniformName Name of the variable.
  86551. * @param matrix matrix to be set.
  86552. * @returns this effect.
  86553. */
  86554. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  86555. /**
  86556. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  86557. * @param uniformName Name of the variable.
  86558. * @param matrix matrix to be set.
  86559. * @returns this effect.
  86560. */
  86561. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  86562. /**
  86563. * Sets a float on a uniform variable.
  86564. * @param uniformName Name of the variable.
  86565. * @param value value to be set.
  86566. * @returns this effect.
  86567. */
  86568. setFloat(uniformName: string, value: number): Effect;
  86569. /**
  86570. * Sets a boolean on a uniform variable.
  86571. * @param uniformName Name of the variable.
  86572. * @param bool value to be set.
  86573. * @returns this effect.
  86574. */
  86575. setBool(uniformName: string, bool: boolean): Effect;
  86576. /**
  86577. * Sets a Vector2 on a uniform variable.
  86578. * @param uniformName Name of the variable.
  86579. * @param vector2 vector2 to be set.
  86580. * @returns this effect.
  86581. */
  86582. setVector2(uniformName: string, vector2: Vector2): Effect;
  86583. /**
  86584. * Sets a float2 on a uniform variable.
  86585. * @param uniformName Name of the variable.
  86586. * @param x First float in float2.
  86587. * @param y Second float in float2.
  86588. * @returns this effect.
  86589. */
  86590. setFloat2(uniformName: string, x: number, y: number): Effect;
  86591. /**
  86592. * Sets a Vector3 on a uniform variable.
  86593. * @param uniformName Name of the variable.
  86594. * @param vector3 Value to be set.
  86595. * @returns this effect.
  86596. */
  86597. setVector3(uniformName: string, vector3: Vector3): Effect;
  86598. /**
  86599. * Sets a float3 on a uniform variable.
  86600. * @param uniformName Name of the variable.
  86601. * @param x First float in float3.
  86602. * @param y Second float in float3.
  86603. * @param z Third float in float3.
  86604. * @returns this effect.
  86605. */
  86606. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  86607. /**
  86608. * Sets a Vector4 on a uniform variable.
  86609. * @param uniformName Name of the variable.
  86610. * @param vector4 Value to be set.
  86611. * @returns this effect.
  86612. */
  86613. setVector4(uniformName: string, vector4: Vector4): Effect;
  86614. /**
  86615. * Sets a float4 on a uniform variable.
  86616. * @param uniformName Name of the variable.
  86617. * @param x First float in float4.
  86618. * @param y Second float in float4.
  86619. * @param z Third float in float4.
  86620. * @param w Fourth float in float4.
  86621. * @returns this effect.
  86622. */
  86623. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  86624. /**
  86625. * Sets a Color3 on a uniform variable.
  86626. * @param uniformName Name of the variable.
  86627. * @param color3 Value to be set.
  86628. * @returns this effect.
  86629. */
  86630. setColor3(uniformName: string, color3: Color3): Effect;
  86631. /**
  86632. * Sets a Color4 on a uniform variable.
  86633. * @param uniformName Name of the variable.
  86634. * @param color3 Value to be set.
  86635. * @param alpha Alpha value to be set.
  86636. * @returns this effect.
  86637. */
  86638. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  86639. /**
  86640. * Sets a Color4 on a uniform variable
  86641. * @param uniformName defines the name of the variable
  86642. * @param color4 defines the value to be set
  86643. * @returns this effect.
  86644. */
  86645. setDirectColor4(uniformName: string, color4: Color4): Effect;
  86646. /**
  86647. * This function will add a new shader to the shader store
  86648. * @param name the name of the shader
  86649. * @param pixelShader optional pixel shader content
  86650. * @param vertexShader optional vertex shader content
  86651. */
  86652. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  86653. /**
  86654. * Store of each shader (The can be looked up using effect.key)
  86655. */
  86656. static ShadersStore: {
  86657. [key: string]: string;
  86658. };
  86659. /**
  86660. * Store of each included file for a shader (The can be looked up using effect.key)
  86661. */
  86662. static IncludesShadersStore: {
  86663. [key: string]: string;
  86664. };
  86665. /**
  86666. * Resets the cache of effects.
  86667. */
  86668. static ResetCache(): void;
  86669. }
  86670. }
  86671. declare module BABYLON {
  86672. /**
  86673. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  86674. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  86675. * 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;
  86676. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  86677. */
  86678. export class ColorCurves {
  86679. private _dirty;
  86680. private _tempColor;
  86681. private _globalCurve;
  86682. private _highlightsCurve;
  86683. private _midtonesCurve;
  86684. private _shadowsCurve;
  86685. private _positiveCurve;
  86686. private _negativeCurve;
  86687. private _globalHue;
  86688. private _globalDensity;
  86689. private _globalSaturation;
  86690. private _globalExposure;
  86691. /**
  86692. * Gets the global Hue value.
  86693. * 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).
  86694. */
  86695. /**
  86696. * Sets the global Hue value.
  86697. * 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).
  86698. */
  86699. globalHue: number;
  86700. /**
  86701. * Gets the global Density value.
  86702. * 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.
  86703. * Values less than zero provide a filter of opposite hue.
  86704. */
  86705. /**
  86706. * Sets the global Density value.
  86707. * 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.
  86708. * Values less than zero provide a filter of opposite hue.
  86709. */
  86710. globalDensity: number;
  86711. /**
  86712. * Gets the global Saturation value.
  86713. * 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.
  86714. */
  86715. /**
  86716. * Sets the global Saturation value.
  86717. * 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.
  86718. */
  86719. globalSaturation: number;
  86720. /**
  86721. * Gets the global Exposure value.
  86722. * 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.
  86723. */
  86724. /**
  86725. * Sets the global Exposure value.
  86726. * 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.
  86727. */
  86728. globalExposure: number;
  86729. private _highlightsHue;
  86730. private _highlightsDensity;
  86731. private _highlightsSaturation;
  86732. private _highlightsExposure;
  86733. /**
  86734. * Gets the highlights Hue value.
  86735. * 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).
  86736. */
  86737. /**
  86738. * Sets the highlights Hue value.
  86739. * 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).
  86740. */
  86741. highlightsHue: number;
  86742. /**
  86743. * Gets the highlights Density value.
  86744. * 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.
  86745. * Values less than zero provide a filter of opposite hue.
  86746. */
  86747. /**
  86748. * Sets the highlights Density value.
  86749. * 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.
  86750. * Values less than zero provide a filter of opposite hue.
  86751. */
  86752. highlightsDensity: number;
  86753. /**
  86754. * Gets the highlights Saturation value.
  86755. * 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.
  86756. */
  86757. /**
  86758. * Sets the highlights Saturation value.
  86759. * 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.
  86760. */
  86761. highlightsSaturation: number;
  86762. /**
  86763. * Gets the highlights Exposure value.
  86764. * 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.
  86765. */
  86766. /**
  86767. * Sets the highlights Exposure value.
  86768. * 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.
  86769. */
  86770. highlightsExposure: number;
  86771. private _midtonesHue;
  86772. private _midtonesDensity;
  86773. private _midtonesSaturation;
  86774. private _midtonesExposure;
  86775. /**
  86776. * Gets the midtones Hue value.
  86777. * 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).
  86778. */
  86779. /**
  86780. * Sets the midtones Hue value.
  86781. * 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).
  86782. */
  86783. midtonesHue: number;
  86784. /**
  86785. * Gets the midtones Density value.
  86786. * 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.
  86787. * Values less than zero provide a filter of opposite hue.
  86788. */
  86789. /**
  86790. * Sets the midtones Density value.
  86791. * 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.
  86792. * Values less than zero provide a filter of opposite hue.
  86793. */
  86794. midtonesDensity: number;
  86795. /**
  86796. * Gets the midtones Saturation value.
  86797. * 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.
  86798. */
  86799. /**
  86800. * Sets the midtones Saturation value.
  86801. * 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.
  86802. */
  86803. midtonesSaturation: number;
  86804. /**
  86805. * Gets the midtones Exposure value.
  86806. * 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.
  86807. */
  86808. /**
  86809. * Sets the midtones Exposure value.
  86810. * 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.
  86811. */
  86812. midtonesExposure: number;
  86813. private _shadowsHue;
  86814. private _shadowsDensity;
  86815. private _shadowsSaturation;
  86816. private _shadowsExposure;
  86817. /**
  86818. * Gets the shadows Hue value.
  86819. * 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).
  86820. */
  86821. /**
  86822. * Sets the shadows Hue value.
  86823. * 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).
  86824. */
  86825. shadowsHue: number;
  86826. /**
  86827. * Gets the shadows Density value.
  86828. * 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.
  86829. * Values less than zero provide a filter of opposite hue.
  86830. */
  86831. /**
  86832. * Sets the shadows Density value.
  86833. * 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.
  86834. * Values less than zero provide a filter of opposite hue.
  86835. */
  86836. shadowsDensity: number;
  86837. /**
  86838. * Gets the shadows Saturation value.
  86839. * 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.
  86840. */
  86841. /**
  86842. * Sets the shadows Saturation value.
  86843. * 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.
  86844. */
  86845. shadowsSaturation: number;
  86846. /**
  86847. * Gets the shadows Exposure value.
  86848. * 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.
  86849. */
  86850. /**
  86851. * Sets the shadows Exposure value.
  86852. * 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.
  86853. */
  86854. shadowsExposure: number;
  86855. /**
  86856. * Returns the class name
  86857. * @returns The class name
  86858. */
  86859. getClassName(): string;
  86860. /**
  86861. * Binds the color curves to the shader.
  86862. * @param colorCurves The color curve to bind
  86863. * @param effect The effect to bind to
  86864. * @param positiveUniform The positive uniform shader parameter
  86865. * @param neutralUniform The neutral uniform shader parameter
  86866. * @param negativeUniform The negative uniform shader parameter
  86867. */
  86868. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  86869. /**
  86870. * Prepare the list of uniforms associated with the ColorCurves effects.
  86871. * @param uniformsList The list of uniforms used in the effect
  86872. */
  86873. static PrepareUniforms(uniformsList: string[]): void;
  86874. /**
  86875. * Returns color grading data based on a hue, density, saturation and exposure value.
  86876. * @param filterHue The hue of the color filter.
  86877. * @param filterDensity The density of the color filter.
  86878. * @param saturation The saturation.
  86879. * @param exposure The exposure.
  86880. * @param result The result data container.
  86881. */
  86882. private getColorGradingDataToRef;
  86883. /**
  86884. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  86885. * @param value The input slider value in range [-100,100].
  86886. * @returns Adjusted value.
  86887. */
  86888. private static applyColorGradingSliderNonlinear;
  86889. /**
  86890. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  86891. * @param hue The hue (H) input.
  86892. * @param saturation The saturation (S) input.
  86893. * @param brightness The brightness (B) input.
  86894. * @result An RGBA color represented as Vector4.
  86895. */
  86896. private static fromHSBToRef;
  86897. /**
  86898. * Returns a value clamped between min and max
  86899. * @param value The value to clamp
  86900. * @param min The minimum of value
  86901. * @param max The maximum of value
  86902. * @returns The clamped value.
  86903. */
  86904. private static clamp;
  86905. /**
  86906. * Clones the current color curve instance.
  86907. * @return The cloned curves
  86908. */
  86909. clone(): ColorCurves;
  86910. /**
  86911. * Serializes the current color curve instance to a json representation.
  86912. * @return a JSON representation
  86913. */
  86914. serialize(): any;
  86915. /**
  86916. * Parses the color curve from a json representation.
  86917. * @param source the JSON source to parse
  86918. * @return The parsed curves
  86919. */
  86920. static Parse(source: any): ColorCurves;
  86921. }
  86922. }
  86923. declare module BABYLON {
  86924. /**
  86925. * Interface to follow in your material defines to integrate easily the
  86926. * Image proccessing functions.
  86927. * @hidden
  86928. */
  86929. export interface IImageProcessingConfigurationDefines {
  86930. IMAGEPROCESSING: boolean;
  86931. VIGNETTE: boolean;
  86932. VIGNETTEBLENDMODEMULTIPLY: boolean;
  86933. VIGNETTEBLENDMODEOPAQUE: boolean;
  86934. TONEMAPPING: boolean;
  86935. TONEMAPPING_ACES: boolean;
  86936. CONTRAST: boolean;
  86937. EXPOSURE: boolean;
  86938. COLORCURVES: boolean;
  86939. COLORGRADING: boolean;
  86940. COLORGRADING3D: boolean;
  86941. SAMPLER3DGREENDEPTH: boolean;
  86942. SAMPLER3DBGRMAP: boolean;
  86943. IMAGEPROCESSINGPOSTPROCESS: boolean;
  86944. }
  86945. /**
  86946. * @hidden
  86947. */
  86948. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  86949. IMAGEPROCESSING: boolean;
  86950. VIGNETTE: boolean;
  86951. VIGNETTEBLENDMODEMULTIPLY: boolean;
  86952. VIGNETTEBLENDMODEOPAQUE: boolean;
  86953. TONEMAPPING: boolean;
  86954. TONEMAPPING_ACES: boolean;
  86955. CONTRAST: boolean;
  86956. COLORCURVES: boolean;
  86957. COLORGRADING: boolean;
  86958. COLORGRADING3D: boolean;
  86959. SAMPLER3DGREENDEPTH: boolean;
  86960. SAMPLER3DBGRMAP: boolean;
  86961. IMAGEPROCESSINGPOSTPROCESS: boolean;
  86962. EXPOSURE: boolean;
  86963. constructor();
  86964. }
  86965. /**
  86966. * This groups together the common properties used for image processing either in direct forward pass
  86967. * or through post processing effect depending on the use of the image processing pipeline in your scene
  86968. * or not.
  86969. */
  86970. export class ImageProcessingConfiguration {
  86971. /**
  86972. * Default tone mapping applied in BabylonJS.
  86973. */
  86974. static readonly TONEMAPPING_STANDARD: number;
  86975. /**
  86976. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  86977. * to other engines rendering to increase portability.
  86978. */
  86979. static readonly TONEMAPPING_ACES: number;
  86980. /**
  86981. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  86982. */
  86983. colorCurves: Nullable<ColorCurves>;
  86984. private _colorCurvesEnabled;
  86985. /**
  86986. * Gets wether the color curves effect is enabled.
  86987. */
  86988. /**
  86989. * Sets wether the color curves effect is enabled.
  86990. */
  86991. colorCurvesEnabled: boolean;
  86992. private _colorGradingTexture;
  86993. /**
  86994. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  86995. */
  86996. /**
  86997. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  86998. */
  86999. colorGradingTexture: Nullable<BaseTexture>;
  87000. private _colorGradingEnabled;
  87001. /**
  87002. * Gets wether the color grading effect is enabled.
  87003. */
  87004. /**
  87005. * Sets wether the color grading effect is enabled.
  87006. */
  87007. colorGradingEnabled: boolean;
  87008. private _colorGradingWithGreenDepth;
  87009. /**
  87010. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  87011. */
  87012. /**
  87013. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  87014. */
  87015. colorGradingWithGreenDepth: boolean;
  87016. private _colorGradingBGR;
  87017. /**
  87018. * Gets wether the color grading texture contains BGR values.
  87019. */
  87020. /**
  87021. * Sets wether the color grading texture contains BGR values.
  87022. */
  87023. colorGradingBGR: boolean;
  87024. /** @hidden */
  87025. _exposure: number;
  87026. /**
  87027. * Gets the Exposure used in the effect.
  87028. */
  87029. /**
  87030. * Sets the Exposure used in the effect.
  87031. */
  87032. exposure: number;
  87033. private _toneMappingEnabled;
  87034. /**
  87035. * Gets wether the tone mapping effect is enabled.
  87036. */
  87037. /**
  87038. * Sets wether the tone mapping effect is enabled.
  87039. */
  87040. toneMappingEnabled: boolean;
  87041. private _toneMappingType;
  87042. /**
  87043. * Gets the type of tone mapping effect.
  87044. */
  87045. /**
  87046. * Sets the type of tone mapping effect used in BabylonJS.
  87047. */
  87048. toneMappingType: number;
  87049. protected _contrast: number;
  87050. /**
  87051. * Gets the contrast used in the effect.
  87052. */
  87053. /**
  87054. * Sets the contrast used in the effect.
  87055. */
  87056. contrast: number;
  87057. /**
  87058. * Vignette stretch size.
  87059. */
  87060. vignetteStretch: number;
  87061. /**
  87062. * Vignette centre X Offset.
  87063. */
  87064. vignetteCentreX: number;
  87065. /**
  87066. * Vignette centre Y Offset.
  87067. */
  87068. vignetteCentreY: number;
  87069. /**
  87070. * Vignette weight or intensity of the vignette effect.
  87071. */
  87072. vignetteWeight: number;
  87073. /**
  87074. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  87075. * if vignetteEnabled is set to true.
  87076. */
  87077. vignetteColor: Color4;
  87078. /**
  87079. * Camera field of view used by the Vignette effect.
  87080. */
  87081. vignetteCameraFov: number;
  87082. private _vignetteBlendMode;
  87083. /**
  87084. * Gets the vignette blend mode allowing different kind of effect.
  87085. */
  87086. /**
  87087. * Sets the vignette blend mode allowing different kind of effect.
  87088. */
  87089. vignetteBlendMode: number;
  87090. private _vignetteEnabled;
  87091. /**
  87092. * Gets wether the vignette effect is enabled.
  87093. */
  87094. /**
  87095. * Sets wether the vignette effect is enabled.
  87096. */
  87097. vignetteEnabled: boolean;
  87098. private _applyByPostProcess;
  87099. /**
  87100. * Gets wether the image processing is applied through a post process or not.
  87101. */
  87102. /**
  87103. * Sets wether the image processing is applied through a post process or not.
  87104. */
  87105. applyByPostProcess: boolean;
  87106. private _isEnabled;
  87107. /**
  87108. * Gets wether the image processing is enabled or not.
  87109. */
  87110. /**
  87111. * Sets wether the image processing is enabled or not.
  87112. */
  87113. isEnabled: boolean;
  87114. /**
  87115. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  87116. */
  87117. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  87118. /**
  87119. * Method called each time the image processing information changes requires to recompile the effect.
  87120. */
  87121. protected _updateParameters(): void;
  87122. /**
  87123. * Gets the current class name.
  87124. * @return "ImageProcessingConfiguration"
  87125. */
  87126. getClassName(): string;
  87127. /**
  87128. * Prepare the list of uniforms associated with the Image Processing effects.
  87129. * @param uniforms The list of uniforms used in the effect
  87130. * @param defines the list of defines currently in use
  87131. */
  87132. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  87133. /**
  87134. * Prepare the list of samplers associated with the Image Processing effects.
  87135. * @param samplersList The list of uniforms used in the effect
  87136. * @param defines the list of defines currently in use
  87137. */
  87138. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  87139. /**
  87140. * Prepare the list of defines associated to the shader.
  87141. * @param defines the list of defines to complete
  87142. * @param forPostProcess Define if we are currently in post process mode or not
  87143. */
  87144. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  87145. /**
  87146. * Returns true if all the image processing information are ready.
  87147. * @returns True if ready, otherwise, false
  87148. */
  87149. isReady(): boolean;
  87150. /**
  87151. * Binds the image processing to the shader.
  87152. * @param effect The effect to bind to
  87153. * @param aspectRatio Define the current aspect ratio of the effect
  87154. */
  87155. bind(effect: Effect, aspectRatio?: number): void;
  87156. /**
  87157. * Clones the current image processing instance.
  87158. * @return The cloned image processing
  87159. */
  87160. clone(): ImageProcessingConfiguration;
  87161. /**
  87162. * Serializes the current image processing instance to a json representation.
  87163. * @return a JSON representation
  87164. */
  87165. serialize(): any;
  87166. /**
  87167. * Parses the image processing from a json representation.
  87168. * @param source the JSON source to parse
  87169. * @return The parsed image processing
  87170. */
  87171. static Parse(source: any): ImageProcessingConfiguration;
  87172. private static _VIGNETTEMODE_MULTIPLY;
  87173. private static _VIGNETTEMODE_OPAQUE;
  87174. /**
  87175. * Used to apply the vignette as a mix with the pixel color.
  87176. */
  87177. static readonly VIGNETTEMODE_MULTIPLY: number;
  87178. /**
  87179. * Used to apply the vignette as a replacement of the pixel color.
  87180. */
  87181. static readonly VIGNETTEMODE_OPAQUE: number;
  87182. }
  87183. }
  87184. declare module BABYLON {
  87185. /**
  87186. * This represents all the required information to add a fresnel effect on a material:
  87187. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  87188. */
  87189. export class FresnelParameters {
  87190. private _isEnabled;
  87191. /**
  87192. * Define if the fresnel effect is enable or not.
  87193. */
  87194. isEnabled: boolean;
  87195. /**
  87196. * Define the color used on edges (grazing angle)
  87197. */
  87198. leftColor: Color3;
  87199. /**
  87200. * Define the color used on center
  87201. */
  87202. rightColor: Color3;
  87203. /**
  87204. * Define bias applied to computed fresnel term
  87205. */
  87206. bias: number;
  87207. /**
  87208. * Defined the power exponent applied to fresnel term
  87209. */
  87210. power: number;
  87211. /**
  87212. * Clones the current fresnel and its valuues
  87213. * @returns a clone fresnel configuration
  87214. */
  87215. clone(): FresnelParameters;
  87216. /**
  87217. * Serializes the current fresnel parameters to a JSON representation.
  87218. * @return the JSON serialization
  87219. */
  87220. serialize(): any;
  87221. /**
  87222. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  87223. * @param parsedFresnelParameters Define the JSON representation
  87224. * @returns the parsed parameters
  87225. */
  87226. static Parse(parsedFresnelParameters: any): FresnelParameters;
  87227. }
  87228. }
  87229. declare module BABYLON {
  87230. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  87231. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87232. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87233. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87234. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87235. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87236. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87237. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87238. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87239. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87240. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87241. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87242. /**
  87243. * Decorator used to define property that can be serialized as reference to a camera
  87244. * @param sourceName defines the name of the property to decorate
  87245. */
  87246. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87247. /**
  87248. * Class used to help serialization objects
  87249. */
  87250. export class SerializationHelper {
  87251. /** hidden */
  87252. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  87253. /** hidden */
  87254. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  87255. /** hidden */
  87256. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  87257. /** hidden */
  87258. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  87259. /**
  87260. * Appends the serialized animations from the source animations
  87261. * @param source Source containing the animations
  87262. * @param destination Target to store the animations
  87263. */
  87264. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  87265. /**
  87266. * Static function used to serialized a specific entity
  87267. * @param entity defines the entity to serialize
  87268. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  87269. * @returns a JSON compatible object representing the serialization of the entity
  87270. */
  87271. static Serialize<T>(entity: T, serializationObject?: any): any;
  87272. /**
  87273. * Creates a new entity from a serialization data object
  87274. * @param creationFunction defines a function used to instanciated the new entity
  87275. * @param source defines the source serialization data
  87276. * @param scene defines the hosting scene
  87277. * @param rootUrl defines the root url for resources
  87278. * @returns a new entity
  87279. */
  87280. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  87281. /**
  87282. * Clones an object
  87283. * @param creationFunction defines the function used to instanciate the new object
  87284. * @param source defines the source object
  87285. * @returns the cloned object
  87286. */
  87287. static Clone<T>(creationFunction: () => T, source: T): T;
  87288. /**
  87289. * Instanciates a new object based on a source one (some data will be shared between both object)
  87290. * @param creationFunction defines the function used to instanciate the new object
  87291. * @param source defines the source object
  87292. * @returns the new object
  87293. */
  87294. static Instanciate<T>(creationFunction: () => T, source: T): T;
  87295. }
  87296. }
  87297. declare module BABYLON {
  87298. /**
  87299. * This is the base class of all the camera used in the application.
  87300. * @see http://doc.babylonjs.com/features/cameras
  87301. */
  87302. export class Camera extends Node {
  87303. /** @hidden */
  87304. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  87305. /**
  87306. * This is the default projection mode used by the cameras.
  87307. * It helps recreating a feeling of perspective and better appreciate depth.
  87308. * This is the best way to simulate real life cameras.
  87309. */
  87310. static readonly PERSPECTIVE_CAMERA: number;
  87311. /**
  87312. * This helps creating camera with an orthographic mode.
  87313. * 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.
  87314. */
  87315. static readonly ORTHOGRAPHIC_CAMERA: number;
  87316. /**
  87317. * This is the default FOV mode for perspective cameras.
  87318. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  87319. */
  87320. static readonly FOVMODE_VERTICAL_FIXED: number;
  87321. /**
  87322. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  87323. */
  87324. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  87325. /**
  87326. * This specifies ther is no need for a camera rig.
  87327. * Basically only one eye is rendered corresponding to the camera.
  87328. */
  87329. static readonly RIG_MODE_NONE: number;
  87330. /**
  87331. * Simulates a camera Rig with one blue eye and one red eye.
  87332. * This can be use with 3d blue and red glasses.
  87333. */
  87334. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  87335. /**
  87336. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  87337. */
  87338. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  87339. /**
  87340. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  87341. */
  87342. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  87343. /**
  87344. * Defines that both eyes of the camera will be rendered over under each other.
  87345. */
  87346. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  87347. /**
  87348. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  87349. */
  87350. static readonly RIG_MODE_VR: number;
  87351. /**
  87352. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  87353. */
  87354. static readonly RIG_MODE_WEBVR: number;
  87355. /**
  87356. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  87357. */
  87358. static readonly RIG_MODE_CUSTOM: number;
  87359. /**
  87360. * Defines if by default attaching controls should prevent the default javascript event to continue.
  87361. */
  87362. static ForceAttachControlToAlwaysPreventDefault: boolean;
  87363. /**
  87364. * @hidden
  87365. * Might be removed once multiview will be a thing
  87366. */
  87367. static UseAlternateWebVRRendering: boolean;
  87368. /**
  87369. * Define the input manager associated with the camera.
  87370. */
  87371. inputs: CameraInputsManager<Camera>;
  87372. /** @hidden */
  87373. _position: Vector3;
  87374. /**
  87375. * Define the current local position of the camera in the scene
  87376. */
  87377. position: Vector3;
  87378. /**
  87379. * The vector the camera should consider as up.
  87380. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  87381. */
  87382. upVector: Vector3;
  87383. /**
  87384. * Define the current limit on the left side for an orthographic camera
  87385. * In scene unit
  87386. */
  87387. orthoLeft: Nullable<number>;
  87388. /**
  87389. * Define the current limit on the right side for an orthographic camera
  87390. * In scene unit
  87391. */
  87392. orthoRight: Nullable<number>;
  87393. /**
  87394. * Define the current limit on the bottom side for an orthographic camera
  87395. * In scene unit
  87396. */
  87397. orthoBottom: Nullable<number>;
  87398. /**
  87399. * Define the current limit on the top side for an orthographic camera
  87400. * In scene unit
  87401. */
  87402. orthoTop: Nullable<number>;
  87403. /**
  87404. * Field Of View is set in Radians. (default is 0.8)
  87405. */
  87406. fov: number;
  87407. /**
  87408. * Define the minimum distance the camera can see from.
  87409. * This is important to note that the depth buffer are not infinite and the closer it starts
  87410. * the more your scene might encounter depth fighting issue.
  87411. */
  87412. minZ: number;
  87413. /**
  87414. * Define the maximum distance the camera can see to.
  87415. * This is important to note that the depth buffer are not infinite and the further it end
  87416. * the more your scene might encounter depth fighting issue.
  87417. */
  87418. maxZ: number;
  87419. /**
  87420. * Define the default inertia of the camera.
  87421. * This helps giving a smooth feeling to the camera movement.
  87422. */
  87423. inertia: number;
  87424. /**
  87425. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  87426. */
  87427. mode: number;
  87428. /**
  87429. * Define wether the camera is intermediate.
  87430. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  87431. */
  87432. isIntermediate: boolean;
  87433. /**
  87434. * Define the viewport of the camera.
  87435. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  87436. */
  87437. viewport: Viewport;
  87438. /**
  87439. * Restricts the camera to viewing objects with the same layerMask.
  87440. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  87441. */
  87442. layerMask: number;
  87443. /**
  87444. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  87445. */
  87446. fovMode: number;
  87447. /**
  87448. * Rig mode of the camera.
  87449. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  87450. * This is normally controlled byt the camera themselves as internal use.
  87451. */
  87452. cameraRigMode: number;
  87453. /**
  87454. * Defines the distance between both "eyes" in case of a RIG
  87455. */
  87456. interaxialDistance: number;
  87457. /**
  87458. * Defines if stereoscopic rendering is done side by side or over under.
  87459. */
  87460. isStereoscopicSideBySide: boolean;
  87461. /**
  87462. * 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
  87463. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  87464. * else in the scene.
  87465. */
  87466. customRenderTargets: RenderTargetTexture[];
  87467. /**
  87468. * When set, the camera will render to this render target instead of the default canvas
  87469. */
  87470. outputRenderTarget: Nullable<RenderTargetTexture>;
  87471. /**
  87472. * Observable triggered when the camera view matrix has changed.
  87473. */
  87474. onViewMatrixChangedObservable: Observable<Camera>;
  87475. /**
  87476. * Observable triggered when the camera Projection matrix has changed.
  87477. */
  87478. onProjectionMatrixChangedObservable: Observable<Camera>;
  87479. /**
  87480. * Observable triggered when the inputs have been processed.
  87481. */
  87482. onAfterCheckInputsObservable: Observable<Camera>;
  87483. /**
  87484. * Observable triggered when reset has been called and applied to the camera.
  87485. */
  87486. onRestoreStateObservable: Observable<Camera>;
  87487. /** @hidden */
  87488. _cameraRigParams: any;
  87489. /** @hidden */
  87490. _rigCameras: Camera[];
  87491. /** @hidden */
  87492. _rigPostProcess: Nullable<PostProcess>;
  87493. protected _webvrViewMatrix: Matrix;
  87494. /** @hidden */
  87495. _skipRendering: boolean;
  87496. /** @hidden */
  87497. _alternateCamera: Camera;
  87498. /** @hidden */
  87499. _projectionMatrix: Matrix;
  87500. /** @hidden */
  87501. _postProcesses: Nullable<PostProcess>[];
  87502. /** @hidden */
  87503. _activeMeshes: SmartArray<AbstractMesh>;
  87504. protected _globalPosition: Vector3;
  87505. /** hidden */
  87506. _computedViewMatrix: Matrix;
  87507. private _doNotComputeProjectionMatrix;
  87508. private _transformMatrix;
  87509. private _frustumPlanes;
  87510. private _refreshFrustumPlanes;
  87511. private _storedFov;
  87512. private _stateStored;
  87513. /**
  87514. * Instantiates a new camera object.
  87515. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  87516. * @see http://doc.babylonjs.com/features/cameras
  87517. * @param name Defines the name of the camera in the scene
  87518. * @param position Defines the position of the camera
  87519. * @param scene Defines the scene the camera belongs too
  87520. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  87521. */
  87522. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  87523. /**
  87524. * Store current camera state (fov, position, etc..)
  87525. * @returns the camera
  87526. */
  87527. storeState(): Camera;
  87528. /**
  87529. * Restores the camera state values if it has been stored. You must call storeState() first
  87530. */
  87531. protected _restoreStateValues(): boolean;
  87532. /**
  87533. * Restored camera state. You must call storeState() first.
  87534. * @returns true if restored and false otherwise
  87535. */
  87536. restoreState(): boolean;
  87537. /**
  87538. * Gets the class name of the camera.
  87539. * @returns the class name
  87540. */
  87541. getClassName(): string;
  87542. /** @hidden */
  87543. readonly _isCamera: boolean;
  87544. /**
  87545. * Gets a string representation of the camera useful for debug purpose.
  87546. * @param fullDetails Defines that a more verboe level of logging is required
  87547. * @returns the string representation
  87548. */
  87549. toString(fullDetails?: boolean): string;
  87550. /**
  87551. * Gets the current world space position of the camera.
  87552. */
  87553. readonly globalPosition: Vector3;
  87554. /**
  87555. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  87556. * @returns the active meshe list
  87557. */
  87558. getActiveMeshes(): SmartArray<AbstractMesh>;
  87559. /**
  87560. * Check wether a mesh is part of the current active mesh list of the camera
  87561. * @param mesh Defines the mesh to check
  87562. * @returns true if active, false otherwise
  87563. */
  87564. isActiveMesh(mesh: Mesh): boolean;
  87565. /**
  87566. * Is this camera ready to be used/rendered
  87567. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  87568. * @return true if the camera is ready
  87569. */
  87570. isReady(completeCheck?: boolean): boolean;
  87571. /** @hidden */
  87572. _initCache(): void;
  87573. /** @hidden */
  87574. _updateCache(ignoreParentClass?: boolean): void;
  87575. /** @hidden */
  87576. _isSynchronized(): boolean;
  87577. /** @hidden */
  87578. _isSynchronizedViewMatrix(): boolean;
  87579. /** @hidden */
  87580. _isSynchronizedProjectionMatrix(): boolean;
  87581. /**
  87582. * Attach the input controls to a specific dom element to get the input from.
  87583. * @param element Defines the element the controls should be listened from
  87584. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87585. */
  87586. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  87587. /**
  87588. * Detach the current controls from the specified dom element.
  87589. * @param element Defines the element to stop listening the inputs from
  87590. */
  87591. detachControl(element: HTMLElement): void;
  87592. /**
  87593. * Update the camera state according to the different inputs gathered during the frame.
  87594. */
  87595. update(): void;
  87596. /** @hidden */
  87597. _checkInputs(): void;
  87598. /** @hidden */
  87599. readonly rigCameras: Camera[];
  87600. /**
  87601. * Gets the post process used by the rig cameras
  87602. */
  87603. readonly rigPostProcess: Nullable<PostProcess>;
  87604. /**
  87605. * Internal, gets the first post proces.
  87606. * @returns the first post process to be run on this camera.
  87607. */
  87608. _getFirstPostProcess(): Nullable<PostProcess>;
  87609. private _cascadePostProcessesToRigCams;
  87610. /**
  87611. * Attach a post process to the camera.
  87612. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  87613. * @param postProcess The post process to attach to the camera
  87614. * @param insertAt The position of the post process in case several of them are in use in the scene
  87615. * @returns the position the post process has been inserted at
  87616. */
  87617. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  87618. /**
  87619. * Detach a post process to the camera.
  87620. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  87621. * @param postProcess The post process to detach from the camera
  87622. */
  87623. detachPostProcess(postProcess: PostProcess): void;
  87624. /**
  87625. * Gets the current world matrix of the camera
  87626. */
  87627. getWorldMatrix(): Matrix;
  87628. /** @hidden */
  87629. _getViewMatrix(): Matrix;
  87630. /**
  87631. * Gets the current view matrix of the camera.
  87632. * @param force forces the camera to recompute the matrix without looking at the cached state
  87633. * @returns the view matrix
  87634. */
  87635. getViewMatrix(force?: boolean): Matrix;
  87636. /**
  87637. * Freeze the projection matrix.
  87638. * It will prevent the cache check of the camera projection compute and can speed up perf
  87639. * if no parameter of the camera are meant to change
  87640. * @param projection Defines manually a projection if necessary
  87641. */
  87642. freezeProjectionMatrix(projection?: Matrix): void;
  87643. /**
  87644. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  87645. */
  87646. unfreezeProjectionMatrix(): void;
  87647. /**
  87648. * Gets the current projection matrix of the camera.
  87649. * @param force forces the camera to recompute the matrix without looking at the cached state
  87650. * @returns the projection matrix
  87651. */
  87652. getProjectionMatrix(force?: boolean): Matrix;
  87653. /**
  87654. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  87655. * @returns a Matrix
  87656. */
  87657. getTransformationMatrix(): Matrix;
  87658. private _updateFrustumPlanes;
  87659. /**
  87660. * Checks if a cullable object (mesh...) is in the camera frustum
  87661. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  87662. * @param target The object to check
  87663. * @returns true if the object is in frustum otherwise false
  87664. */
  87665. isInFrustum(target: ICullable): boolean;
  87666. /**
  87667. * Checks if a cullable object (mesh...) is in the camera frustum
  87668. * Unlike isInFrustum this cheks the full bounding box
  87669. * @param target The object to check
  87670. * @returns true if the object is in frustum otherwise false
  87671. */
  87672. isCompletelyInFrustum(target: ICullable): boolean;
  87673. /**
  87674. * Gets a ray in the forward direction from the camera.
  87675. * @param length Defines the length of the ray to create
  87676. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  87677. * @param origin Defines the start point of the ray which defaults to the camera position
  87678. * @returns the forward ray
  87679. */
  87680. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  87681. /**
  87682. * Releases resources associated with this node.
  87683. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87684. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87685. */
  87686. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87687. /** @hidden */
  87688. _isLeftCamera: boolean;
  87689. /**
  87690. * Gets the left camera of a rig setup in case of Rigged Camera
  87691. */
  87692. readonly isLeftCamera: boolean;
  87693. /** @hidden */
  87694. _isRightCamera: boolean;
  87695. /**
  87696. * Gets the right camera of a rig setup in case of Rigged Camera
  87697. */
  87698. readonly isRightCamera: boolean;
  87699. /**
  87700. * Gets the left camera of a rig setup in case of Rigged Camera
  87701. */
  87702. readonly leftCamera: Nullable<FreeCamera>;
  87703. /**
  87704. * Gets the right camera of a rig setup in case of Rigged Camera
  87705. */
  87706. readonly rightCamera: Nullable<FreeCamera>;
  87707. /**
  87708. * Gets the left camera target of a rig setup in case of Rigged Camera
  87709. * @returns the target position
  87710. */
  87711. getLeftTarget(): Nullable<Vector3>;
  87712. /**
  87713. * Gets the right camera target of a rig setup in case of Rigged Camera
  87714. * @returns the target position
  87715. */
  87716. getRightTarget(): Nullable<Vector3>;
  87717. /**
  87718. * @hidden
  87719. */
  87720. setCameraRigMode(mode: number, rigParams: any): void;
  87721. /** @hidden */
  87722. static _setStereoscopicRigMode(camera: Camera): void;
  87723. /** @hidden */
  87724. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  87725. /** @hidden */
  87726. static _setVRRigMode(camera: Camera, rigParams: any): void;
  87727. /** @hidden */
  87728. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  87729. /** @hidden */
  87730. _getVRProjectionMatrix(): Matrix;
  87731. protected _updateCameraRotationMatrix(): void;
  87732. protected _updateWebVRCameraRotationMatrix(): void;
  87733. /**
  87734. * This function MUST be overwritten by the different WebVR cameras available.
  87735. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  87736. * @hidden
  87737. */
  87738. _getWebVRProjectionMatrix(): Matrix;
  87739. /**
  87740. * This function MUST be overwritten by the different WebVR cameras available.
  87741. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  87742. * @hidden
  87743. */
  87744. _getWebVRViewMatrix(): Matrix;
  87745. /** @hidden */
  87746. setCameraRigParameter(name: string, value: any): void;
  87747. /**
  87748. * needs to be overridden by children so sub has required properties to be copied
  87749. * @hidden
  87750. */
  87751. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  87752. /**
  87753. * May need to be overridden by children
  87754. * @hidden
  87755. */
  87756. _updateRigCameras(): void;
  87757. /** @hidden */
  87758. _setupInputs(): void;
  87759. /**
  87760. * Serialiaze the camera setup to a json represention
  87761. * @returns the JSON representation
  87762. */
  87763. serialize(): any;
  87764. /**
  87765. * Clones the current camera.
  87766. * @param name The cloned camera name
  87767. * @returns the cloned camera
  87768. */
  87769. clone(name: string): Camera;
  87770. /**
  87771. * Gets the direction of the camera relative to a given local axis.
  87772. * @param localAxis Defines the reference axis to provide a relative direction.
  87773. * @return the direction
  87774. */
  87775. getDirection(localAxis: Vector3): Vector3;
  87776. /**
  87777. * Gets the direction of the camera relative to a given local axis into a passed vector.
  87778. * @param localAxis Defines the reference axis to provide a relative direction.
  87779. * @param result Defines the vector to store the result in
  87780. */
  87781. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  87782. /**
  87783. * Gets a camera constructor for a given camera type
  87784. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  87785. * @param name The name of the camera the result will be able to instantiate
  87786. * @param scene The scene the result will construct the camera in
  87787. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  87788. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  87789. * @returns a factory method to construc the camera
  87790. */
  87791. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  87792. /**
  87793. * Compute the world matrix of the camera.
  87794. * @returns the camera workd matrix
  87795. */
  87796. computeWorldMatrix(): Matrix;
  87797. /**
  87798. * Parse a JSON and creates the camera from the parsed information
  87799. * @param parsedCamera The JSON to parse
  87800. * @param scene The scene to instantiate the camera in
  87801. * @returns the newly constructed camera
  87802. */
  87803. static Parse(parsedCamera: any, scene: Scene): Camera;
  87804. }
  87805. }
  87806. declare module BABYLON {
  87807. /**
  87808. * Interface for any object that can request an animation frame
  87809. */
  87810. export interface ICustomAnimationFrameRequester {
  87811. /**
  87812. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  87813. */
  87814. renderFunction?: Function;
  87815. /**
  87816. * Called to request the next frame to render to
  87817. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  87818. */
  87819. requestAnimationFrame: Function;
  87820. /**
  87821. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  87822. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  87823. */
  87824. requestID?: number;
  87825. }
  87826. /**
  87827. * Interface containing an array of animations
  87828. */
  87829. export interface IAnimatable {
  87830. /**
  87831. * Array of animations
  87832. */
  87833. animations: Array<Animation>;
  87834. }
  87835. /** Interface used by value gradients (color, factor, ...) */
  87836. export interface IValueGradient {
  87837. /**
  87838. * Gets or sets the gradient value (between 0 and 1)
  87839. */
  87840. gradient: number;
  87841. }
  87842. /** Class used to store color4 gradient */
  87843. export class ColorGradient implements IValueGradient {
  87844. /**
  87845. * Gets or sets the gradient value (between 0 and 1)
  87846. */
  87847. gradient: number;
  87848. /**
  87849. * Gets or sets first associated color
  87850. */
  87851. color1: Color4;
  87852. /**
  87853. * Gets or sets second associated color
  87854. */
  87855. color2?: Color4;
  87856. /**
  87857. * Will get a color picked randomly between color1 and color2.
  87858. * If color2 is undefined then color1 will be used
  87859. * @param result defines the target Color4 to store the result in
  87860. */
  87861. getColorToRef(result: Color4): void;
  87862. }
  87863. /** Class used to store color 3 gradient */
  87864. export class Color3Gradient implements IValueGradient {
  87865. /**
  87866. * Gets or sets the gradient value (between 0 and 1)
  87867. */
  87868. gradient: number;
  87869. /**
  87870. * Gets or sets the associated color
  87871. */
  87872. color: Color3;
  87873. }
  87874. /** Class used to store factor gradient */
  87875. export class FactorGradient implements IValueGradient {
  87876. /**
  87877. * Gets or sets the gradient value (between 0 and 1)
  87878. */
  87879. gradient: number;
  87880. /**
  87881. * Gets or sets first associated factor
  87882. */
  87883. factor1: number;
  87884. /**
  87885. * Gets or sets second associated factor
  87886. */
  87887. factor2?: number;
  87888. /**
  87889. * Will get a number picked randomly between factor1 and factor2.
  87890. * If factor2 is undefined then factor1 will be used
  87891. * @returns the picked number
  87892. */
  87893. getFactor(): number;
  87894. }
  87895. /**
  87896. * @ignore
  87897. * Application error to support additional information when loading a file
  87898. */
  87899. export class LoadFileError extends Error {
  87900. /** defines the optional web request */
  87901. request?: WebRequest | undefined;
  87902. private static _setPrototypeOf;
  87903. /**
  87904. * Creates a new LoadFileError
  87905. * @param message defines the message of the error
  87906. * @param request defines the optional web request
  87907. */
  87908. constructor(message: string,
  87909. /** defines the optional web request */
  87910. request?: WebRequest | undefined);
  87911. }
  87912. /**
  87913. * Class used to define a retry strategy when error happens while loading assets
  87914. */
  87915. export class RetryStrategy {
  87916. /**
  87917. * Function used to defines an exponential back off strategy
  87918. * @param maxRetries defines the maximum number of retries (3 by default)
  87919. * @param baseInterval defines the interval between retries
  87920. * @returns the strategy function to use
  87921. */
  87922. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  87923. }
  87924. /**
  87925. * File request interface
  87926. */
  87927. export interface IFileRequest {
  87928. /**
  87929. * Raised when the request is complete (success or error).
  87930. */
  87931. onCompleteObservable: Observable<IFileRequest>;
  87932. /**
  87933. * Aborts the request for a file.
  87934. */
  87935. abort: () => void;
  87936. }
  87937. /**
  87938. * Class containing a set of static utilities functions
  87939. */
  87940. export class Tools {
  87941. /**
  87942. * Gets or sets the base URL to use to load assets
  87943. */
  87944. static BaseUrl: string;
  87945. /**
  87946. * Enable/Disable Custom HTTP Request Headers globally.
  87947. * default = false
  87948. * @see CustomRequestHeaders
  87949. */
  87950. static UseCustomRequestHeaders: boolean;
  87951. /**
  87952. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  87953. * i.e. when loading files, where the server/service expects an Authorization header
  87954. */
  87955. static CustomRequestHeaders: {
  87956. [key: string]: string;
  87957. };
  87958. /**
  87959. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  87960. */
  87961. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  87962. /**
  87963. * Default behaviour for cors in the application.
  87964. * It can be a string if the expected behavior is identical in the entire app.
  87965. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  87966. */
  87967. static CorsBehavior: string | ((url: string | string[]) => string);
  87968. /**
  87969. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  87970. * @ignorenaming
  87971. */
  87972. static UseFallbackTexture: boolean;
  87973. /**
  87974. * Use this object to register external classes like custom textures or material
  87975. * to allow the laoders to instantiate them
  87976. */
  87977. static RegisteredExternalClasses: {
  87978. [key: string]: Object;
  87979. };
  87980. /**
  87981. * Texture content used if a texture cannot loaded
  87982. * @ignorenaming
  87983. */
  87984. static fallbackTexture: string;
  87985. /**
  87986. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  87987. * @param u defines the coordinate on X axis
  87988. * @param v defines the coordinate on Y axis
  87989. * @param width defines the width of the source data
  87990. * @param height defines the height of the source data
  87991. * @param pixels defines the source byte array
  87992. * @param color defines the output color
  87993. */
  87994. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  87995. /**
  87996. * Interpolates between a and b via alpha
  87997. * @param a The lower value (returned when alpha = 0)
  87998. * @param b The upper value (returned when alpha = 1)
  87999. * @param alpha The interpolation-factor
  88000. * @return The mixed value
  88001. */
  88002. static Mix(a: number, b: number, alpha: number): number;
  88003. /**
  88004. * Tries to instantiate a new object from a given class name
  88005. * @param className defines the class name to instantiate
  88006. * @returns the new object or null if the system was not able to do the instantiation
  88007. */
  88008. static Instantiate(className: string): any;
  88009. /**
  88010. * Provides a slice function that will work even on IE
  88011. * @param data defines the array to slice
  88012. * @param start defines the start of the data (optional)
  88013. * @param end defines the end of the data (optional)
  88014. * @returns the new sliced array
  88015. */
  88016. static Slice<T>(data: T, start?: number, end?: number): T;
  88017. /**
  88018. * Polyfill for setImmediate
  88019. * @param action defines the action to execute after the current execution block
  88020. */
  88021. static SetImmediate(action: () => void): void;
  88022. /**
  88023. * Function indicating if a number is an exponent of 2
  88024. * @param value defines the value to test
  88025. * @returns true if the value is an exponent of 2
  88026. */
  88027. static IsExponentOfTwo(value: number): boolean;
  88028. private static _tmpFloatArray;
  88029. /**
  88030. * Returns the nearest 32-bit single precision float representation of a Number
  88031. * @param value A Number. If the parameter is of a different type, it will get converted
  88032. * to a number or to NaN if it cannot be converted
  88033. * @returns number
  88034. */
  88035. static FloatRound(value: number): number;
  88036. /**
  88037. * Find the next highest power of two.
  88038. * @param x Number to start search from.
  88039. * @return Next highest power of two.
  88040. */
  88041. static CeilingPOT(x: number): number;
  88042. /**
  88043. * Find the next lowest power of two.
  88044. * @param x Number to start search from.
  88045. * @return Next lowest power of two.
  88046. */
  88047. static FloorPOT(x: number): number;
  88048. /**
  88049. * Find the nearest power of two.
  88050. * @param x Number to start search from.
  88051. * @return Next nearest power of two.
  88052. */
  88053. static NearestPOT(x: number): number;
  88054. /**
  88055. * Get the closest exponent of two
  88056. * @param value defines the value to approximate
  88057. * @param max defines the maximum value to return
  88058. * @param mode defines how to define the closest value
  88059. * @returns closest exponent of two of the given value
  88060. */
  88061. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  88062. /**
  88063. * Extracts the filename from a path
  88064. * @param path defines the path to use
  88065. * @returns the filename
  88066. */
  88067. static GetFilename(path: string): string;
  88068. /**
  88069. * Extracts the "folder" part of a path (everything before the filename).
  88070. * @param uri The URI to extract the info from
  88071. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  88072. * @returns The "folder" part of the path
  88073. */
  88074. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  88075. /**
  88076. * Extracts text content from a DOM element hierarchy
  88077. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  88078. */
  88079. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  88080. /**
  88081. * Convert an angle in radians to degrees
  88082. * @param angle defines the angle to convert
  88083. * @returns the angle in degrees
  88084. */
  88085. static ToDegrees(angle: number): number;
  88086. /**
  88087. * Convert an angle in degrees to radians
  88088. * @param angle defines the angle to convert
  88089. * @returns the angle in radians
  88090. */
  88091. static ToRadians(angle: number): number;
  88092. /**
  88093. * Encode a buffer to a base64 string
  88094. * @param buffer defines the buffer to encode
  88095. * @returns the encoded string
  88096. */
  88097. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  88098. /**
  88099. * Extracts minimum and maximum values from a list of indexed positions
  88100. * @param positions defines the positions to use
  88101. * @param indices defines the indices to the positions
  88102. * @param indexStart defines the start index
  88103. * @param indexCount defines the end index
  88104. * @param bias defines bias value to add to the result
  88105. * @return minimum and maximum values
  88106. */
  88107. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  88108. minimum: Vector3;
  88109. maximum: Vector3;
  88110. };
  88111. /**
  88112. * Extracts minimum and maximum values from a list of positions
  88113. * @param positions defines the positions to use
  88114. * @param start defines the start index in the positions array
  88115. * @param count defines the number of positions to handle
  88116. * @param bias defines bias value to add to the result
  88117. * @param stride defines the stride size to use (distance between two positions in the positions array)
  88118. * @return minimum and maximum values
  88119. */
  88120. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  88121. minimum: Vector3;
  88122. maximum: Vector3;
  88123. };
  88124. /**
  88125. * Returns an array if obj is not an array
  88126. * @param obj defines the object to evaluate as an array
  88127. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  88128. * @returns either obj directly if obj is an array or a new array containing obj
  88129. */
  88130. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  88131. /**
  88132. * Gets the pointer prefix to use
  88133. * @returns "pointer" if touch is enabled. Else returns "mouse"
  88134. */
  88135. static GetPointerPrefix(): string;
  88136. /**
  88137. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  88138. * @param func - the function to be called
  88139. * @param requester - the object that will request the next frame. Falls back to window.
  88140. * @returns frame number
  88141. */
  88142. static QueueNewFrame(func: () => void, requester?: any): number;
  88143. /**
  88144. * Ask the browser to promote the current element to fullscreen rendering mode
  88145. * @param element defines the DOM element to promote
  88146. */
  88147. static RequestFullscreen(element: HTMLElement): void;
  88148. /**
  88149. * Asks the browser to exit fullscreen mode
  88150. */
  88151. static ExitFullscreen(): void;
  88152. /**
  88153. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  88154. * @param url define the url we are trying
  88155. * @param element define the dom element where to configure the cors policy
  88156. */
  88157. static SetCorsBehavior(url: string | string[], element: {
  88158. crossOrigin: string | null;
  88159. }): void;
  88160. /**
  88161. * Removes unwanted characters from an url
  88162. * @param url defines the url to clean
  88163. * @returns the cleaned url
  88164. */
  88165. static CleanUrl(url: string): string;
  88166. /**
  88167. * Gets or sets a function used to pre-process url before using them to load assets
  88168. */
  88169. static PreprocessUrl: (url: string) => string;
  88170. /**
  88171. * Loads an image as an HTMLImageElement.
  88172. * @param input url string, ArrayBuffer, or Blob to load
  88173. * @param onLoad callback called when the image successfully loads
  88174. * @param onError callback called when the image fails to load
  88175. * @param offlineProvider offline provider for caching
  88176. * @returns the HTMLImageElement of the loaded image
  88177. */
  88178. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  88179. /**
  88180. * Loads a file
  88181. * @param url url string, ArrayBuffer, or Blob to load
  88182. * @param onSuccess callback called when the file successfully loads
  88183. * @param onProgress callback called while file is loading (if the server supports this mode)
  88184. * @param offlineProvider defines the offline provider for caching
  88185. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  88186. * @param onError callback called when the file fails to load
  88187. * @returns a file request object
  88188. */
  88189. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  88190. /**
  88191. * Load a script (identified by an url). When the url returns, the
  88192. * content of this file is added into a new script element, attached to the DOM (body element)
  88193. * @param scriptUrl defines the url of the script to laod
  88194. * @param onSuccess defines the callback called when the script is loaded
  88195. * @param onError defines the callback to call if an error occurs
  88196. */
  88197. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  88198. /**
  88199. * Loads a file from a blob
  88200. * @param fileToLoad defines the blob to use
  88201. * @param callback defines the callback to call when data is loaded
  88202. * @param progressCallback defines the callback to call during loading process
  88203. * @returns a file request object
  88204. */
  88205. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  88206. /**
  88207. * Loads a file
  88208. * @param fileToLoad defines the file to load
  88209. * @param callback defines the callback to call when data is loaded
  88210. * @param progressCallBack defines the callback to call during loading process
  88211. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  88212. * @returns a file request object
  88213. */
  88214. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  88215. /**
  88216. * Creates a data url from a given string content
  88217. * @param content defines the content to convert
  88218. * @returns the new data url link
  88219. */
  88220. static FileAsURL(content: string): string;
  88221. /**
  88222. * Format the given number to a specific decimal format
  88223. * @param value defines the number to format
  88224. * @param decimals defines the number of decimals to use
  88225. * @returns the formatted string
  88226. */
  88227. static Format(value: number, decimals?: number): string;
  88228. /**
  88229. * Checks if a given vector is inside a specific range
  88230. * @param v defines the vector to test
  88231. * @param min defines the minimum range
  88232. * @param max defines the maximum range
  88233. */
  88234. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  88235. /**
  88236. * Tries to copy an object by duplicating every property
  88237. * @param source defines the source object
  88238. * @param destination defines the target object
  88239. * @param doNotCopyList defines a list of properties to avoid
  88240. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  88241. */
  88242. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  88243. /**
  88244. * Gets a boolean indicating if the given object has no own property
  88245. * @param obj defines the object to test
  88246. * @returns true if object has no own property
  88247. */
  88248. static IsEmpty(obj: any): boolean;
  88249. /**
  88250. * Function used to register events at window level
  88251. * @param events defines the events to register
  88252. */
  88253. static RegisterTopRootEvents(events: {
  88254. name: string;
  88255. handler: Nullable<(e: FocusEvent) => any>;
  88256. }[]): void;
  88257. /**
  88258. * Function used to unregister events from window level
  88259. * @param events defines the events to unregister
  88260. */
  88261. static UnregisterTopRootEvents(events: {
  88262. name: string;
  88263. handler: Nullable<(e: FocusEvent) => any>;
  88264. }[]): void;
  88265. /**
  88266. * @ignore
  88267. */
  88268. static _ScreenshotCanvas: HTMLCanvasElement;
  88269. /**
  88270. * Dumps the current bound framebuffer
  88271. * @param width defines the rendering width
  88272. * @param height defines the rendering height
  88273. * @param engine defines the hosting engine
  88274. * @param successCallback defines the callback triggered once the data are available
  88275. * @param mimeType defines the mime type of the result
  88276. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  88277. */
  88278. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  88279. /**
  88280. * Converts the canvas data to blob.
  88281. * This acts as a polyfill for browsers not supporting the to blob function.
  88282. * @param canvas Defines the canvas to extract the data from
  88283. * @param successCallback Defines the callback triggered once the data are available
  88284. * @param mimeType Defines the mime type of the result
  88285. */
  88286. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  88287. /**
  88288. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  88289. * @param successCallback defines the callback triggered once the data are available
  88290. * @param mimeType defines the mime type of the result
  88291. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  88292. */
  88293. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  88294. /**
  88295. * Downloads a blob in the browser
  88296. * @param blob defines the blob to download
  88297. * @param fileName defines the name of the downloaded file
  88298. */
  88299. static Download(blob: Blob, fileName: string): void;
  88300. /**
  88301. * Captures a screenshot of the current rendering
  88302. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  88303. * @param engine defines the rendering engine
  88304. * @param camera defines the source camera
  88305. * @param size This parameter can be set to a single number or to an object with the
  88306. * following (optional) properties: precision, width, height. If a single number is passed,
  88307. * it will be used for both width and height. If an object is passed, the screenshot size
  88308. * will be derived from the parameters. The precision property is a multiplier allowing
  88309. * rendering at a higher or lower resolution
  88310. * @param successCallback defines the callback receives a single parameter which contains the
  88311. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  88312. * src parameter of an <img> to display it
  88313. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  88314. * Check your browser for supported MIME types
  88315. */
  88316. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  88317. /**
  88318. * Generates an image screenshot from the specified camera.
  88319. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  88320. * @param engine The engine to use for rendering
  88321. * @param camera The camera to use for rendering
  88322. * @param size This parameter can be set to a single number or to an object with the
  88323. * following (optional) properties: precision, width, height. If a single number is passed,
  88324. * it will be used for both width and height. If an object is passed, the screenshot size
  88325. * will be derived from the parameters. The precision property is a multiplier allowing
  88326. * rendering at a higher or lower resolution
  88327. * @param successCallback The callback receives a single parameter which contains the
  88328. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  88329. * src parameter of an <img> to display it
  88330. * @param mimeType The MIME type of the screenshot image (default: image/png).
  88331. * Check your browser for supported MIME types
  88332. * @param samples Texture samples (default: 1)
  88333. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  88334. * @param fileName A name for for the downloaded file.
  88335. */
  88336. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  88337. /**
  88338. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  88339. * Be aware Math.random() could cause collisions, but:
  88340. * "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"
  88341. * @returns a pseudo random id
  88342. */
  88343. static RandomId(): string;
  88344. /**
  88345. * Test if the given uri is a base64 string
  88346. * @param uri The uri to test
  88347. * @return True if the uri is a base64 string or false otherwise
  88348. */
  88349. static IsBase64(uri: string): boolean;
  88350. /**
  88351. * Decode the given base64 uri.
  88352. * @param uri The uri to decode
  88353. * @return The decoded base64 data.
  88354. */
  88355. static DecodeBase64(uri: string): ArrayBuffer;
  88356. /**
  88357. * No log
  88358. */
  88359. static readonly NoneLogLevel: number;
  88360. /**
  88361. * Only message logs
  88362. */
  88363. static readonly MessageLogLevel: number;
  88364. /**
  88365. * Only warning logs
  88366. */
  88367. static readonly WarningLogLevel: number;
  88368. /**
  88369. * Only error logs
  88370. */
  88371. static readonly ErrorLogLevel: number;
  88372. /**
  88373. * All logs
  88374. */
  88375. static readonly AllLogLevel: number;
  88376. /**
  88377. * Gets a value indicating the number of loading errors
  88378. * @ignorenaming
  88379. */
  88380. static readonly errorsCount: number;
  88381. /**
  88382. * Callback called when a new log is added
  88383. */
  88384. static OnNewCacheEntry: (entry: string) => void;
  88385. /**
  88386. * Log a message to the console
  88387. * @param message defines the message to log
  88388. */
  88389. static Log(message: string): void;
  88390. /**
  88391. * Write a warning message to the console
  88392. * @param message defines the message to log
  88393. */
  88394. static Warn(message: string): void;
  88395. /**
  88396. * Write an error message to the console
  88397. * @param message defines the message to log
  88398. */
  88399. static Error(message: string): void;
  88400. /**
  88401. * Gets current log cache (list of logs)
  88402. */
  88403. static readonly LogCache: string;
  88404. /**
  88405. * Clears the log cache
  88406. */
  88407. static ClearLogCache(): void;
  88408. /**
  88409. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  88410. */
  88411. static LogLevels: number;
  88412. /**
  88413. * Checks if the loaded document was accessed via `file:`-Protocol.
  88414. * @returns boolean
  88415. */
  88416. static IsFileURL(): boolean;
  88417. /**
  88418. * Checks if the window object exists
  88419. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  88420. */
  88421. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  88422. /**
  88423. * No performance log
  88424. */
  88425. static readonly PerformanceNoneLogLevel: number;
  88426. /**
  88427. * Use user marks to log performance
  88428. */
  88429. static readonly PerformanceUserMarkLogLevel: number;
  88430. /**
  88431. * Log performance to the console
  88432. */
  88433. static readonly PerformanceConsoleLogLevel: number;
  88434. private static _performance;
  88435. /**
  88436. * Sets the current performance log level
  88437. */
  88438. static PerformanceLogLevel: number;
  88439. private static _StartPerformanceCounterDisabled;
  88440. private static _EndPerformanceCounterDisabled;
  88441. private static _StartUserMark;
  88442. private static _EndUserMark;
  88443. private static _StartPerformanceConsole;
  88444. private static _EndPerformanceConsole;
  88445. /**
  88446. * Starts a performance counter
  88447. */
  88448. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  88449. /**
  88450. * Ends a specific performance coutner
  88451. */
  88452. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  88453. /**
  88454. * Gets either window.performance.now() if supported or Date.now() else
  88455. */
  88456. static readonly Now: number;
  88457. /**
  88458. * This method will return the name of the class used to create the instance of the given object.
  88459. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  88460. * @param object the object to get the class name from
  88461. * @param isType defines if the object is actually a type
  88462. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  88463. */
  88464. static GetClassName(object: any, isType?: boolean): string;
  88465. /**
  88466. * Gets the first element of an array satisfying a given predicate
  88467. * @param array defines the array to browse
  88468. * @param predicate defines the predicate to use
  88469. * @returns null if not found or the element
  88470. */
  88471. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  88472. /**
  88473. * This method will return the name of the full name of the class, including its owning module (if any).
  88474. * 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).
  88475. * @param object the object to get the class name from
  88476. * @param isType defines if the object is actually a type
  88477. * @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.
  88478. * @ignorenaming
  88479. */
  88480. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  88481. /**
  88482. * Returns a promise that resolves after the given amount of time.
  88483. * @param delay Number of milliseconds to delay
  88484. * @returns Promise that resolves after the given amount of time
  88485. */
  88486. static DelayAsync(delay: number): Promise<void>;
  88487. /**
  88488. * Gets the current gradient from an array of IValueGradient
  88489. * @param ratio defines the current ratio to get
  88490. * @param gradients defines the array of IValueGradient
  88491. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  88492. */
  88493. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  88494. }
  88495. /**
  88496. * This class is used to track a performance counter which is number based.
  88497. * The user has access to many properties which give statistics of different nature.
  88498. *
  88499. * The implementer can track two kinds of Performance Counter: time and count.
  88500. * 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.
  88501. * 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.
  88502. */
  88503. export class PerfCounter {
  88504. /**
  88505. * Gets or sets a global boolean to turn on and off all the counters
  88506. */
  88507. static Enabled: boolean;
  88508. /**
  88509. * Returns the smallest value ever
  88510. */
  88511. readonly min: number;
  88512. /**
  88513. * Returns the biggest value ever
  88514. */
  88515. readonly max: number;
  88516. /**
  88517. * Returns the average value since the performance counter is running
  88518. */
  88519. readonly average: number;
  88520. /**
  88521. * Returns the average value of the last second the counter was monitored
  88522. */
  88523. readonly lastSecAverage: number;
  88524. /**
  88525. * Returns the current value
  88526. */
  88527. readonly current: number;
  88528. /**
  88529. * Gets the accumulated total
  88530. */
  88531. readonly total: number;
  88532. /**
  88533. * Gets the total value count
  88534. */
  88535. readonly count: number;
  88536. /**
  88537. * Creates a new counter
  88538. */
  88539. constructor();
  88540. /**
  88541. * Call this method to start monitoring a new frame.
  88542. * 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.
  88543. */
  88544. fetchNewFrame(): void;
  88545. /**
  88546. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  88547. * @param newCount the count value to add to the monitored count
  88548. * @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.
  88549. */
  88550. addCount(newCount: number, fetchResult: boolean): void;
  88551. /**
  88552. * Start monitoring this performance counter
  88553. */
  88554. beginMonitoring(): void;
  88555. /**
  88556. * Compute the time lapsed since the previous beginMonitoring() call.
  88557. * @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
  88558. */
  88559. endMonitoring(newFrame?: boolean): void;
  88560. private _fetchResult;
  88561. private _startMonitoringTime;
  88562. private _min;
  88563. private _max;
  88564. private _average;
  88565. private _current;
  88566. private _totalValueCount;
  88567. private _totalAccumulated;
  88568. private _lastSecAverage;
  88569. private _lastSecAccumulated;
  88570. private _lastSecTime;
  88571. private _lastSecValueCount;
  88572. }
  88573. /**
  88574. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  88575. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  88576. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  88577. * @param name The name of the class, case should be preserved
  88578. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  88579. */
  88580. export function className(name: string, module?: string): (target: Object) => void;
  88581. /**
  88582. * An implementation of a loop for asynchronous functions.
  88583. */
  88584. export class AsyncLoop {
  88585. /**
  88586. * Defines the number of iterations for the loop
  88587. */
  88588. iterations: number;
  88589. /**
  88590. * Defines the current index of the loop.
  88591. */
  88592. index: number;
  88593. private _done;
  88594. private _fn;
  88595. private _successCallback;
  88596. /**
  88597. * Constructor.
  88598. * @param iterations the number of iterations.
  88599. * @param func the function to run each iteration
  88600. * @param successCallback the callback that will be called upon succesful execution
  88601. * @param offset starting offset.
  88602. */
  88603. constructor(
  88604. /**
  88605. * Defines the number of iterations for the loop
  88606. */
  88607. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  88608. /**
  88609. * Execute the next iteration. Must be called after the last iteration was finished.
  88610. */
  88611. executeNext(): void;
  88612. /**
  88613. * Break the loop and run the success callback.
  88614. */
  88615. breakLoop(): void;
  88616. /**
  88617. * Create and run an async loop.
  88618. * @param iterations the number of iterations.
  88619. * @param fn the function to run each iteration
  88620. * @param successCallback the callback that will be called upon succesful execution
  88621. * @param offset starting offset.
  88622. * @returns the created async loop object
  88623. */
  88624. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  88625. /**
  88626. * A for-loop that will run a given number of iterations synchronous and the rest async.
  88627. * @param iterations total number of iterations
  88628. * @param syncedIterations number of synchronous iterations in each async iteration.
  88629. * @param fn the function to call each iteration.
  88630. * @param callback a success call back that will be called when iterating stops.
  88631. * @param breakFunction a break condition (optional)
  88632. * @param timeout timeout settings for the setTimeout function. default - 0.
  88633. * @returns the created async loop object
  88634. */
  88635. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  88636. }
  88637. }
  88638. declare module BABYLON {
  88639. /** @hidden */
  88640. export interface ICollisionCoordinator {
  88641. createCollider(): Collider;
  88642. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  88643. init(scene: Scene): void;
  88644. }
  88645. /** @hidden */
  88646. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  88647. private _scene;
  88648. private _scaledPosition;
  88649. private _scaledVelocity;
  88650. private _finalPosition;
  88651. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  88652. createCollider(): Collider;
  88653. init(scene: Scene): void;
  88654. private _collideWithWorld;
  88655. }
  88656. }
  88657. declare module BABYLON {
  88658. /**
  88659. * This class defines the direct association between an animation and a target
  88660. */
  88661. export class TargetedAnimation {
  88662. /**
  88663. * Animation to perform
  88664. */
  88665. animation: Animation;
  88666. /**
  88667. * Target to animate
  88668. */
  88669. target: any;
  88670. }
  88671. /**
  88672. * Use this class to create coordinated animations on multiple targets
  88673. */
  88674. export class AnimationGroup implements IDisposable {
  88675. /** The name of the animation group */
  88676. name: string;
  88677. private _scene;
  88678. private _targetedAnimations;
  88679. private _animatables;
  88680. private _from;
  88681. private _to;
  88682. private _isStarted;
  88683. private _isPaused;
  88684. private _speedRatio;
  88685. /**
  88686. * Gets or sets the unique id of the node
  88687. */
  88688. uniqueId: number;
  88689. /**
  88690. * This observable will notify when one animation have ended
  88691. */
  88692. onAnimationEndObservable: Observable<TargetedAnimation>;
  88693. /**
  88694. * Observer raised when one animation loops
  88695. */
  88696. onAnimationLoopObservable: Observable<TargetedAnimation>;
  88697. /**
  88698. * This observable will notify when all animations have ended.
  88699. */
  88700. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  88701. /**
  88702. * This observable will notify when all animations have paused.
  88703. */
  88704. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  88705. /**
  88706. * This observable will notify when all animations are playing.
  88707. */
  88708. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  88709. /**
  88710. * Gets the first frame
  88711. */
  88712. readonly from: number;
  88713. /**
  88714. * Gets the last frame
  88715. */
  88716. readonly to: number;
  88717. /**
  88718. * Define if the animations are started
  88719. */
  88720. readonly isStarted: boolean;
  88721. /**
  88722. * Gets a value indicating that the current group is playing
  88723. */
  88724. readonly isPlaying: boolean;
  88725. /**
  88726. * Gets or sets the speed ratio to use for all animations
  88727. */
  88728. /**
  88729. * Gets or sets the speed ratio to use for all animations
  88730. */
  88731. speedRatio: number;
  88732. /**
  88733. * Gets the targeted animations for this animation group
  88734. */
  88735. readonly targetedAnimations: Array<TargetedAnimation>;
  88736. /**
  88737. * returning the list of animatables controlled by this animation group.
  88738. */
  88739. readonly animatables: Array<Animatable>;
  88740. /**
  88741. * Instantiates a new Animation Group.
  88742. * This helps managing several animations at once.
  88743. * @see http://doc.babylonjs.com/how_to/group
  88744. * @param name Defines the name of the group
  88745. * @param scene Defines the scene the group belongs to
  88746. */
  88747. constructor(
  88748. /** The name of the animation group */
  88749. name: string, scene?: Nullable<Scene>);
  88750. /**
  88751. * Add an animation (with its target) in the group
  88752. * @param animation defines the animation we want to add
  88753. * @param target defines the target of the animation
  88754. * @returns the TargetedAnimation object
  88755. */
  88756. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  88757. /**
  88758. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  88759. * It can add constant keys at begin or end
  88760. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  88761. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  88762. * @returns the animation group
  88763. */
  88764. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  88765. /**
  88766. * Start all animations on given targets
  88767. * @param loop defines if animations must loop
  88768. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  88769. * @param from defines the from key (optional)
  88770. * @param to defines the to key (optional)
  88771. * @returns the current animation group
  88772. */
  88773. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  88774. /**
  88775. * Pause all animations
  88776. * @returns the animation group
  88777. */
  88778. pause(): AnimationGroup;
  88779. /**
  88780. * Play all animations to initial state
  88781. * This function will start() the animations if they were not started or will restart() them if they were paused
  88782. * @param loop defines if animations must loop
  88783. * @returns the animation group
  88784. */
  88785. play(loop?: boolean): AnimationGroup;
  88786. /**
  88787. * Reset all animations to initial state
  88788. * @returns the animation group
  88789. */
  88790. reset(): AnimationGroup;
  88791. /**
  88792. * Restart animations from key 0
  88793. * @returns the animation group
  88794. */
  88795. restart(): AnimationGroup;
  88796. /**
  88797. * Stop all animations
  88798. * @returns the animation group
  88799. */
  88800. stop(): AnimationGroup;
  88801. /**
  88802. * Set animation weight for all animatables
  88803. * @param weight defines the weight to use
  88804. * @return the animationGroup
  88805. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  88806. */
  88807. setWeightForAllAnimatables(weight: number): AnimationGroup;
  88808. /**
  88809. * Synchronize and normalize all animatables with a source animatable
  88810. * @param root defines the root animatable to synchronize with
  88811. * @return the animationGroup
  88812. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  88813. */
  88814. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  88815. /**
  88816. * Goes to a specific frame in this animation group
  88817. * @param frame the frame number to go to
  88818. * @return the animationGroup
  88819. */
  88820. goToFrame(frame: number): AnimationGroup;
  88821. /**
  88822. * Dispose all associated resources
  88823. */
  88824. dispose(): void;
  88825. private _checkAnimationGroupEnded;
  88826. /**
  88827. * Clone the current animation group and returns a copy
  88828. * @param newName defines the name of the new group
  88829. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  88830. * @returns the new aniamtion group
  88831. */
  88832. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  88833. /**
  88834. * Returns a new AnimationGroup object parsed from the source provided.
  88835. * @param parsedAnimationGroup defines the source
  88836. * @param scene defines the scene that will receive the animationGroup
  88837. * @returns a new AnimationGroup
  88838. */
  88839. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  88840. /**
  88841. * Returns the string "AnimationGroup"
  88842. * @returns "AnimationGroup"
  88843. */
  88844. getClassName(): string;
  88845. /**
  88846. * Creates a detailled string about the object
  88847. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  88848. * @returns a string representing the object
  88849. */
  88850. toString(fullDetails?: boolean): string;
  88851. }
  88852. }
  88853. declare module BABYLON {
  88854. /**
  88855. * Define an interface for all classes that will hold resources
  88856. */
  88857. export interface IDisposable {
  88858. /**
  88859. * Releases all held resources
  88860. */
  88861. dispose(): void;
  88862. }
  88863. /** Interface defining initialization parameters for Scene class */
  88864. export interface SceneOptions {
  88865. /**
  88866. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  88867. * It will improve performance when the number of geometries becomes important.
  88868. */
  88869. useGeometryUniqueIdsMap?: boolean;
  88870. /**
  88871. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  88872. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  88873. */
  88874. useMaterialMeshMap?: boolean;
  88875. /**
  88876. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  88877. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  88878. */
  88879. useClonedMeshhMap?: boolean;
  88880. }
  88881. /**
  88882. * Represents a scene to be rendered by the engine.
  88883. * @see http://doc.babylonjs.com/features/scene
  88884. */
  88885. export class Scene extends AbstractScene implements IAnimatable {
  88886. private static _uniqueIdCounter;
  88887. /** The fog is deactivated */
  88888. static readonly FOGMODE_NONE: number;
  88889. /** The fog density is following an exponential function */
  88890. static readonly FOGMODE_EXP: number;
  88891. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  88892. static readonly FOGMODE_EXP2: number;
  88893. /** The fog density is following a linear function. */
  88894. static readonly FOGMODE_LINEAR: number;
  88895. /**
  88896. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  88897. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88898. */
  88899. static MinDeltaTime: number;
  88900. /**
  88901. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  88902. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88903. */
  88904. static MaxDeltaTime: number;
  88905. /**
  88906. * Factory used to create the default material.
  88907. * @param name The name of the material to create
  88908. * @param scene The scene to create the material for
  88909. * @returns The default material
  88910. */
  88911. static DefaultMaterialFactory(scene: Scene): Material;
  88912. /**
  88913. * Factory used to create the a collision coordinator.
  88914. * @returns The collision coordinator
  88915. */
  88916. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  88917. /** @hidden */
  88918. readonly _isScene: boolean;
  88919. /**
  88920. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  88921. */
  88922. autoClear: boolean;
  88923. /**
  88924. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  88925. */
  88926. autoClearDepthAndStencil: boolean;
  88927. /**
  88928. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  88929. */
  88930. clearColor: Color4;
  88931. /**
  88932. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  88933. */
  88934. ambientColor: Color3;
  88935. /** @hidden */
  88936. _environmentBRDFTexture: BaseTexture;
  88937. /** @hidden */
  88938. protected _environmentTexture: Nullable<BaseTexture>;
  88939. /**
  88940. * Texture used in all pbr material as the reflection texture.
  88941. * As in the majority of the scene they are the same (exception for multi room and so on),
  88942. * this is easier to reference from here than from all the materials.
  88943. */
  88944. /**
  88945. * Texture used in all pbr material as the reflection texture.
  88946. * As in the majority of the scene they are the same (exception for multi room and so on),
  88947. * this is easier to set here than in all the materials.
  88948. */
  88949. environmentTexture: Nullable<BaseTexture>;
  88950. /** @hidden */
  88951. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  88952. /**
  88953. * Default image processing configuration used either in the rendering
  88954. * Forward main pass or through the imageProcessingPostProcess if present.
  88955. * As in the majority of the scene they are the same (exception for multi camera),
  88956. * this is easier to reference from here than from all the materials and post process.
  88957. *
  88958. * No setter as we it is a shared configuration, you can set the values instead.
  88959. */
  88960. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  88961. private _forceWireframe;
  88962. /**
  88963. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  88964. */
  88965. forceWireframe: boolean;
  88966. private _forcePointsCloud;
  88967. /**
  88968. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  88969. */
  88970. forcePointsCloud: boolean;
  88971. /**
  88972. * Gets or sets the active clipplane 1
  88973. */
  88974. clipPlane: Nullable<Plane>;
  88975. /**
  88976. * Gets or sets the active clipplane 2
  88977. */
  88978. clipPlane2: Nullable<Plane>;
  88979. /**
  88980. * Gets or sets the active clipplane 3
  88981. */
  88982. clipPlane3: Nullable<Plane>;
  88983. /**
  88984. * Gets or sets the active clipplane 4
  88985. */
  88986. clipPlane4: Nullable<Plane>;
  88987. /**
  88988. * Gets or sets a boolean indicating if animations are enabled
  88989. */
  88990. animationsEnabled: boolean;
  88991. private _animationPropertiesOverride;
  88992. /**
  88993. * Gets or sets the animation properties override
  88994. */
  88995. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  88996. /**
  88997. * Gets or sets a boolean indicating if a constant deltatime has to be used
  88998. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  88999. */
  89000. useConstantAnimationDeltaTime: boolean;
  89001. /**
  89002. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  89003. * Please note that it requires to run a ray cast through the scene on every frame
  89004. */
  89005. constantlyUpdateMeshUnderPointer: boolean;
  89006. /**
  89007. * Defines the HTML cursor to use when hovering over interactive elements
  89008. */
  89009. hoverCursor: string;
  89010. /**
  89011. * Defines the HTML default cursor to use (empty by default)
  89012. */
  89013. defaultCursor: string;
  89014. /**
  89015. * This is used to call preventDefault() on pointer down
  89016. * in order to block unwanted artifacts like system double clicks
  89017. */
  89018. preventDefaultOnPointerDown: boolean;
  89019. /**
  89020. * This is used to call preventDefault() on pointer up
  89021. * in order to block unwanted artifacts like system double clicks
  89022. */
  89023. preventDefaultOnPointerUp: boolean;
  89024. /**
  89025. * Gets or sets user defined metadata
  89026. */
  89027. metadata: any;
  89028. /**
  89029. * For internal use only. Please do not use.
  89030. */
  89031. reservedDataStore: any;
  89032. /**
  89033. * Gets the name of the plugin used to load this scene (null by default)
  89034. */
  89035. loadingPluginName: string;
  89036. /**
  89037. * Use this array to add regular expressions used to disable offline support for specific urls
  89038. */
  89039. disableOfflineSupportExceptionRules: RegExp[];
  89040. /**
  89041. * An event triggered when the scene is disposed.
  89042. */
  89043. onDisposeObservable: Observable<Scene>;
  89044. private _onDisposeObserver;
  89045. /** Sets a function to be executed when this scene is disposed. */
  89046. onDispose: () => void;
  89047. /**
  89048. * An event triggered before rendering the scene (right after animations and physics)
  89049. */
  89050. onBeforeRenderObservable: Observable<Scene>;
  89051. private _onBeforeRenderObserver;
  89052. /** Sets a function to be executed before rendering this scene */
  89053. beforeRender: Nullable<() => void>;
  89054. /**
  89055. * An event triggered after rendering the scene
  89056. */
  89057. onAfterRenderObservable: Observable<Scene>;
  89058. private _onAfterRenderObserver;
  89059. /** Sets a function to be executed after rendering this scene */
  89060. afterRender: Nullable<() => void>;
  89061. /**
  89062. * An event triggered before animating the scene
  89063. */
  89064. onBeforeAnimationsObservable: Observable<Scene>;
  89065. /**
  89066. * An event triggered after animations processing
  89067. */
  89068. onAfterAnimationsObservable: Observable<Scene>;
  89069. /**
  89070. * An event triggered before draw calls are ready to be sent
  89071. */
  89072. onBeforeDrawPhaseObservable: Observable<Scene>;
  89073. /**
  89074. * An event triggered after draw calls have been sent
  89075. */
  89076. onAfterDrawPhaseObservable: Observable<Scene>;
  89077. /**
  89078. * An event triggered when the scene is ready
  89079. */
  89080. onReadyObservable: Observable<Scene>;
  89081. /**
  89082. * An event triggered before rendering a camera
  89083. */
  89084. onBeforeCameraRenderObservable: Observable<Camera>;
  89085. private _onBeforeCameraRenderObserver;
  89086. /** Sets a function to be executed before rendering a camera*/
  89087. beforeCameraRender: () => void;
  89088. /**
  89089. * An event triggered after rendering a camera
  89090. */
  89091. onAfterCameraRenderObservable: Observable<Camera>;
  89092. private _onAfterCameraRenderObserver;
  89093. /** Sets a function to be executed after rendering a camera*/
  89094. afterCameraRender: () => void;
  89095. /**
  89096. * An event triggered when active meshes evaluation is about to start
  89097. */
  89098. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  89099. /**
  89100. * An event triggered when active meshes evaluation is done
  89101. */
  89102. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  89103. /**
  89104. * An event triggered when particles rendering is about to start
  89105. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  89106. */
  89107. onBeforeParticlesRenderingObservable: Observable<Scene>;
  89108. /**
  89109. * An event triggered when particles rendering is done
  89110. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  89111. */
  89112. onAfterParticlesRenderingObservable: Observable<Scene>;
  89113. /**
  89114. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  89115. */
  89116. onDataLoadedObservable: Observable<Scene>;
  89117. /**
  89118. * An event triggered when a camera is created
  89119. */
  89120. onNewCameraAddedObservable: Observable<Camera>;
  89121. /**
  89122. * An event triggered when a camera is removed
  89123. */
  89124. onCameraRemovedObservable: Observable<Camera>;
  89125. /**
  89126. * An event triggered when a light is created
  89127. */
  89128. onNewLightAddedObservable: Observable<Light>;
  89129. /**
  89130. * An event triggered when a light is removed
  89131. */
  89132. onLightRemovedObservable: Observable<Light>;
  89133. /**
  89134. * An event triggered when a geometry is created
  89135. */
  89136. onNewGeometryAddedObservable: Observable<Geometry>;
  89137. /**
  89138. * An event triggered when a geometry is removed
  89139. */
  89140. onGeometryRemovedObservable: Observable<Geometry>;
  89141. /**
  89142. * An event triggered when a transform node is created
  89143. */
  89144. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  89145. /**
  89146. * An event triggered when a transform node is removed
  89147. */
  89148. onTransformNodeRemovedObservable: Observable<TransformNode>;
  89149. /**
  89150. * An event triggered when a mesh is created
  89151. */
  89152. onNewMeshAddedObservable: Observable<AbstractMesh>;
  89153. /**
  89154. * An event triggered when a mesh is removed
  89155. */
  89156. onMeshRemovedObservable: Observable<AbstractMesh>;
  89157. /**
  89158. * An event triggered when a skeleton is created
  89159. */
  89160. onNewSkeletonAddedObservable: Observable<Skeleton>;
  89161. /**
  89162. * An event triggered when a skeleton is removed
  89163. */
  89164. onSkeletonRemovedObservable: Observable<Skeleton>;
  89165. /**
  89166. * An event triggered when a material is created
  89167. */
  89168. onNewMaterialAddedObservable: Observable<Material>;
  89169. /**
  89170. * An event triggered when a material is removed
  89171. */
  89172. onMaterialRemovedObservable: Observable<Material>;
  89173. /**
  89174. * An event triggered when a texture is created
  89175. */
  89176. onNewTextureAddedObservable: Observable<BaseTexture>;
  89177. /**
  89178. * An event triggered when a texture is removed
  89179. */
  89180. onTextureRemovedObservable: Observable<BaseTexture>;
  89181. /**
  89182. * An event triggered when render targets are about to be rendered
  89183. * Can happen multiple times per frame.
  89184. */
  89185. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  89186. /**
  89187. * An event triggered when render targets were rendered.
  89188. * Can happen multiple times per frame.
  89189. */
  89190. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  89191. /**
  89192. * An event triggered before calculating deterministic simulation step
  89193. */
  89194. onBeforeStepObservable: Observable<Scene>;
  89195. /**
  89196. * An event triggered after calculating deterministic simulation step
  89197. */
  89198. onAfterStepObservable: Observable<Scene>;
  89199. /**
  89200. * An event triggered when the activeCamera property is updated
  89201. */
  89202. onActiveCameraChanged: Observable<Scene>;
  89203. /**
  89204. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  89205. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  89206. * 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)
  89207. */
  89208. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  89209. /**
  89210. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  89211. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  89212. * 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)
  89213. */
  89214. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  89215. /**
  89216. * This Observable will when a mesh has been imported into the scene.
  89217. */
  89218. onMeshImportedObservable: Observable<AbstractMesh>;
  89219. /**
  89220. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  89221. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  89222. */
  89223. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  89224. /** @hidden */
  89225. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  89226. /**
  89227. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  89228. */
  89229. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  89230. /**
  89231. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  89232. */
  89233. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  89234. /**
  89235. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  89236. */
  89237. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  89238. private _onPointerMove;
  89239. private _onPointerDown;
  89240. private _onPointerUp;
  89241. /** Callback called when a pointer move is detected */
  89242. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  89243. /** Callback called when a pointer down is detected */
  89244. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  89245. /** Callback called when a pointer up is detected */
  89246. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  89247. /** Callback called when a pointer pick is detected */
  89248. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  89249. /**
  89250. * 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).
  89251. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  89252. */
  89253. onPrePointerObservable: Observable<PointerInfoPre>;
  89254. /**
  89255. * Observable event triggered each time an input event is received from the rendering canvas
  89256. */
  89257. onPointerObservable: Observable<PointerInfo>;
  89258. /**
  89259. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  89260. */
  89261. readonly unTranslatedPointer: Vector2;
  89262. /** The distance in pixel that you have to move to prevent some events */
  89263. static DragMovementThreshold: number;
  89264. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  89265. static LongPressDelay: number;
  89266. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  89267. static DoubleClickDelay: number;
  89268. /** If you need to check double click without raising a single click at first click, enable this flag */
  89269. static ExclusiveDoubleClickMode: boolean;
  89270. private _initClickEvent;
  89271. private _initActionManager;
  89272. private _delayedSimpleClick;
  89273. private _delayedSimpleClickTimeout;
  89274. private _previousDelayedSimpleClickTimeout;
  89275. private _meshPickProceed;
  89276. private _previousButtonPressed;
  89277. private _currentPickResult;
  89278. private _previousPickResult;
  89279. private _totalPointersPressed;
  89280. private _doubleClickOccured;
  89281. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  89282. cameraToUseForPointers: Nullable<Camera>;
  89283. private _pointerX;
  89284. private _pointerY;
  89285. private _unTranslatedPointerX;
  89286. private _unTranslatedPointerY;
  89287. private _startingPointerPosition;
  89288. private _previousStartingPointerPosition;
  89289. private _startingPointerTime;
  89290. private _previousStartingPointerTime;
  89291. private _pointerCaptures;
  89292. private _timeAccumulator;
  89293. private _currentStepId;
  89294. private _currentInternalStep;
  89295. /** @hidden */
  89296. _mirroredCameraPosition: Nullable<Vector3>;
  89297. /**
  89298. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  89299. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  89300. */
  89301. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  89302. /**
  89303. * Observable event triggered each time an keyboard event is received from the hosting window
  89304. */
  89305. onKeyboardObservable: Observable<KeyboardInfo>;
  89306. private _onKeyDown;
  89307. private _onKeyUp;
  89308. private _onCanvasFocusObserver;
  89309. private _onCanvasBlurObserver;
  89310. private _useRightHandedSystem;
  89311. /**
  89312. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  89313. */
  89314. useRightHandedSystem: boolean;
  89315. /**
  89316. * Sets the step Id used by deterministic lock step
  89317. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89318. * @param newStepId defines the step Id
  89319. */
  89320. setStepId(newStepId: number): void;
  89321. /**
  89322. * Gets the step Id used by deterministic lock step
  89323. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89324. * @returns the step Id
  89325. */
  89326. getStepId(): number;
  89327. /**
  89328. * Gets the internal step used by deterministic lock step
  89329. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89330. * @returns the internal step
  89331. */
  89332. getInternalStep(): number;
  89333. private _fogEnabled;
  89334. /**
  89335. * Gets or sets a boolean indicating if fog is enabled on this scene
  89336. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89337. * (Default is true)
  89338. */
  89339. fogEnabled: boolean;
  89340. private _fogMode;
  89341. /**
  89342. * Gets or sets the fog mode to use
  89343. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89344. * | mode | value |
  89345. * | --- | --- |
  89346. * | FOGMODE_NONE | 0 |
  89347. * | FOGMODE_EXP | 1 |
  89348. * | FOGMODE_EXP2 | 2 |
  89349. * | FOGMODE_LINEAR | 3 |
  89350. */
  89351. fogMode: number;
  89352. /**
  89353. * Gets or sets the fog color to use
  89354. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89355. * (Default is Color3(0.2, 0.2, 0.3))
  89356. */
  89357. fogColor: Color3;
  89358. /**
  89359. * Gets or sets the fog density to use
  89360. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89361. * (Default is 0.1)
  89362. */
  89363. fogDensity: number;
  89364. /**
  89365. * Gets or sets the fog start distance to use
  89366. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89367. * (Default is 0)
  89368. */
  89369. fogStart: number;
  89370. /**
  89371. * Gets or sets the fog end distance to use
  89372. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89373. * (Default is 1000)
  89374. */
  89375. fogEnd: number;
  89376. private _shadowsEnabled;
  89377. /**
  89378. * Gets or sets a boolean indicating if shadows are enabled on this scene
  89379. */
  89380. shadowsEnabled: boolean;
  89381. private _lightsEnabled;
  89382. /**
  89383. * Gets or sets a boolean indicating if lights are enabled on this scene
  89384. */
  89385. lightsEnabled: boolean;
  89386. /** All of the active cameras added to this scene. */
  89387. activeCameras: Camera[];
  89388. private _activeCamera;
  89389. /** Gets or sets the current active camera */
  89390. activeCamera: Nullable<Camera>;
  89391. private _defaultMaterial;
  89392. /** The default material used on meshes when no material is affected */
  89393. /** The default material used on meshes when no material is affected */
  89394. defaultMaterial: Material;
  89395. private _texturesEnabled;
  89396. /**
  89397. * Gets or sets a boolean indicating if textures are enabled on this scene
  89398. */
  89399. texturesEnabled: boolean;
  89400. /**
  89401. * Gets or sets a boolean indicating if particles are enabled on this scene
  89402. */
  89403. particlesEnabled: boolean;
  89404. /**
  89405. * Gets or sets a boolean indicating if sprites are enabled on this scene
  89406. */
  89407. spritesEnabled: boolean;
  89408. private _skeletonsEnabled;
  89409. /**
  89410. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  89411. */
  89412. skeletonsEnabled: boolean;
  89413. /**
  89414. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  89415. */
  89416. lensFlaresEnabled: boolean;
  89417. /**
  89418. * Gets or sets a boolean indicating if collisions are enabled on this scene
  89419. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89420. */
  89421. collisionsEnabled: boolean;
  89422. private _collisionCoordinator;
  89423. /** @hidden */
  89424. readonly collisionCoordinator: ICollisionCoordinator;
  89425. /**
  89426. * Defines the gravity applied to this scene (used only for collisions)
  89427. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89428. */
  89429. gravity: Vector3;
  89430. /**
  89431. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  89432. */
  89433. postProcessesEnabled: boolean;
  89434. /**
  89435. * The list of postprocesses added to the scene
  89436. */
  89437. postProcesses: PostProcess[];
  89438. /**
  89439. * Gets the current postprocess manager
  89440. */
  89441. postProcessManager: PostProcessManager;
  89442. /**
  89443. * Gets or sets a boolean indicating if render targets are enabled on this scene
  89444. */
  89445. renderTargetsEnabled: boolean;
  89446. /**
  89447. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  89448. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  89449. */
  89450. dumpNextRenderTargets: boolean;
  89451. /**
  89452. * The list of user defined render targets added to the scene
  89453. */
  89454. customRenderTargets: RenderTargetTexture[];
  89455. /**
  89456. * Defines if texture loading must be delayed
  89457. * If true, textures will only be loaded when they need to be rendered
  89458. */
  89459. useDelayedTextureLoading: boolean;
  89460. /**
  89461. * Gets the list of meshes imported to the scene through SceneLoader
  89462. */
  89463. importedMeshesFiles: String[];
  89464. /**
  89465. * Gets or sets a boolean indicating if probes are enabled on this scene
  89466. */
  89467. probesEnabled: boolean;
  89468. /**
  89469. * Gets or sets the current offline provider to use to store scene data
  89470. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  89471. */
  89472. offlineProvider: IOfflineProvider;
  89473. /**
  89474. * Gets or sets the action manager associated with the scene
  89475. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  89476. */
  89477. actionManager: AbstractActionManager;
  89478. private _meshesForIntersections;
  89479. /**
  89480. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  89481. */
  89482. proceduralTexturesEnabled: boolean;
  89483. private _engine;
  89484. private _totalVertices;
  89485. /** @hidden */
  89486. _activeIndices: PerfCounter;
  89487. /** @hidden */
  89488. _activeParticles: PerfCounter;
  89489. /** @hidden */
  89490. _activeBones: PerfCounter;
  89491. private _animationRatio;
  89492. /** @hidden */
  89493. _animationTimeLast: number;
  89494. /** @hidden */
  89495. _animationTime: number;
  89496. /**
  89497. * Gets or sets a general scale for animation speed
  89498. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  89499. */
  89500. animationTimeScale: number;
  89501. /** @hidden */
  89502. _cachedMaterial: Nullable<Material>;
  89503. /** @hidden */
  89504. _cachedEffect: Nullable<Effect>;
  89505. /** @hidden */
  89506. _cachedVisibility: Nullable<number>;
  89507. private _renderId;
  89508. private _frameId;
  89509. private _executeWhenReadyTimeoutId;
  89510. private _intermediateRendering;
  89511. private _viewUpdateFlag;
  89512. private _projectionUpdateFlag;
  89513. private _alternateViewUpdateFlag;
  89514. private _alternateProjectionUpdateFlag;
  89515. /** @hidden */
  89516. _toBeDisposed: Nullable<IDisposable>[];
  89517. private _activeRequests;
  89518. /** @hidden */
  89519. _pendingData: any[];
  89520. private _isDisposed;
  89521. /**
  89522. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  89523. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  89524. */
  89525. dispatchAllSubMeshesOfActiveMeshes: boolean;
  89526. private _activeMeshes;
  89527. private _processedMaterials;
  89528. private _renderTargets;
  89529. /** @hidden */
  89530. _activeParticleSystems: SmartArray<IParticleSystem>;
  89531. private _activeSkeletons;
  89532. private _softwareSkinnedMeshes;
  89533. private _renderingManager;
  89534. /** @hidden */
  89535. _activeAnimatables: Animatable[];
  89536. private _transformMatrix;
  89537. private _sceneUbo;
  89538. private _alternateSceneUbo;
  89539. private _viewMatrix;
  89540. private _projectionMatrix;
  89541. private _alternateViewMatrix;
  89542. private _alternateProjectionMatrix;
  89543. private _alternateTransformMatrix;
  89544. private _useAlternateCameraConfiguration;
  89545. private _alternateRendering;
  89546. private _wheelEventName;
  89547. /** @hidden */
  89548. _forcedViewPosition: Nullable<Vector3>;
  89549. /** @hidden */
  89550. readonly _isAlternateRenderingEnabled: boolean;
  89551. private _frustumPlanes;
  89552. /**
  89553. * Gets the list of frustum planes (built from the active camera)
  89554. */
  89555. readonly frustumPlanes: Plane[];
  89556. /**
  89557. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  89558. * This is useful if there are more lights that the maximum simulteanous authorized
  89559. */
  89560. requireLightSorting: boolean;
  89561. /** @hidden */
  89562. readonly useMaterialMeshMap: boolean;
  89563. /** @hidden */
  89564. readonly useClonedMeshhMap: boolean;
  89565. private _pointerOverMesh;
  89566. private _pickedDownMesh;
  89567. private _pickedUpMesh;
  89568. private _externalData;
  89569. private _uid;
  89570. /**
  89571. * @hidden
  89572. * Backing store of defined scene components.
  89573. */
  89574. _components: ISceneComponent[];
  89575. /**
  89576. * @hidden
  89577. * Backing store of defined scene components.
  89578. */
  89579. _serializableComponents: ISceneSerializableComponent[];
  89580. /**
  89581. * List of components to register on the next registration step.
  89582. */
  89583. private _transientComponents;
  89584. /**
  89585. * Registers the transient components if needed.
  89586. */
  89587. private _registerTransientComponents;
  89588. /**
  89589. * @hidden
  89590. * Add a component to the scene.
  89591. * Note that the ccomponent could be registered on th next frame if this is called after
  89592. * the register component stage.
  89593. * @param component Defines the component to add to the scene
  89594. */
  89595. _addComponent(component: ISceneComponent): void;
  89596. /**
  89597. * @hidden
  89598. * Gets a component from the scene.
  89599. * @param name defines the name of the component to retrieve
  89600. * @returns the component or null if not present
  89601. */
  89602. _getComponent(name: string): Nullable<ISceneComponent>;
  89603. /**
  89604. * @hidden
  89605. * Defines the actions happening before camera updates.
  89606. */
  89607. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  89608. /**
  89609. * @hidden
  89610. * Defines the actions happening before clear the canvas.
  89611. */
  89612. _beforeClearStage: Stage<SimpleStageAction>;
  89613. /**
  89614. * @hidden
  89615. * Defines the actions when collecting render targets for the frame.
  89616. */
  89617. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  89618. /**
  89619. * @hidden
  89620. * Defines the actions happening for one camera in the frame.
  89621. */
  89622. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  89623. /**
  89624. * @hidden
  89625. * Defines the actions happening during the per mesh ready checks.
  89626. */
  89627. _isReadyForMeshStage: Stage<MeshStageAction>;
  89628. /**
  89629. * @hidden
  89630. * Defines the actions happening before evaluate active mesh checks.
  89631. */
  89632. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  89633. /**
  89634. * @hidden
  89635. * Defines the actions happening during the evaluate sub mesh checks.
  89636. */
  89637. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  89638. /**
  89639. * @hidden
  89640. * Defines the actions happening during the active mesh stage.
  89641. */
  89642. _activeMeshStage: Stage<ActiveMeshStageAction>;
  89643. /**
  89644. * @hidden
  89645. * Defines the actions happening during the per camera render target step.
  89646. */
  89647. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  89648. /**
  89649. * @hidden
  89650. * Defines the actions happening just before the active camera is drawing.
  89651. */
  89652. _beforeCameraDrawStage: Stage<CameraStageAction>;
  89653. /**
  89654. * @hidden
  89655. * Defines the actions happening just before a render target is drawing.
  89656. */
  89657. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  89658. /**
  89659. * @hidden
  89660. * Defines the actions happening just before a rendering group is drawing.
  89661. */
  89662. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  89663. /**
  89664. * @hidden
  89665. * Defines the actions happening just before a mesh is drawing.
  89666. */
  89667. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  89668. /**
  89669. * @hidden
  89670. * Defines the actions happening just after a mesh has been drawn.
  89671. */
  89672. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  89673. /**
  89674. * @hidden
  89675. * Defines the actions happening just after a rendering group has been drawn.
  89676. */
  89677. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  89678. /**
  89679. * @hidden
  89680. * Defines the actions happening just after the active camera has been drawn.
  89681. */
  89682. _afterCameraDrawStage: Stage<CameraStageAction>;
  89683. /**
  89684. * @hidden
  89685. * Defines the actions happening just after a render target has been drawn.
  89686. */
  89687. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  89688. /**
  89689. * @hidden
  89690. * Defines the actions happening just after rendering all cameras and computing intersections.
  89691. */
  89692. _afterRenderStage: Stage<SimpleStageAction>;
  89693. /**
  89694. * @hidden
  89695. * Defines the actions happening when a pointer move event happens.
  89696. */
  89697. _pointerMoveStage: Stage<PointerMoveStageAction>;
  89698. /**
  89699. * @hidden
  89700. * Defines the actions happening when a pointer down event happens.
  89701. */
  89702. _pointerDownStage: Stage<PointerUpDownStageAction>;
  89703. /**
  89704. * @hidden
  89705. * Defines the actions happening when a pointer up event happens.
  89706. */
  89707. _pointerUpStage: Stage<PointerUpDownStageAction>;
  89708. /**
  89709. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  89710. */
  89711. private geometriesByUniqueId;
  89712. /**
  89713. * Creates a new Scene
  89714. * @param engine defines the engine to use to render this scene
  89715. * @param options defines the scene options
  89716. */
  89717. constructor(engine: Engine, options?: SceneOptions);
  89718. private _defaultMeshCandidates;
  89719. /**
  89720. * @hidden
  89721. */
  89722. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  89723. private _defaultSubMeshCandidates;
  89724. /**
  89725. * @hidden
  89726. */
  89727. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  89728. /**
  89729. * Sets the default candidate providers for the scene.
  89730. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  89731. * and getCollidingSubMeshCandidates to their default function
  89732. */
  89733. setDefaultCandidateProviders(): void;
  89734. /**
  89735. * Gets the mesh that is currently under the pointer
  89736. */
  89737. readonly meshUnderPointer: Nullable<AbstractMesh>;
  89738. /**
  89739. * Gets or sets the current on-screen X position of the pointer
  89740. */
  89741. pointerX: number;
  89742. /**
  89743. * Gets or sets the current on-screen Y position of the pointer
  89744. */
  89745. pointerY: number;
  89746. /**
  89747. * Gets the cached material (ie. the latest rendered one)
  89748. * @returns the cached material
  89749. */
  89750. getCachedMaterial(): Nullable<Material>;
  89751. /**
  89752. * Gets the cached effect (ie. the latest rendered one)
  89753. * @returns the cached effect
  89754. */
  89755. getCachedEffect(): Nullable<Effect>;
  89756. /**
  89757. * Gets the cached visibility state (ie. the latest rendered one)
  89758. * @returns the cached visibility state
  89759. */
  89760. getCachedVisibility(): Nullable<number>;
  89761. /**
  89762. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  89763. * @param material defines the current material
  89764. * @param effect defines the current effect
  89765. * @param visibility defines the current visibility state
  89766. * @returns true if one parameter is not cached
  89767. */
  89768. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  89769. /**
  89770. * Gets the engine associated with the scene
  89771. * @returns an Engine
  89772. */
  89773. getEngine(): Engine;
  89774. /**
  89775. * Gets the total number of vertices rendered per frame
  89776. * @returns the total number of vertices rendered per frame
  89777. */
  89778. getTotalVertices(): number;
  89779. /**
  89780. * Gets the performance counter for total vertices
  89781. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89782. */
  89783. readonly totalVerticesPerfCounter: PerfCounter;
  89784. /**
  89785. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  89786. * @returns the total number of active indices rendered per frame
  89787. */
  89788. getActiveIndices(): number;
  89789. /**
  89790. * Gets the performance counter for active indices
  89791. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89792. */
  89793. readonly totalActiveIndicesPerfCounter: PerfCounter;
  89794. /**
  89795. * Gets the total number of active particles rendered per frame
  89796. * @returns the total number of active particles rendered per frame
  89797. */
  89798. getActiveParticles(): number;
  89799. /**
  89800. * Gets the performance counter for active particles
  89801. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89802. */
  89803. readonly activeParticlesPerfCounter: PerfCounter;
  89804. /**
  89805. * Gets the total number of active bones rendered per frame
  89806. * @returns the total number of active bones rendered per frame
  89807. */
  89808. getActiveBones(): number;
  89809. /**
  89810. * Gets the performance counter for active bones
  89811. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89812. */
  89813. readonly activeBonesPerfCounter: PerfCounter;
  89814. /**
  89815. * Gets the array of active meshes
  89816. * @returns an array of AbstractMesh
  89817. */
  89818. getActiveMeshes(): SmartArray<AbstractMesh>;
  89819. /**
  89820. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  89821. * @returns a number
  89822. */
  89823. getAnimationRatio(): number;
  89824. /**
  89825. * Gets an unique Id for the current render phase
  89826. * @returns a number
  89827. */
  89828. getRenderId(): number;
  89829. /**
  89830. * Gets an unique Id for the current frame
  89831. * @returns a number
  89832. */
  89833. getFrameId(): number;
  89834. /** Call this function if you want to manually increment the render Id*/
  89835. incrementRenderId(): void;
  89836. private _updatePointerPosition;
  89837. private _createUbo;
  89838. private _createAlternateUbo;
  89839. private _setRayOnPointerInfo;
  89840. /**
  89841. * Use this method to simulate a pointer move on a mesh
  89842. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  89843. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  89844. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  89845. * @returns the current scene
  89846. */
  89847. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  89848. private _processPointerMove;
  89849. private _checkPrePointerObservable;
  89850. /**
  89851. * Use this method to simulate a pointer down on a mesh
  89852. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  89853. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  89854. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  89855. * @returns the current scene
  89856. */
  89857. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  89858. private _processPointerDown;
  89859. /**
  89860. * Use this method to simulate a pointer up on a mesh
  89861. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  89862. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  89863. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  89864. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  89865. * @returns the current scene
  89866. */
  89867. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  89868. private _processPointerUp;
  89869. /**
  89870. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  89871. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  89872. * @returns true if the pointer was captured
  89873. */
  89874. isPointerCaptured(pointerId?: number): boolean;
  89875. /** @hidden */
  89876. _isPointerSwiping(): boolean;
  89877. /**
  89878. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  89879. * @param attachUp defines if you want to attach events to pointerup
  89880. * @param attachDown defines if you want to attach events to pointerdown
  89881. * @param attachMove defines if you want to attach events to pointermove
  89882. */
  89883. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  89884. /** Detaches all event handlers*/
  89885. detachControl(): void;
  89886. /**
  89887. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  89888. * Delay loaded resources are not taking in account
  89889. * @return true if all required resources are ready
  89890. */
  89891. isReady(): boolean;
  89892. /** Resets all cached information relative to material (including effect and visibility) */
  89893. resetCachedMaterial(): void;
  89894. /**
  89895. * Registers a function to be called before every frame render
  89896. * @param func defines the function to register
  89897. */
  89898. registerBeforeRender(func: () => void): void;
  89899. /**
  89900. * Unregisters a function called before every frame render
  89901. * @param func defines the function to unregister
  89902. */
  89903. unregisterBeforeRender(func: () => void): void;
  89904. /**
  89905. * Registers a function to be called after every frame render
  89906. * @param func defines the function to register
  89907. */
  89908. registerAfterRender(func: () => void): void;
  89909. /**
  89910. * Unregisters a function called after every frame render
  89911. * @param func defines the function to unregister
  89912. */
  89913. unregisterAfterRender(func: () => void): void;
  89914. private _executeOnceBeforeRender;
  89915. /**
  89916. * The provided function will run before render once and will be disposed afterwards.
  89917. * A timeout delay can be provided so that the function will be executed in N ms.
  89918. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  89919. * @param func The function to be executed.
  89920. * @param timeout optional delay in ms
  89921. */
  89922. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  89923. /** @hidden */
  89924. _addPendingData(data: any): void;
  89925. /** @hidden */
  89926. _removePendingData(data: any): void;
  89927. /**
  89928. * Returns the number of items waiting to be loaded
  89929. * @returns the number of items waiting to be loaded
  89930. */
  89931. getWaitingItemsCount(): number;
  89932. /**
  89933. * Returns a boolean indicating if the scene is still loading data
  89934. */
  89935. readonly isLoading: boolean;
  89936. /**
  89937. * Registers a function to be executed when the scene is ready
  89938. * @param {Function} func - the function to be executed
  89939. */
  89940. executeWhenReady(func: () => void): void;
  89941. /**
  89942. * Returns a promise that resolves when the scene is ready
  89943. * @returns A promise that resolves when the scene is ready
  89944. */
  89945. whenReadyAsync(): Promise<void>;
  89946. /** @hidden */
  89947. _checkIsReady(): void;
  89948. /**
  89949. * Gets all animatable attached to the scene
  89950. */
  89951. readonly animatables: Animatable[];
  89952. /**
  89953. * Resets the last animation time frame.
  89954. * Useful to override when animations start running when loading a scene for the first time.
  89955. */
  89956. resetLastAnimationTimeFrame(): void;
  89957. /** @hidden */
  89958. _switchToAlternateCameraConfiguration(active: boolean): void;
  89959. /**
  89960. * Gets the current view matrix
  89961. * @returns a Matrix
  89962. */
  89963. getViewMatrix(): Matrix;
  89964. /**
  89965. * Gets the current projection matrix
  89966. * @returns a Matrix
  89967. */
  89968. getProjectionMatrix(): Matrix;
  89969. /**
  89970. * Gets the current transform matrix
  89971. * @returns a Matrix made of View * Projection
  89972. */
  89973. getTransformMatrix(): Matrix;
  89974. /**
  89975. * Sets the current transform matrix
  89976. * @param view defines the View matrix to use
  89977. * @param projection defines the Projection matrix to use
  89978. */
  89979. setTransformMatrix(view: Matrix, projection: Matrix): void;
  89980. /** @hidden */
  89981. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  89982. /**
  89983. * Gets the uniform buffer used to store scene data
  89984. * @returns a UniformBuffer
  89985. */
  89986. getSceneUniformBuffer(): UniformBuffer;
  89987. /**
  89988. * Gets an unique (relatively to the current scene) Id
  89989. * @returns an unique number for the scene
  89990. */
  89991. getUniqueId(): number;
  89992. /**
  89993. * Add a mesh to the list of scene's meshes
  89994. * @param newMesh defines the mesh to add
  89995. * @param recursive if all child meshes should also be added to the scene
  89996. */
  89997. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  89998. /**
  89999. * Remove a mesh for the list of scene's meshes
  90000. * @param toRemove defines the mesh to remove
  90001. * @param recursive if all child meshes should also be removed from the scene
  90002. * @returns the index where the mesh was in the mesh list
  90003. */
  90004. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  90005. /**
  90006. * Add a transform node to the list of scene's transform nodes
  90007. * @param newTransformNode defines the transform node to add
  90008. */
  90009. addTransformNode(newTransformNode: TransformNode): void;
  90010. /**
  90011. * Remove a transform node for the list of scene's transform nodes
  90012. * @param toRemove defines the transform node to remove
  90013. * @returns the index where the transform node was in the transform node list
  90014. */
  90015. removeTransformNode(toRemove: TransformNode): number;
  90016. /**
  90017. * Remove a skeleton for the list of scene's skeletons
  90018. * @param toRemove defines the skeleton to remove
  90019. * @returns the index where the skeleton was in the skeleton list
  90020. */
  90021. removeSkeleton(toRemove: Skeleton): number;
  90022. /**
  90023. * Remove a morph target for the list of scene's morph targets
  90024. * @param toRemove defines the morph target to remove
  90025. * @returns the index where the morph target was in the morph target list
  90026. */
  90027. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  90028. /**
  90029. * Remove a light for the list of scene's lights
  90030. * @param toRemove defines the light to remove
  90031. * @returns the index where the light was in the light list
  90032. */
  90033. removeLight(toRemove: Light): number;
  90034. /**
  90035. * Remove a camera for the list of scene's cameras
  90036. * @param toRemove defines the camera to remove
  90037. * @returns the index where the camera was in the camera list
  90038. */
  90039. removeCamera(toRemove: Camera): number;
  90040. /**
  90041. * Remove a particle system for the list of scene's particle systems
  90042. * @param toRemove defines the particle system to remove
  90043. * @returns the index where the particle system was in the particle system list
  90044. */
  90045. removeParticleSystem(toRemove: IParticleSystem): number;
  90046. /**
  90047. * Remove a animation for the list of scene's animations
  90048. * @param toRemove defines the animation to remove
  90049. * @returns the index where the animation was in the animation list
  90050. */
  90051. removeAnimation(toRemove: Animation): number;
  90052. /**
  90053. * Removes the given animation group from this scene.
  90054. * @param toRemove The animation group to remove
  90055. * @returns The index of the removed animation group
  90056. */
  90057. removeAnimationGroup(toRemove: AnimationGroup): number;
  90058. /**
  90059. * Removes the given multi-material from this scene.
  90060. * @param toRemove The multi-material to remove
  90061. * @returns The index of the removed multi-material
  90062. */
  90063. removeMultiMaterial(toRemove: MultiMaterial): number;
  90064. /**
  90065. * Removes the given material from this scene.
  90066. * @param toRemove The material to remove
  90067. * @returns The index of the removed material
  90068. */
  90069. removeMaterial(toRemove: Material): number;
  90070. /**
  90071. * Removes the given action manager from this scene.
  90072. * @param toRemove The action manager to remove
  90073. * @returns The index of the removed action manager
  90074. */
  90075. removeActionManager(toRemove: AbstractActionManager): number;
  90076. /**
  90077. * Removes the given texture from this scene.
  90078. * @param toRemove The texture to remove
  90079. * @returns The index of the removed texture
  90080. */
  90081. removeTexture(toRemove: BaseTexture): number;
  90082. /**
  90083. * Adds the given light to this scene
  90084. * @param newLight The light to add
  90085. */
  90086. addLight(newLight: Light): void;
  90087. /**
  90088. * Sorts the list list based on light priorities
  90089. */
  90090. sortLightsByPriority(): void;
  90091. /**
  90092. * Adds the given camera to this scene
  90093. * @param newCamera The camera to add
  90094. */
  90095. addCamera(newCamera: Camera): void;
  90096. /**
  90097. * Adds the given skeleton to this scene
  90098. * @param newSkeleton The skeleton to add
  90099. */
  90100. addSkeleton(newSkeleton: Skeleton): void;
  90101. /**
  90102. * Adds the given particle system to this scene
  90103. * @param newParticleSystem The particle system to add
  90104. */
  90105. addParticleSystem(newParticleSystem: IParticleSystem): void;
  90106. /**
  90107. * Adds the given animation to this scene
  90108. * @param newAnimation The animation to add
  90109. */
  90110. addAnimation(newAnimation: Animation): void;
  90111. /**
  90112. * Adds the given animation group to this scene.
  90113. * @param newAnimationGroup The animation group to add
  90114. */
  90115. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  90116. /**
  90117. * Adds the given multi-material to this scene
  90118. * @param newMultiMaterial The multi-material to add
  90119. */
  90120. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  90121. /**
  90122. * Adds the given material to this scene
  90123. * @param newMaterial The material to add
  90124. */
  90125. addMaterial(newMaterial: Material): void;
  90126. /**
  90127. * Adds the given morph target to this scene
  90128. * @param newMorphTargetManager The morph target to add
  90129. */
  90130. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  90131. /**
  90132. * Adds the given geometry to this scene
  90133. * @param newGeometry The geometry to add
  90134. */
  90135. addGeometry(newGeometry: Geometry): void;
  90136. /**
  90137. * Adds the given action manager to this scene
  90138. * @param newActionManager The action manager to add
  90139. */
  90140. addActionManager(newActionManager: AbstractActionManager): void;
  90141. /**
  90142. * Adds the given texture to this scene.
  90143. * @param newTexture The texture to add
  90144. */
  90145. addTexture(newTexture: BaseTexture): void;
  90146. /**
  90147. * Switch active camera
  90148. * @param newCamera defines the new active camera
  90149. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  90150. */
  90151. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  90152. /**
  90153. * sets the active camera of the scene using its ID
  90154. * @param id defines the camera's ID
  90155. * @return the new active camera or null if none found.
  90156. */
  90157. setActiveCameraByID(id: string): Nullable<Camera>;
  90158. /**
  90159. * sets the active camera of the scene using its name
  90160. * @param name defines the camera's name
  90161. * @returns the new active camera or null if none found.
  90162. */
  90163. setActiveCameraByName(name: string): Nullable<Camera>;
  90164. /**
  90165. * get an animation group using its name
  90166. * @param name defines the material's name
  90167. * @return the animation group or null if none found.
  90168. */
  90169. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  90170. /**
  90171. * get a material using its id
  90172. * @param id defines the material's ID
  90173. * @return the material or null if none found.
  90174. */
  90175. getMaterialByID(id: string): Nullable<Material>;
  90176. /**
  90177. * Gets a material using its name
  90178. * @param name defines the material's name
  90179. * @return the material or null if none found.
  90180. */
  90181. getMaterialByName(name: string): Nullable<Material>;
  90182. /**
  90183. * Gets a camera using its id
  90184. * @param id defines the id to look for
  90185. * @returns the camera or null if not found
  90186. */
  90187. getCameraByID(id: string): Nullable<Camera>;
  90188. /**
  90189. * Gets a camera using its unique id
  90190. * @param uniqueId defines the unique id to look for
  90191. * @returns the camera or null if not found
  90192. */
  90193. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  90194. /**
  90195. * Gets a camera using its name
  90196. * @param name defines the camera's name
  90197. * @return the camera or null if none found.
  90198. */
  90199. getCameraByName(name: string): Nullable<Camera>;
  90200. /**
  90201. * Gets a bone using its id
  90202. * @param id defines the bone's id
  90203. * @return the bone or null if not found
  90204. */
  90205. getBoneByID(id: string): Nullable<Bone>;
  90206. /**
  90207. * Gets a bone using its id
  90208. * @param name defines the bone's name
  90209. * @return the bone or null if not found
  90210. */
  90211. getBoneByName(name: string): Nullable<Bone>;
  90212. /**
  90213. * Gets a light node using its name
  90214. * @param name defines the the light's name
  90215. * @return the light or null if none found.
  90216. */
  90217. getLightByName(name: string): Nullable<Light>;
  90218. /**
  90219. * Gets a light node using its id
  90220. * @param id defines the light's id
  90221. * @return the light or null if none found.
  90222. */
  90223. getLightByID(id: string): Nullable<Light>;
  90224. /**
  90225. * Gets a light node using its scene-generated unique ID
  90226. * @param uniqueId defines the light's unique id
  90227. * @return the light or null if none found.
  90228. */
  90229. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  90230. /**
  90231. * Gets a particle system by id
  90232. * @param id defines the particle system id
  90233. * @return the corresponding system or null if none found
  90234. */
  90235. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  90236. /**
  90237. * Gets a geometry using its ID
  90238. * @param id defines the geometry's id
  90239. * @return the geometry or null if none found.
  90240. */
  90241. getGeometryByID(id: string): Nullable<Geometry>;
  90242. private _getGeometryByUniqueID;
  90243. /**
  90244. * Add a new geometry to this scene
  90245. * @param geometry defines the geometry to be added to the scene.
  90246. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  90247. * @return a boolean defining if the geometry was added or not
  90248. */
  90249. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  90250. /**
  90251. * Removes an existing geometry
  90252. * @param geometry defines the geometry to be removed from the scene
  90253. * @return a boolean defining if the geometry was removed or not
  90254. */
  90255. removeGeometry(geometry: Geometry): boolean;
  90256. /**
  90257. * Gets the list of geometries attached to the scene
  90258. * @returns an array of Geometry
  90259. */
  90260. getGeometries(): Geometry[];
  90261. /**
  90262. * Gets the first added mesh found of a given ID
  90263. * @param id defines the id to search for
  90264. * @return the mesh found or null if not found at all
  90265. */
  90266. getMeshByID(id: string): Nullable<AbstractMesh>;
  90267. /**
  90268. * Gets a list of meshes using their id
  90269. * @param id defines the id to search for
  90270. * @returns a list of meshes
  90271. */
  90272. getMeshesByID(id: string): Array<AbstractMesh>;
  90273. /**
  90274. * Gets the first added transform node found of a given ID
  90275. * @param id defines the id to search for
  90276. * @return the found transform node or null if not found at all.
  90277. */
  90278. getTransformNodeByID(id: string): Nullable<TransformNode>;
  90279. /**
  90280. * Gets a list of transform nodes using their id
  90281. * @param id defines the id to search for
  90282. * @returns a list of transform nodes
  90283. */
  90284. getTransformNodesByID(id: string): Array<TransformNode>;
  90285. /**
  90286. * Gets a mesh with its auto-generated unique id
  90287. * @param uniqueId defines the unique id to search for
  90288. * @return the found mesh or null if not found at all.
  90289. */
  90290. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  90291. /**
  90292. * Gets a the last added mesh using a given id
  90293. * @param id defines the id to search for
  90294. * @return the found mesh or null if not found at all.
  90295. */
  90296. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  90297. /**
  90298. * Gets a the last added node (Mesh, Camera, Light) using a given id
  90299. * @param id defines the id to search for
  90300. * @return the found node or null if not found at all
  90301. */
  90302. getLastEntryByID(id: string): Nullable<Node>;
  90303. /**
  90304. * Gets a node (Mesh, Camera, Light) using a given id
  90305. * @param id defines the id to search for
  90306. * @return the found node or null if not found at all
  90307. */
  90308. getNodeByID(id: string): Nullable<Node>;
  90309. /**
  90310. * Gets a node (Mesh, Camera, Light) using a given name
  90311. * @param name defines the name to search for
  90312. * @return the found node or null if not found at all.
  90313. */
  90314. getNodeByName(name: string): Nullable<Node>;
  90315. /**
  90316. * Gets a mesh using a given name
  90317. * @param name defines the name to search for
  90318. * @return the found mesh or null if not found at all.
  90319. */
  90320. getMeshByName(name: string): Nullable<AbstractMesh>;
  90321. /**
  90322. * Gets a transform node using a given name
  90323. * @param name defines the name to search for
  90324. * @return the found transform node or null if not found at all.
  90325. */
  90326. getTransformNodeByName(name: string): Nullable<TransformNode>;
  90327. /**
  90328. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  90329. * @param id defines the id to search for
  90330. * @return the found skeleton or null if not found at all.
  90331. */
  90332. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  90333. /**
  90334. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  90335. * @param id defines the id to search for
  90336. * @return the found skeleton or null if not found at all.
  90337. */
  90338. getSkeletonById(id: string): Nullable<Skeleton>;
  90339. /**
  90340. * Gets a skeleton using a given name
  90341. * @param name defines the name to search for
  90342. * @return the found skeleton or null if not found at all.
  90343. */
  90344. getSkeletonByName(name: string): Nullable<Skeleton>;
  90345. /**
  90346. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  90347. * @param id defines the id to search for
  90348. * @return the found morph target manager or null if not found at all.
  90349. */
  90350. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  90351. /**
  90352. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  90353. * @param id defines the id to search for
  90354. * @return the found morph target or null if not found at all.
  90355. */
  90356. getMorphTargetById(id: string): Nullable<MorphTarget>;
  90357. /**
  90358. * Gets a boolean indicating if the given mesh is active
  90359. * @param mesh defines the mesh to look for
  90360. * @returns true if the mesh is in the active list
  90361. */
  90362. isActiveMesh(mesh: AbstractMesh): boolean;
  90363. /**
  90364. * Return a unique id as a string which can serve as an identifier for the scene
  90365. */
  90366. readonly uid: string;
  90367. /**
  90368. * Add an externaly attached data from its key.
  90369. * This method call will fail and return false, if such key already exists.
  90370. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  90371. * @param key the unique key that identifies the data
  90372. * @param data the data object to associate to the key for this Engine instance
  90373. * @return true if no such key were already present and the data was added successfully, false otherwise
  90374. */
  90375. addExternalData<T>(key: string, data: T): boolean;
  90376. /**
  90377. * Get an externaly attached data from its key
  90378. * @param key the unique key that identifies the data
  90379. * @return the associated data, if present (can be null), or undefined if not present
  90380. */
  90381. getExternalData<T>(key: string): Nullable<T>;
  90382. /**
  90383. * Get an externaly attached data from its key, create it using a factory if it's not already present
  90384. * @param key the unique key that identifies the data
  90385. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  90386. * @return the associated data, can be null if the factory returned null.
  90387. */
  90388. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  90389. /**
  90390. * Remove an externaly attached data from the Engine instance
  90391. * @param key the unique key that identifies the data
  90392. * @return true if the data was successfully removed, false if it doesn't exist
  90393. */
  90394. removeExternalData(key: string): boolean;
  90395. private _evaluateSubMesh;
  90396. /**
  90397. * Clear the processed materials smart array preventing retention point in material dispose.
  90398. */
  90399. freeProcessedMaterials(): void;
  90400. private _preventFreeActiveMeshesAndRenderingGroups;
  90401. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  90402. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  90403. * when disposing several meshes in a row or a hierarchy of meshes.
  90404. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  90405. */
  90406. blockfreeActiveMeshesAndRenderingGroups: boolean;
  90407. /**
  90408. * Clear the active meshes smart array preventing retention point in mesh dispose.
  90409. */
  90410. freeActiveMeshes(): void;
  90411. /**
  90412. * Clear the info related to rendering groups preventing retention points during dispose.
  90413. */
  90414. freeRenderingGroups(): void;
  90415. /** @hidden */
  90416. _isInIntermediateRendering(): boolean;
  90417. /**
  90418. * Lambda returning the list of potentially active meshes.
  90419. */
  90420. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  90421. /**
  90422. * Lambda returning the list of potentially active sub meshes.
  90423. */
  90424. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  90425. /**
  90426. * Lambda returning the list of potentially intersecting sub meshes.
  90427. */
  90428. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  90429. /**
  90430. * Lambda returning the list of potentially colliding sub meshes.
  90431. */
  90432. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  90433. private _activeMeshesFrozen;
  90434. /**
  90435. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  90436. * @returns the current scene
  90437. */
  90438. freezeActiveMeshes(): Scene;
  90439. /**
  90440. * Use this function to restart evaluating active meshes on every frame
  90441. * @returns the current scene
  90442. */
  90443. unfreezeActiveMeshes(): Scene;
  90444. private _evaluateActiveMeshes;
  90445. private _activeMesh;
  90446. /**
  90447. * Update the transform matrix to update from the current active camera
  90448. * @param force defines a boolean used to force the update even if cache is up to date
  90449. */
  90450. updateTransformMatrix(force?: boolean): void;
  90451. /**
  90452. * 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)
  90453. * @param alternateCamera defines the camera to use
  90454. */
  90455. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  90456. /** @hidden */
  90457. _allowPostProcessClearColor: boolean;
  90458. private _renderForCamera;
  90459. private _processSubCameras;
  90460. private _checkIntersections;
  90461. /** @hidden */
  90462. _advancePhysicsEngineStep(step: number): void;
  90463. /**
  90464. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  90465. */
  90466. getDeterministicFrameTime: () => number;
  90467. /** @hidden */
  90468. _animate(): void;
  90469. /**
  90470. * Render the scene
  90471. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  90472. */
  90473. render(updateCameras?: boolean): void;
  90474. /**
  90475. * Freeze all materials
  90476. * A frozen material will not be updatable but should be faster to render
  90477. */
  90478. freezeMaterials(): void;
  90479. /**
  90480. * Unfreeze all materials
  90481. * A frozen material will not be updatable but should be faster to render
  90482. */
  90483. unfreezeMaterials(): void;
  90484. /**
  90485. * Releases all held ressources
  90486. */
  90487. dispose(): void;
  90488. /**
  90489. * Gets if the scene is already disposed
  90490. */
  90491. readonly isDisposed: boolean;
  90492. /**
  90493. * Call this function to reduce memory footprint of the scene.
  90494. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  90495. */
  90496. clearCachedVertexData(): void;
  90497. /**
  90498. * This function will remove the local cached buffer data from texture.
  90499. * It will save memory but will prevent the texture from being rebuilt
  90500. */
  90501. cleanCachedTextureBuffer(): void;
  90502. /**
  90503. * Get the world extend vectors with an optional filter
  90504. *
  90505. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  90506. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  90507. */
  90508. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  90509. min: Vector3;
  90510. max: Vector3;
  90511. };
  90512. /**
  90513. * Creates a ray that can be used to pick in the scene
  90514. * @param x defines the x coordinate of the origin (on-screen)
  90515. * @param y defines the y coordinate of the origin (on-screen)
  90516. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  90517. * @param camera defines the camera to use for the picking
  90518. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  90519. * @returns a Ray
  90520. */
  90521. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  90522. /**
  90523. * Creates a ray that can be used to pick in the scene
  90524. * @param x defines the x coordinate of the origin (on-screen)
  90525. * @param y defines the y coordinate of the origin (on-screen)
  90526. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  90527. * @param result defines the ray where to store the picking ray
  90528. * @param camera defines the camera to use for the picking
  90529. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  90530. * @returns the current scene
  90531. */
  90532. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  90533. /**
  90534. * Creates a ray that can be used to pick in the scene
  90535. * @param x defines the x coordinate of the origin (on-screen)
  90536. * @param y defines the y coordinate of the origin (on-screen)
  90537. * @param camera defines the camera to use for the picking
  90538. * @returns a Ray
  90539. */
  90540. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  90541. /**
  90542. * Creates a ray that can be used to pick in the scene
  90543. * @param x defines the x coordinate of the origin (on-screen)
  90544. * @param y defines the y coordinate of the origin (on-screen)
  90545. * @param result defines the ray where to store the picking ray
  90546. * @param camera defines the camera to use for the picking
  90547. * @returns the current scene
  90548. */
  90549. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  90550. /** Launch a ray to try to pick a mesh in the scene
  90551. * @param x position on screen
  90552. * @param y position on screen
  90553. * @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
  90554. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  90555. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  90556. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90557. * @returns a PickingInfo
  90558. */
  90559. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  90560. /** Use the given ray to pick a mesh in the scene
  90561. * @param ray The ray to use to pick meshes
  90562. * @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
  90563. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  90564. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90565. * @returns a PickingInfo
  90566. */
  90567. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  90568. /**
  90569. * Launch a ray to try to pick a mesh in the scene
  90570. * @param x X position on screen
  90571. * @param y Y position on screen
  90572. * @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
  90573. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  90574. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90575. * @returns an array of PickingInfo
  90576. */
  90577. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  90578. /**
  90579. * Launch a ray to try to pick a mesh in the scene
  90580. * @param ray Ray to use
  90581. * @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
  90582. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90583. * @returns an array of PickingInfo
  90584. */
  90585. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  90586. /**
  90587. * Force the value of meshUnderPointer
  90588. * @param mesh defines the mesh to use
  90589. */
  90590. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  90591. /**
  90592. * Gets the mesh under the pointer
  90593. * @returns a Mesh or null if no mesh is under the pointer
  90594. */
  90595. getPointerOverMesh(): Nullable<AbstractMesh>;
  90596. /** @hidden */
  90597. _rebuildGeometries(): void;
  90598. /** @hidden */
  90599. _rebuildTextures(): void;
  90600. private _getByTags;
  90601. /**
  90602. * Get a list of meshes by tags
  90603. * @param tagsQuery defines the tags query to use
  90604. * @param forEach defines a predicate used to filter results
  90605. * @returns an array of Mesh
  90606. */
  90607. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  90608. /**
  90609. * Get a list of cameras by tags
  90610. * @param tagsQuery defines the tags query to use
  90611. * @param forEach defines a predicate used to filter results
  90612. * @returns an array of Camera
  90613. */
  90614. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  90615. /**
  90616. * Get a list of lights by tags
  90617. * @param tagsQuery defines the tags query to use
  90618. * @param forEach defines a predicate used to filter results
  90619. * @returns an array of Light
  90620. */
  90621. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  90622. /**
  90623. * Get a list of materials by tags
  90624. * @param tagsQuery defines the tags query to use
  90625. * @param forEach defines a predicate used to filter results
  90626. * @returns an array of Material
  90627. */
  90628. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  90629. /**
  90630. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  90631. * This allowed control for front to back rendering or reversly depending of the special needs.
  90632. *
  90633. * @param renderingGroupId The rendering group id corresponding to its index
  90634. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  90635. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  90636. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  90637. */
  90638. 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;
  90639. /**
  90640. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  90641. *
  90642. * @param renderingGroupId The rendering group id corresponding to its index
  90643. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  90644. * @param depth Automatically clears depth between groups if true and autoClear is true.
  90645. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  90646. */
  90647. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  90648. /**
  90649. * Gets the current auto clear configuration for one rendering group of the rendering
  90650. * manager.
  90651. * @param index the rendering group index to get the information for
  90652. * @returns The auto clear setup for the requested rendering group
  90653. */
  90654. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  90655. private _blockMaterialDirtyMechanism;
  90656. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  90657. blockMaterialDirtyMechanism: boolean;
  90658. /**
  90659. * Will flag all materials as dirty to trigger new shader compilation
  90660. * @param flag defines the flag used to specify which material part must be marked as dirty
  90661. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  90662. */
  90663. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  90664. /** @hidden */
  90665. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  90666. /** @hidden */
  90667. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  90668. }
  90669. }
  90670. declare module BABYLON {
  90671. /**
  90672. * Set of assets to keep when moving a scene into an asset container.
  90673. */
  90674. export class KeepAssets extends AbstractScene {
  90675. }
  90676. /**
  90677. * Container with a set of assets that can be added or removed from a scene.
  90678. */
  90679. export class AssetContainer extends AbstractScene {
  90680. /**
  90681. * The scene the AssetContainer belongs to.
  90682. */
  90683. scene: Scene;
  90684. /**
  90685. * Instantiates an AssetContainer.
  90686. * @param scene The scene the AssetContainer belongs to.
  90687. */
  90688. constructor(scene: Scene);
  90689. /**
  90690. * Adds all the assets from the container to the scene.
  90691. */
  90692. addAllToScene(): void;
  90693. /**
  90694. * Removes all the assets in the container from the scene
  90695. */
  90696. removeAllFromScene(): void;
  90697. /**
  90698. * Disposes all the assets in the container
  90699. */
  90700. dispose(): void;
  90701. private _moveAssets;
  90702. /**
  90703. * Removes all the assets contained in the scene and adds them to the container.
  90704. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  90705. */
  90706. moveAllFromScene(keepAssets?: KeepAssets): void;
  90707. /**
  90708. * 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.
  90709. * @returns the root mesh
  90710. */
  90711. createRootMesh(): Mesh;
  90712. }
  90713. }
  90714. declare module BABYLON {
  90715. /**
  90716. * Defines how the parser contract is defined.
  90717. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  90718. */
  90719. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  90720. /**
  90721. * Defines how the individual parser contract is defined.
  90722. * These parser can parse an individual asset
  90723. */
  90724. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  90725. /**
  90726. * Base class of the scene acting as a container for the different elements composing a scene.
  90727. * This class is dynamically extended by the different components of the scene increasing
  90728. * flexibility and reducing coupling
  90729. */
  90730. export abstract class AbstractScene {
  90731. /**
  90732. * Stores the list of available parsers in the application.
  90733. */
  90734. private static _BabylonFileParsers;
  90735. /**
  90736. * Stores the list of available individual parsers in the application.
  90737. */
  90738. private static _IndividualBabylonFileParsers;
  90739. /**
  90740. * Adds a parser in the list of available ones
  90741. * @param name Defines the name of the parser
  90742. * @param parser Defines the parser to add
  90743. */
  90744. static AddParser(name: string, parser: BabylonFileParser): void;
  90745. /**
  90746. * Gets a general parser from the list of avaialble ones
  90747. * @param name Defines the name of the parser
  90748. * @returns the requested parser or null
  90749. */
  90750. static GetParser(name: string): Nullable<BabylonFileParser>;
  90751. /**
  90752. * Adds n individual parser in the list of available ones
  90753. * @param name Defines the name of the parser
  90754. * @param parser Defines the parser to add
  90755. */
  90756. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  90757. /**
  90758. * Gets an individual parser from the list of avaialble ones
  90759. * @param name Defines the name of the parser
  90760. * @returns the requested parser or null
  90761. */
  90762. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  90763. /**
  90764. * Parser json data and populate both a scene and its associated container object
  90765. * @param jsonData Defines the data to parse
  90766. * @param scene Defines the scene to parse the data for
  90767. * @param container Defines the container attached to the parsing sequence
  90768. * @param rootUrl Defines the root url of the data
  90769. */
  90770. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  90771. /**
  90772. * Gets the list of root nodes (ie. nodes with no parent)
  90773. */
  90774. rootNodes: Node[];
  90775. /** All of the cameras added to this scene
  90776. * @see http://doc.babylonjs.com/babylon101/cameras
  90777. */
  90778. cameras: Camera[];
  90779. /**
  90780. * All of the lights added to this scene
  90781. * @see http://doc.babylonjs.com/babylon101/lights
  90782. */
  90783. lights: Light[];
  90784. /**
  90785. * All of the (abstract) meshes added to this scene
  90786. */
  90787. meshes: AbstractMesh[];
  90788. /**
  90789. * The list of skeletons added to the scene
  90790. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  90791. */
  90792. skeletons: Skeleton[];
  90793. /**
  90794. * All of the particle systems added to this scene
  90795. * @see http://doc.babylonjs.com/babylon101/particles
  90796. */
  90797. particleSystems: IParticleSystem[];
  90798. /**
  90799. * Gets a list of Animations associated with the scene
  90800. */
  90801. animations: Animation[];
  90802. /**
  90803. * All of the animation groups added to this scene
  90804. * @see http://doc.babylonjs.com/how_to/group
  90805. */
  90806. animationGroups: AnimationGroup[];
  90807. /**
  90808. * All of the multi-materials added to this scene
  90809. * @see http://doc.babylonjs.com/how_to/multi_materials
  90810. */
  90811. multiMaterials: MultiMaterial[];
  90812. /**
  90813. * All of the materials added to this scene
  90814. * In the context of a Scene, it is not supposed to be modified manually.
  90815. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  90816. * Note also that the order of the Material wihin the array is not significant and might change.
  90817. * @see http://doc.babylonjs.com/babylon101/materials
  90818. */
  90819. materials: Material[];
  90820. /**
  90821. * The list of morph target managers added to the scene
  90822. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  90823. */
  90824. morphTargetManagers: MorphTargetManager[];
  90825. /**
  90826. * The list of geometries used in the scene.
  90827. */
  90828. geometries: Geometry[];
  90829. /**
  90830. * All of the tranform nodes added to this scene
  90831. * In the context of a Scene, it is not supposed to be modified manually.
  90832. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  90833. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  90834. * @see http://doc.babylonjs.com/how_to/transformnode
  90835. */
  90836. transformNodes: TransformNode[];
  90837. /**
  90838. * ActionManagers available on the scene.
  90839. */
  90840. actionManagers: AbstractActionManager[];
  90841. /**
  90842. * Textures to keep.
  90843. */
  90844. textures: BaseTexture[];
  90845. }
  90846. }
  90847. declare module BABYLON {
  90848. /**
  90849. * Defines a sound that can be played in the application.
  90850. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  90851. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90852. */
  90853. export class Sound {
  90854. /**
  90855. * The name of the sound in the scene.
  90856. */
  90857. name: string;
  90858. /**
  90859. * Does the sound autoplay once loaded.
  90860. */
  90861. autoplay: boolean;
  90862. /**
  90863. * Does the sound loop after it finishes playing once.
  90864. */
  90865. loop: boolean;
  90866. /**
  90867. * Does the sound use a custom attenuation curve to simulate the falloff
  90868. * happening when the source gets further away from the camera.
  90869. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  90870. */
  90871. useCustomAttenuation: boolean;
  90872. /**
  90873. * The sound track id this sound belongs to.
  90874. */
  90875. soundTrackId: number;
  90876. /**
  90877. * Is this sound currently played.
  90878. */
  90879. isPlaying: boolean;
  90880. /**
  90881. * Is this sound currently paused.
  90882. */
  90883. isPaused: boolean;
  90884. /**
  90885. * Does this sound enables spatial sound.
  90886. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90887. */
  90888. spatialSound: boolean;
  90889. /**
  90890. * Define the reference distance the sound should be heard perfectly.
  90891. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90892. */
  90893. refDistance: number;
  90894. /**
  90895. * Define the roll off factor of spatial sounds.
  90896. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90897. */
  90898. rolloffFactor: number;
  90899. /**
  90900. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  90901. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90902. */
  90903. maxDistance: number;
  90904. /**
  90905. * Define the distance attenuation model the sound will follow.
  90906. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90907. */
  90908. distanceModel: string;
  90909. /**
  90910. * @hidden
  90911. * Back Compat
  90912. **/
  90913. onended: () => any;
  90914. /**
  90915. * Observable event when the current playing sound finishes.
  90916. */
  90917. onEndedObservable: Observable<Sound>;
  90918. private _panningModel;
  90919. private _playbackRate;
  90920. private _streaming;
  90921. private _startTime;
  90922. private _startOffset;
  90923. private _position;
  90924. /** @hidden */
  90925. _positionInEmitterSpace: boolean;
  90926. private _localDirection;
  90927. private _volume;
  90928. private _isReadyToPlay;
  90929. private _isDirectional;
  90930. private _readyToPlayCallback;
  90931. private _audioBuffer;
  90932. private _soundSource;
  90933. private _streamingSource;
  90934. private _soundPanner;
  90935. private _soundGain;
  90936. private _inputAudioNode;
  90937. private _outputAudioNode;
  90938. private _coneInnerAngle;
  90939. private _coneOuterAngle;
  90940. private _coneOuterGain;
  90941. private _scene;
  90942. private _connectedTransformNode;
  90943. private _customAttenuationFunction;
  90944. private _registerFunc;
  90945. private _isOutputConnected;
  90946. private _htmlAudioElement;
  90947. private _urlType;
  90948. /** @hidden */
  90949. static _SceneComponentInitialization: (scene: Scene) => void;
  90950. /**
  90951. * Create a sound and attach it to a scene
  90952. * @param name Name of your sound
  90953. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  90954. * @param scene defines the scene the sound belongs to
  90955. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  90956. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  90957. */
  90958. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  90959. /**
  90960. * Release the sound and its associated resources
  90961. */
  90962. dispose(): void;
  90963. /**
  90964. * Gets if the sounds is ready to be played or not.
  90965. * @returns true if ready, otherwise false
  90966. */
  90967. isReady(): boolean;
  90968. private _soundLoaded;
  90969. /**
  90970. * Sets the data of the sound from an audiobuffer
  90971. * @param audioBuffer The audioBuffer containing the data
  90972. */
  90973. setAudioBuffer(audioBuffer: AudioBuffer): void;
  90974. /**
  90975. * Updates the current sounds options such as maxdistance, loop...
  90976. * @param options A JSON object containing values named as the object properties
  90977. */
  90978. updateOptions(options: any): void;
  90979. private _createSpatialParameters;
  90980. private _updateSpatialParameters;
  90981. /**
  90982. * Switch the panning model to HRTF:
  90983. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  90984. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90985. */
  90986. switchPanningModelToHRTF(): void;
  90987. /**
  90988. * Switch the panning model to Equal Power:
  90989. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  90990. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90991. */
  90992. switchPanningModelToEqualPower(): void;
  90993. private _switchPanningModel;
  90994. /**
  90995. * Connect this sound to a sound track audio node like gain...
  90996. * @param soundTrackAudioNode the sound track audio node to connect to
  90997. */
  90998. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  90999. /**
  91000. * Transform this sound into a directional source
  91001. * @param coneInnerAngle Size of the inner cone in degree
  91002. * @param coneOuterAngle Size of the outer cone in degree
  91003. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  91004. */
  91005. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  91006. /**
  91007. * Gets or sets the inner angle for the directional cone.
  91008. */
  91009. /**
  91010. * Gets or sets the inner angle for the directional cone.
  91011. */
  91012. directionalConeInnerAngle: number;
  91013. /**
  91014. * Gets or sets the outer angle for the directional cone.
  91015. */
  91016. /**
  91017. * Gets or sets the outer angle for the directional cone.
  91018. */
  91019. directionalConeOuterAngle: number;
  91020. /**
  91021. * Sets the position of the emitter if spatial sound is enabled
  91022. * @param newPosition Defines the new posisiton
  91023. */
  91024. setPosition(newPosition: Vector3): void;
  91025. /**
  91026. * Sets the local direction of the emitter if spatial sound is enabled
  91027. * @param newLocalDirection Defines the new local direction
  91028. */
  91029. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  91030. private _updateDirection;
  91031. /** @hidden */
  91032. updateDistanceFromListener(): void;
  91033. /**
  91034. * Sets a new custom attenuation function for the sound.
  91035. * @param callback Defines the function used for the attenuation
  91036. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  91037. */
  91038. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  91039. /**
  91040. * Play the sound
  91041. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  91042. * @param offset (optional) Start the sound setting it at a specific time
  91043. */
  91044. play(time?: number, offset?: number): void;
  91045. private _onended;
  91046. /**
  91047. * Stop the sound
  91048. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  91049. */
  91050. stop(time?: number): void;
  91051. /**
  91052. * Put the sound in pause
  91053. */
  91054. pause(): void;
  91055. /**
  91056. * Sets a dedicated volume for this sounds
  91057. * @param newVolume Define the new volume of the sound
  91058. * @param time Define in how long the sound should be at this value
  91059. */
  91060. setVolume(newVolume: number, time?: number): void;
  91061. /**
  91062. * Set the sound play back rate
  91063. * @param newPlaybackRate Define the playback rate the sound should be played at
  91064. */
  91065. setPlaybackRate(newPlaybackRate: number): void;
  91066. /**
  91067. * Gets the volume of the sound.
  91068. * @returns the volume of the sound
  91069. */
  91070. getVolume(): number;
  91071. /**
  91072. * Attach the sound to a dedicated mesh
  91073. * @param transformNode The transform node to connect the sound with
  91074. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  91075. */
  91076. attachToMesh(transformNode: TransformNode): void;
  91077. /**
  91078. * Detach the sound from the previously attached mesh
  91079. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  91080. */
  91081. detachFromMesh(): void;
  91082. private _onRegisterAfterWorldMatrixUpdate;
  91083. /**
  91084. * Clone the current sound in the scene.
  91085. * @returns the new sound clone
  91086. */
  91087. clone(): Nullable<Sound>;
  91088. /**
  91089. * Gets the current underlying audio buffer containing the data
  91090. * @returns the audio buffer
  91091. */
  91092. getAudioBuffer(): Nullable<AudioBuffer>;
  91093. /**
  91094. * Serializes the Sound in a JSON representation
  91095. * @returns the JSON representation of the sound
  91096. */
  91097. serialize(): any;
  91098. /**
  91099. * Parse a JSON representation of a sound to innstantiate in a given scene
  91100. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  91101. * @param scene Define the scene the new parsed sound should be created in
  91102. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  91103. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  91104. * @returns the newly parsed sound
  91105. */
  91106. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  91107. }
  91108. }
  91109. declare module BABYLON {
  91110. /**
  91111. * This defines an action helpful to play a defined sound on a triggered action.
  91112. */
  91113. export class PlaySoundAction extends Action {
  91114. private _sound;
  91115. /**
  91116. * Instantiate the action
  91117. * @param triggerOptions defines the trigger options
  91118. * @param sound defines the sound to play
  91119. * @param condition defines the trigger related conditions
  91120. */
  91121. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  91122. /** @hidden */
  91123. _prepare(): void;
  91124. /**
  91125. * Execute the action and play the sound.
  91126. */
  91127. execute(): void;
  91128. /**
  91129. * Serializes the actions and its related information.
  91130. * @param parent defines the object to serialize in
  91131. * @returns the serialized object
  91132. */
  91133. serialize(parent: any): any;
  91134. }
  91135. /**
  91136. * This defines an action helpful to stop a defined sound on a triggered action.
  91137. */
  91138. export class StopSoundAction extends Action {
  91139. private _sound;
  91140. /**
  91141. * Instantiate the action
  91142. * @param triggerOptions defines the trigger options
  91143. * @param sound defines the sound to stop
  91144. * @param condition defines the trigger related conditions
  91145. */
  91146. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  91147. /** @hidden */
  91148. _prepare(): void;
  91149. /**
  91150. * Execute the action and stop the sound.
  91151. */
  91152. execute(): void;
  91153. /**
  91154. * Serializes the actions and its related information.
  91155. * @param parent defines the object to serialize in
  91156. * @returns the serialized object
  91157. */
  91158. serialize(parent: any): any;
  91159. }
  91160. }
  91161. declare module BABYLON {
  91162. /**
  91163. * This defines an action responsible to change the value of a property
  91164. * by interpolating between its current value and the newly set one once triggered.
  91165. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91166. */
  91167. export class InterpolateValueAction extends Action {
  91168. /**
  91169. * Defines the path of the property where the value should be interpolated
  91170. */
  91171. propertyPath: string;
  91172. /**
  91173. * Defines the target value at the end of the interpolation.
  91174. */
  91175. value: any;
  91176. /**
  91177. * Defines the time it will take for the property to interpolate to the value.
  91178. */
  91179. duration: number;
  91180. /**
  91181. * Defines if the other scene animations should be stopped when the action has been triggered
  91182. */
  91183. stopOtherAnimations?: boolean;
  91184. /**
  91185. * Defines a callback raised once the interpolation animation has been done.
  91186. */
  91187. onInterpolationDone?: () => void;
  91188. /**
  91189. * Observable triggered once the interpolation animation has been done.
  91190. */
  91191. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  91192. private _target;
  91193. private _effectiveTarget;
  91194. private _property;
  91195. /**
  91196. * Instantiate the action
  91197. * @param triggerOptions defines the trigger options
  91198. * @param target defines the object containing the value to interpolate
  91199. * @param propertyPath defines the path to the property in the target object
  91200. * @param value defines the target value at the end of the interpolation
  91201. * @param duration deines the time it will take for the property to interpolate to the value.
  91202. * @param condition defines the trigger related conditions
  91203. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  91204. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  91205. */
  91206. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  91207. /** @hidden */
  91208. _prepare(): void;
  91209. /**
  91210. * Execute the action starts the value interpolation.
  91211. */
  91212. execute(): void;
  91213. /**
  91214. * Serializes the actions and its related information.
  91215. * @param parent defines the object to serialize in
  91216. * @returns the serialized object
  91217. */
  91218. serialize(parent: any): any;
  91219. }
  91220. }
  91221. declare module BABYLON {
  91222. /**
  91223. * Options allowed during the creation of a sound track.
  91224. */
  91225. export interface ISoundTrackOptions {
  91226. /**
  91227. * The volume the sound track should take during creation
  91228. */
  91229. volume?: number;
  91230. /**
  91231. * Define if the sound track is the main sound track of the scene
  91232. */
  91233. mainTrack?: boolean;
  91234. }
  91235. /**
  91236. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  91237. * It will be also used in a future release to apply effects on a specific track.
  91238. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  91239. */
  91240. export class SoundTrack {
  91241. /**
  91242. * The unique identifier of the sound track in the scene.
  91243. */
  91244. id: number;
  91245. /**
  91246. * The list of sounds included in the sound track.
  91247. */
  91248. soundCollection: Array<Sound>;
  91249. private _outputAudioNode;
  91250. private _scene;
  91251. private _isMainTrack;
  91252. private _connectedAnalyser;
  91253. private _options;
  91254. private _isInitialized;
  91255. /**
  91256. * Creates a new sound track.
  91257. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  91258. * @param scene Define the scene the sound track belongs to
  91259. * @param options
  91260. */
  91261. constructor(scene: Scene, options?: ISoundTrackOptions);
  91262. private _initializeSoundTrackAudioGraph;
  91263. /**
  91264. * Release the sound track and its associated resources
  91265. */
  91266. dispose(): void;
  91267. /**
  91268. * Adds a sound to this sound track
  91269. * @param sound define the cound to add
  91270. * @ignoreNaming
  91271. */
  91272. AddSound(sound: Sound): void;
  91273. /**
  91274. * Removes a sound to this sound track
  91275. * @param sound define the cound to remove
  91276. * @ignoreNaming
  91277. */
  91278. RemoveSound(sound: Sound): void;
  91279. /**
  91280. * Set a global volume for the full sound track.
  91281. * @param newVolume Define the new volume of the sound track
  91282. */
  91283. setVolume(newVolume: number): void;
  91284. /**
  91285. * Switch the panning model to HRTF:
  91286. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  91287. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91288. */
  91289. switchPanningModelToHRTF(): void;
  91290. /**
  91291. * Switch the panning model to Equal Power:
  91292. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  91293. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91294. */
  91295. switchPanningModelToEqualPower(): void;
  91296. /**
  91297. * Connect the sound track to an audio analyser allowing some amazing
  91298. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  91299. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  91300. * @param analyser The analyser to connect to the engine
  91301. */
  91302. connectToAnalyser(analyser: Analyser): void;
  91303. }
  91304. }
  91305. declare module BABYLON {
  91306. interface AbstractScene {
  91307. /**
  91308. * The list of sounds used in the scene.
  91309. */
  91310. sounds: Nullable<Array<Sound>>;
  91311. }
  91312. interface Scene {
  91313. /**
  91314. * @hidden
  91315. * Backing field
  91316. */
  91317. _mainSoundTrack: SoundTrack;
  91318. /**
  91319. * The main sound track played by the scene.
  91320. * It cotains your primary collection of sounds.
  91321. */
  91322. mainSoundTrack: SoundTrack;
  91323. /**
  91324. * The list of sound tracks added to the scene
  91325. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  91326. */
  91327. soundTracks: Nullable<Array<SoundTrack>>;
  91328. /**
  91329. * Gets a sound using a given name
  91330. * @param name defines the name to search for
  91331. * @return the found sound or null if not found at all.
  91332. */
  91333. getSoundByName(name: string): Nullable<Sound>;
  91334. /**
  91335. * Gets or sets if audio support is enabled
  91336. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  91337. */
  91338. audioEnabled: boolean;
  91339. /**
  91340. * Gets or sets if audio will be output to headphones
  91341. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  91342. */
  91343. headphone: boolean;
  91344. }
  91345. /**
  91346. * Defines the sound scene component responsible to manage any sounds
  91347. * in a given scene.
  91348. */
  91349. export class AudioSceneComponent implements ISceneSerializableComponent {
  91350. /**
  91351. * The component name helpfull to identify the component in the list of scene components.
  91352. */
  91353. readonly name: string;
  91354. /**
  91355. * The scene the component belongs to.
  91356. */
  91357. scene: Scene;
  91358. private _audioEnabled;
  91359. /**
  91360. * Gets whether audio is enabled or not.
  91361. * Please use related enable/disable method to switch state.
  91362. */
  91363. readonly audioEnabled: boolean;
  91364. private _headphone;
  91365. /**
  91366. * Gets whether audio is outputing to headphone or not.
  91367. * Please use the according Switch methods to change output.
  91368. */
  91369. readonly headphone: boolean;
  91370. /**
  91371. * Creates a new instance of the component for the given scene
  91372. * @param scene Defines the scene to register the component in
  91373. */
  91374. constructor(scene: Scene);
  91375. /**
  91376. * Registers the component in a given scene
  91377. */
  91378. register(): void;
  91379. /**
  91380. * Rebuilds the elements related to this component in case of
  91381. * context lost for instance.
  91382. */
  91383. rebuild(): void;
  91384. /**
  91385. * Serializes the component data to the specified json object
  91386. * @param serializationObject The object to serialize to
  91387. */
  91388. serialize(serializationObject: any): void;
  91389. /**
  91390. * Adds all the element from the container to the scene
  91391. * @param container the container holding the elements
  91392. */
  91393. addFromContainer(container: AbstractScene): void;
  91394. /**
  91395. * Removes all the elements in the container from the scene
  91396. * @param container contains the elements to remove
  91397. */
  91398. removeFromContainer(container: AbstractScene): void;
  91399. /**
  91400. * Disposes the component and the associated ressources.
  91401. */
  91402. dispose(): void;
  91403. /**
  91404. * Disables audio in the associated scene.
  91405. */
  91406. disableAudio(): void;
  91407. /**
  91408. * Enables audio in the associated scene.
  91409. */
  91410. enableAudio(): void;
  91411. /**
  91412. * Switch audio to headphone output.
  91413. */
  91414. switchAudioModeForHeadphones(): void;
  91415. /**
  91416. * Switch audio to normal speakers.
  91417. */
  91418. switchAudioModeForNormalSpeakers(): void;
  91419. private _afterRender;
  91420. }
  91421. }
  91422. declare module BABYLON {
  91423. /**
  91424. * Wraps one or more Sound objects and selects one with random weight for playback.
  91425. */
  91426. export class WeightedSound {
  91427. /** When true a Sound will be selected and played when the current playing Sound completes. */
  91428. loop: boolean;
  91429. private _coneInnerAngle;
  91430. private _coneOuterAngle;
  91431. private _volume;
  91432. /** A Sound is currently playing. */
  91433. isPlaying: boolean;
  91434. /** A Sound is currently paused. */
  91435. isPaused: boolean;
  91436. private _sounds;
  91437. private _weights;
  91438. private _currentIndex?;
  91439. /**
  91440. * Creates a new WeightedSound from the list of sounds given.
  91441. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  91442. * @param sounds Array of Sounds that will be selected from.
  91443. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  91444. */
  91445. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  91446. /**
  91447. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  91448. */
  91449. /**
  91450. * The size of cone in degress for a directional sound in which there will be no attenuation.
  91451. */
  91452. directionalConeInnerAngle: number;
  91453. /**
  91454. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  91455. * Listener angles between innerAngle and outerAngle will falloff linearly.
  91456. */
  91457. /**
  91458. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  91459. * Listener angles between innerAngle and outerAngle will falloff linearly.
  91460. */
  91461. directionalConeOuterAngle: number;
  91462. /**
  91463. * Playback volume.
  91464. */
  91465. /**
  91466. * Playback volume.
  91467. */
  91468. volume: number;
  91469. private _onended;
  91470. /**
  91471. * Suspend playback
  91472. */
  91473. pause(): void;
  91474. /**
  91475. * Stop playback
  91476. */
  91477. stop(): void;
  91478. /**
  91479. * Start playback.
  91480. * @param startOffset Position the clip head at a specific time in seconds.
  91481. */
  91482. play(startOffset?: number): void;
  91483. }
  91484. }
  91485. declare module BABYLON {
  91486. /**
  91487. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  91488. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  91489. */
  91490. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  91491. /**
  91492. * Gets the name of the behavior.
  91493. */
  91494. readonly name: string;
  91495. /**
  91496. * The easing function used by animations
  91497. */
  91498. static EasingFunction: BackEase;
  91499. /**
  91500. * The easing mode used by animations
  91501. */
  91502. static EasingMode: number;
  91503. /**
  91504. * The duration of the animation, in milliseconds
  91505. */
  91506. transitionDuration: number;
  91507. /**
  91508. * Length of the distance animated by the transition when lower radius is reached
  91509. */
  91510. lowerRadiusTransitionRange: number;
  91511. /**
  91512. * Length of the distance animated by the transition when upper radius is reached
  91513. */
  91514. upperRadiusTransitionRange: number;
  91515. private _autoTransitionRange;
  91516. /**
  91517. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  91518. */
  91519. /**
  91520. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  91521. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  91522. */
  91523. autoTransitionRange: boolean;
  91524. private _attachedCamera;
  91525. private _onAfterCheckInputsObserver;
  91526. private _onMeshTargetChangedObserver;
  91527. /**
  91528. * Initializes the behavior.
  91529. */
  91530. init(): void;
  91531. /**
  91532. * Attaches the behavior to its arc rotate camera.
  91533. * @param camera Defines the camera to attach the behavior to
  91534. */
  91535. attach(camera: ArcRotateCamera): void;
  91536. /**
  91537. * Detaches the behavior from its current arc rotate camera.
  91538. */
  91539. detach(): void;
  91540. private _radiusIsAnimating;
  91541. private _radiusBounceTransition;
  91542. private _animatables;
  91543. private _cachedWheelPrecision;
  91544. /**
  91545. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  91546. * @param radiusLimit The limit to check against.
  91547. * @return Bool to indicate if at limit.
  91548. */
  91549. private _isRadiusAtLimit;
  91550. /**
  91551. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  91552. * @param radiusDelta The delta by which to animate to. Can be negative.
  91553. */
  91554. private _applyBoundRadiusAnimation;
  91555. /**
  91556. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  91557. */
  91558. protected _clearAnimationLocks(): void;
  91559. /**
  91560. * Stops and removes all animations that have been applied to the camera
  91561. */
  91562. stopAllAnimations(): void;
  91563. }
  91564. }
  91565. declare module BABYLON {
  91566. /**
  91567. * 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.
  91568. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  91569. */
  91570. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  91571. /**
  91572. * Gets the name of the behavior.
  91573. */
  91574. readonly name: string;
  91575. private _mode;
  91576. private _radiusScale;
  91577. private _positionScale;
  91578. private _defaultElevation;
  91579. private _elevationReturnTime;
  91580. private _elevationReturnWaitTime;
  91581. private _zoomStopsAnimation;
  91582. private _framingTime;
  91583. /**
  91584. * The easing function used by animations
  91585. */
  91586. static EasingFunction: ExponentialEase;
  91587. /**
  91588. * The easing mode used by animations
  91589. */
  91590. static EasingMode: number;
  91591. /**
  91592. * Sets the current mode used by the behavior
  91593. */
  91594. /**
  91595. * Gets current mode used by the behavior.
  91596. */
  91597. mode: number;
  91598. /**
  91599. * Sets the scale applied to the radius (1 by default)
  91600. */
  91601. /**
  91602. * Gets the scale applied to the radius
  91603. */
  91604. radiusScale: number;
  91605. /**
  91606. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  91607. */
  91608. /**
  91609. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  91610. */
  91611. positionScale: number;
  91612. /**
  91613. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  91614. * behaviour is triggered, in radians.
  91615. */
  91616. /**
  91617. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  91618. * behaviour is triggered, in radians.
  91619. */
  91620. defaultElevation: number;
  91621. /**
  91622. * Sets the time (in milliseconds) taken to return to the default beta position.
  91623. * Negative value indicates camera should not return to default.
  91624. */
  91625. /**
  91626. * Gets the time (in milliseconds) taken to return to the default beta position.
  91627. * Negative value indicates camera should not return to default.
  91628. */
  91629. elevationReturnTime: number;
  91630. /**
  91631. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  91632. */
  91633. /**
  91634. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  91635. */
  91636. elevationReturnWaitTime: number;
  91637. /**
  91638. * Sets the flag that indicates if user zooming should stop animation.
  91639. */
  91640. /**
  91641. * Gets the flag that indicates if user zooming should stop animation.
  91642. */
  91643. zoomStopsAnimation: boolean;
  91644. /**
  91645. * Sets the transition time when framing the mesh, in milliseconds
  91646. */
  91647. /**
  91648. * Gets the transition time when framing the mesh, in milliseconds
  91649. */
  91650. framingTime: number;
  91651. /**
  91652. * Define if the behavior should automatically change the configured
  91653. * camera limits and sensibilities.
  91654. */
  91655. autoCorrectCameraLimitsAndSensibility: boolean;
  91656. private _onPrePointerObservableObserver;
  91657. private _onAfterCheckInputsObserver;
  91658. private _onMeshTargetChangedObserver;
  91659. private _attachedCamera;
  91660. private _isPointerDown;
  91661. private _lastInteractionTime;
  91662. /**
  91663. * Initializes the behavior.
  91664. */
  91665. init(): void;
  91666. /**
  91667. * Attaches the behavior to its arc rotate camera.
  91668. * @param camera Defines the camera to attach the behavior to
  91669. */
  91670. attach(camera: ArcRotateCamera): void;
  91671. /**
  91672. * Detaches the behavior from its current arc rotate camera.
  91673. */
  91674. detach(): void;
  91675. private _animatables;
  91676. private _betaIsAnimating;
  91677. private _betaTransition;
  91678. private _radiusTransition;
  91679. private _vectorTransition;
  91680. /**
  91681. * Targets the given mesh and updates zoom level accordingly.
  91682. * @param mesh The mesh to target.
  91683. * @param radius Optional. If a cached radius position already exists, overrides default.
  91684. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  91685. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91686. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91687. */
  91688. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91689. /**
  91690. * Targets the given mesh with its children and updates zoom level accordingly.
  91691. * @param mesh The mesh to target.
  91692. * @param radius Optional. If a cached radius position already exists, overrides default.
  91693. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  91694. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91695. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91696. */
  91697. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91698. /**
  91699. * Targets the given meshes with their children and updates zoom level accordingly.
  91700. * @param meshes The mesh to target.
  91701. * @param radius Optional. If a cached radius position already exists, overrides default.
  91702. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  91703. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91704. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91705. */
  91706. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91707. /**
  91708. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  91709. * @param minimumWorld Determines the smaller position of the bounding box extend
  91710. * @param maximumWorld Determines the bigger position of the bounding box extend
  91711. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91712. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91713. */
  91714. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91715. /**
  91716. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  91717. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  91718. * frustum width.
  91719. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  91720. * to fully enclose the mesh in the viewing frustum.
  91721. */
  91722. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  91723. /**
  91724. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  91725. * is automatically returned to its default position (expected to be above ground plane).
  91726. */
  91727. private _maintainCameraAboveGround;
  91728. /**
  91729. * Returns the frustum slope based on the canvas ratio and camera FOV
  91730. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  91731. */
  91732. private _getFrustumSlope;
  91733. /**
  91734. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  91735. */
  91736. private _clearAnimationLocks;
  91737. /**
  91738. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  91739. */
  91740. private _applyUserInteraction;
  91741. /**
  91742. * Stops and removes all animations that have been applied to the camera
  91743. */
  91744. stopAllAnimations(): void;
  91745. /**
  91746. * Gets a value indicating if the user is moving the camera
  91747. */
  91748. readonly isUserIsMoving: boolean;
  91749. /**
  91750. * The camera can move all the way towards the mesh.
  91751. */
  91752. static IgnoreBoundsSizeMode: number;
  91753. /**
  91754. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  91755. */
  91756. static FitFrustumSidesMode: number;
  91757. }
  91758. }
  91759. declare module BABYLON {
  91760. /**
  91761. * Base class for Camera Pointer Inputs.
  91762. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  91763. * for example usage.
  91764. */
  91765. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  91766. /**
  91767. * Defines the camera the input is attached to.
  91768. */
  91769. abstract camera: Camera;
  91770. /**
  91771. * Whether keyboard modifier keys are pressed at time of last mouse event.
  91772. */
  91773. protected _altKey: boolean;
  91774. protected _ctrlKey: boolean;
  91775. protected _metaKey: boolean;
  91776. protected _shiftKey: boolean;
  91777. /**
  91778. * Which mouse buttons were pressed at time of last mouse event.
  91779. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  91780. */
  91781. protected _buttonsPressed: number;
  91782. /**
  91783. * Defines the buttons associated with the input to handle camera move.
  91784. */
  91785. buttons: number[];
  91786. /**
  91787. * Attach the input controls to a specific dom element to get the input from.
  91788. * @param element Defines the element the controls should be listened from
  91789. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91790. */
  91791. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91792. /**
  91793. * Detach the current controls from the specified dom element.
  91794. * @param element Defines the element to stop listening the inputs from
  91795. */
  91796. detachControl(element: Nullable<HTMLElement>): void;
  91797. /**
  91798. * Gets the class name of the current input.
  91799. * @returns the class name
  91800. */
  91801. getClassName(): string;
  91802. /**
  91803. * Get the friendly name associated with the input class.
  91804. * @returns the input friendly name
  91805. */
  91806. getSimpleName(): string;
  91807. /**
  91808. * Called on pointer POINTERDOUBLETAP event.
  91809. * Override this method to provide functionality on POINTERDOUBLETAP event.
  91810. */
  91811. protected onDoubleTap(type: string): void;
  91812. /**
  91813. * Called on pointer POINTERMOVE event if only a single touch is active.
  91814. * Override this method to provide functionality.
  91815. */
  91816. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  91817. /**
  91818. * Called on pointer POINTERMOVE event if multiple touches are active.
  91819. * Override this method to provide functionality.
  91820. */
  91821. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  91822. /**
  91823. * Called on JS contextmenu event.
  91824. * Override this method to provide functionality.
  91825. */
  91826. protected onContextMenu(evt: PointerEvent): void;
  91827. /**
  91828. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  91829. * press.
  91830. * Override this method to provide functionality.
  91831. */
  91832. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  91833. /**
  91834. * Called each time a new POINTERUP event occurs. Ie, for each button
  91835. * release.
  91836. * Override this method to provide functionality.
  91837. */
  91838. protected onButtonUp(evt: PointerEvent): void;
  91839. /**
  91840. * Called when window becomes inactive.
  91841. * Override this method to provide functionality.
  91842. */
  91843. protected onLostFocus(): void;
  91844. private _pointerInput;
  91845. private _observer;
  91846. private _onLostFocus;
  91847. }
  91848. }
  91849. declare module BABYLON {
  91850. /**
  91851. * Manage the pointers inputs to control an arc rotate camera.
  91852. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91853. */
  91854. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  91855. /**
  91856. * Defines the camera the input is attached to.
  91857. */
  91858. camera: ArcRotateCamera;
  91859. /**
  91860. * Gets the class name of the current input.
  91861. * @returns the class name
  91862. */
  91863. getClassName(): string;
  91864. /**
  91865. * Defines the buttons associated with the input to handle camera move.
  91866. */
  91867. buttons: number[];
  91868. /**
  91869. * Defines the pointer angular sensibility along the X axis or how fast is
  91870. * the camera rotating.
  91871. */
  91872. angularSensibilityX: number;
  91873. /**
  91874. * Defines the pointer angular sensibility along the Y axis or how fast is
  91875. * the camera rotating.
  91876. */
  91877. angularSensibilityY: number;
  91878. /**
  91879. * Defines the pointer pinch precision or how fast is the camera zooming.
  91880. */
  91881. pinchPrecision: number;
  91882. /**
  91883. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  91884. * from 0.
  91885. * It defines the percentage of current camera.radius to use as delta when
  91886. * pinch zoom is used.
  91887. */
  91888. pinchDeltaPercentage: number;
  91889. /**
  91890. * Defines the pointer panning sensibility or how fast is the camera moving.
  91891. */
  91892. panningSensibility: number;
  91893. /**
  91894. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  91895. */
  91896. multiTouchPanning: boolean;
  91897. /**
  91898. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  91899. * zoom (pinch) through multitouch.
  91900. */
  91901. multiTouchPanAndZoom: boolean;
  91902. /**
  91903. * Revers pinch action direction.
  91904. */
  91905. pinchInwards: boolean;
  91906. private _isPanClick;
  91907. private _twoFingerActivityCount;
  91908. private _isPinching;
  91909. /**
  91910. * Called on pointer POINTERMOVE event if only a single touch is active.
  91911. */
  91912. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  91913. /**
  91914. * Called on pointer POINTERDOUBLETAP event.
  91915. */
  91916. protected onDoubleTap(type: string): void;
  91917. /**
  91918. * Called on pointer POINTERMOVE event if multiple touches are active.
  91919. */
  91920. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  91921. /**
  91922. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  91923. * press.
  91924. */
  91925. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  91926. /**
  91927. * Called each time a new POINTERUP event occurs. Ie, for each button
  91928. * release.
  91929. */
  91930. protected onButtonUp(evt: PointerEvent): void;
  91931. /**
  91932. * Called when window becomes inactive.
  91933. */
  91934. protected onLostFocus(): void;
  91935. }
  91936. }
  91937. declare module BABYLON {
  91938. /**
  91939. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  91940. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91941. */
  91942. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  91943. /**
  91944. * Defines the camera the input is attached to.
  91945. */
  91946. camera: ArcRotateCamera;
  91947. /**
  91948. * Defines the list of key codes associated with the up action (increase alpha)
  91949. */
  91950. keysUp: number[];
  91951. /**
  91952. * Defines the list of key codes associated with the down action (decrease alpha)
  91953. */
  91954. keysDown: number[];
  91955. /**
  91956. * Defines the list of key codes associated with the left action (increase beta)
  91957. */
  91958. keysLeft: number[];
  91959. /**
  91960. * Defines the list of key codes associated with the right action (decrease beta)
  91961. */
  91962. keysRight: number[];
  91963. /**
  91964. * Defines the list of key codes associated with the reset action.
  91965. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  91966. */
  91967. keysReset: number[];
  91968. /**
  91969. * Defines the panning sensibility of the inputs.
  91970. * (How fast is the camera paning)
  91971. */
  91972. panningSensibility: number;
  91973. /**
  91974. * Defines the zooming sensibility of the inputs.
  91975. * (How fast is the camera zooming)
  91976. */
  91977. zoomingSensibility: number;
  91978. /**
  91979. * Defines wether maintaining the alt key down switch the movement mode from
  91980. * orientation to zoom.
  91981. */
  91982. useAltToZoom: boolean;
  91983. /**
  91984. * Rotation speed of the camera
  91985. */
  91986. angularSpeed: number;
  91987. private _keys;
  91988. private _ctrlPressed;
  91989. private _altPressed;
  91990. private _onCanvasBlurObserver;
  91991. private _onKeyboardObserver;
  91992. private _engine;
  91993. private _scene;
  91994. /**
  91995. * Attach the input controls to a specific dom element to get the input from.
  91996. * @param element Defines the element the controls should be listened from
  91997. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91998. */
  91999. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92000. /**
  92001. * Detach the current controls from the specified dom element.
  92002. * @param element Defines the element to stop listening the inputs from
  92003. */
  92004. detachControl(element: Nullable<HTMLElement>): void;
  92005. /**
  92006. * Update the current camera state depending on the inputs that have been used this frame.
  92007. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92008. */
  92009. checkInputs(): void;
  92010. /**
  92011. * Gets the class name of the current intput.
  92012. * @returns the class name
  92013. */
  92014. getClassName(): string;
  92015. /**
  92016. * Get the friendly name associated with the input class.
  92017. * @returns the input friendly name
  92018. */
  92019. getSimpleName(): string;
  92020. }
  92021. }
  92022. declare module BABYLON {
  92023. /**
  92024. * Manage the mouse wheel inputs to control an arc rotate camera.
  92025. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92026. */
  92027. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  92028. /**
  92029. * Defines the camera the input is attached to.
  92030. */
  92031. camera: ArcRotateCamera;
  92032. /**
  92033. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  92034. */
  92035. wheelPrecision: number;
  92036. /**
  92037. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  92038. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  92039. */
  92040. wheelDeltaPercentage: number;
  92041. private _wheel;
  92042. private _observer;
  92043. /**
  92044. * Attach the input controls to a specific dom element to get the input from.
  92045. * @param element Defines the element the controls should be listened from
  92046. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92047. */
  92048. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92049. /**
  92050. * Detach the current controls from the specified dom element.
  92051. * @param element Defines the element to stop listening the inputs from
  92052. */
  92053. detachControl(element: Nullable<HTMLElement>): void;
  92054. /**
  92055. * Gets the class name of the current intput.
  92056. * @returns the class name
  92057. */
  92058. getClassName(): string;
  92059. /**
  92060. * Get the friendly name associated with the input class.
  92061. * @returns the input friendly name
  92062. */
  92063. getSimpleName(): string;
  92064. }
  92065. }
  92066. declare module BABYLON {
  92067. /**
  92068. * Default Inputs manager for the ArcRotateCamera.
  92069. * It groups all the default supported inputs for ease of use.
  92070. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92071. */
  92072. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  92073. /**
  92074. * Instantiates a new ArcRotateCameraInputsManager.
  92075. * @param camera Defines the camera the inputs belong to
  92076. */
  92077. constructor(camera: ArcRotateCamera);
  92078. /**
  92079. * Add mouse wheel input support to the input manager.
  92080. * @returns the current input manager
  92081. */
  92082. addMouseWheel(): ArcRotateCameraInputsManager;
  92083. /**
  92084. * Add pointers input support to the input manager.
  92085. * @returns the current input manager
  92086. */
  92087. addPointers(): ArcRotateCameraInputsManager;
  92088. /**
  92089. * Add keyboard input support to the input manager.
  92090. * @returns the current input manager
  92091. */
  92092. addKeyboard(): ArcRotateCameraInputsManager;
  92093. }
  92094. }
  92095. declare module BABYLON {
  92096. /**
  92097. * This represents an orbital type of camera.
  92098. *
  92099. * 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.
  92100. * 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.
  92101. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  92102. */
  92103. export class ArcRotateCamera extends TargetCamera {
  92104. /**
  92105. * Defines the rotation angle of the camera along the longitudinal axis.
  92106. */
  92107. alpha: number;
  92108. /**
  92109. * Defines the rotation angle of the camera along the latitudinal axis.
  92110. */
  92111. beta: number;
  92112. /**
  92113. * Defines the radius of the camera from it s target point.
  92114. */
  92115. radius: number;
  92116. protected _target: Vector3;
  92117. protected _targetHost: Nullable<AbstractMesh>;
  92118. /**
  92119. * Defines the target point of the camera.
  92120. * The camera looks towards it form the radius distance.
  92121. */
  92122. target: Vector3;
  92123. /**
  92124. * Define the current local position of the camera in the scene
  92125. */
  92126. position: Vector3;
  92127. /**
  92128. * Current inertia value on the longitudinal axis.
  92129. * The bigger this number the longer it will take for the camera to stop.
  92130. */
  92131. inertialAlphaOffset: number;
  92132. /**
  92133. * Current inertia value on the latitudinal axis.
  92134. * The bigger this number the longer it will take for the camera to stop.
  92135. */
  92136. inertialBetaOffset: number;
  92137. /**
  92138. * Current inertia value on the radius axis.
  92139. * The bigger this number the longer it will take for the camera to stop.
  92140. */
  92141. inertialRadiusOffset: number;
  92142. /**
  92143. * Minimum allowed angle on the longitudinal axis.
  92144. * This can help limiting how the Camera is able to move in the scene.
  92145. */
  92146. lowerAlphaLimit: Nullable<number>;
  92147. /**
  92148. * Maximum allowed angle on the longitudinal axis.
  92149. * This can help limiting how the Camera is able to move in the scene.
  92150. */
  92151. upperAlphaLimit: Nullable<number>;
  92152. /**
  92153. * Minimum allowed angle on the latitudinal axis.
  92154. * This can help limiting how the Camera is able to move in the scene.
  92155. */
  92156. lowerBetaLimit: number;
  92157. /**
  92158. * Maximum allowed angle on the latitudinal axis.
  92159. * This can help limiting how the Camera is able to move in the scene.
  92160. */
  92161. upperBetaLimit: number;
  92162. /**
  92163. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  92164. * This can help limiting how the Camera is able to move in the scene.
  92165. */
  92166. lowerRadiusLimit: Nullable<number>;
  92167. /**
  92168. * Maximum allowed distance of the camera to the target (The camera can not get further).
  92169. * This can help limiting how the Camera is able to move in the scene.
  92170. */
  92171. upperRadiusLimit: Nullable<number>;
  92172. /**
  92173. * Defines the current inertia value used during panning of the camera along the X axis.
  92174. */
  92175. inertialPanningX: number;
  92176. /**
  92177. * Defines the current inertia value used during panning of the camera along the Y axis.
  92178. */
  92179. inertialPanningY: number;
  92180. /**
  92181. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  92182. * Basically if your fingers moves away from more than this distance you will be considered
  92183. * in pinch mode.
  92184. */
  92185. pinchToPanMaxDistance: number;
  92186. /**
  92187. * Defines the maximum distance the camera can pan.
  92188. * This could help keeping the cammera always in your scene.
  92189. */
  92190. panningDistanceLimit: Nullable<number>;
  92191. /**
  92192. * Defines the target of the camera before paning.
  92193. */
  92194. panningOriginTarget: Vector3;
  92195. /**
  92196. * Defines the value of the inertia used during panning.
  92197. * 0 would mean stop inertia and one would mean no decelleration at all.
  92198. */
  92199. panningInertia: number;
  92200. /**
  92201. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  92202. */
  92203. angularSensibilityX: number;
  92204. /**
  92205. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  92206. */
  92207. angularSensibilityY: number;
  92208. /**
  92209. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  92210. */
  92211. pinchPrecision: number;
  92212. /**
  92213. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  92214. * It will be used instead of pinchDeltaPrecision if different from 0.
  92215. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  92216. */
  92217. pinchDeltaPercentage: number;
  92218. /**
  92219. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  92220. */
  92221. panningSensibility: number;
  92222. /**
  92223. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  92224. */
  92225. keysUp: number[];
  92226. /**
  92227. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  92228. */
  92229. keysDown: number[];
  92230. /**
  92231. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  92232. */
  92233. keysLeft: number[];
  92234. /**
  92235. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  92236. */
  92237. keysRight: number[];
  92238. /**
  92239. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  92240. */
  92241. wheelPrecision: number;
  92242. /**
  92243. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  92244. * It will be used instead of pinchDeltaPrecision if different from 0.
  92245. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  92246. */
  92247. wheelDeltaPercentage: number;
  92248. /**
  92249. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  92250. */
  92251. zoomOnFactor: number;
  92252. /**
  92253. * Defines a screen offset for the camera position.
  92254. */
  92255. targetScreenOffset: Vector2;
  92256. /**
  92257. * Allows the camera to be completely reversed.
  92258. * If false the camera can not arrive upside down.
  92259. */
  92260. allowUpsideDown: boolean;
  92261. /**
  92262. * Define if double tap/click is used to restore the previously saved state of the camera.
  92263. */
  92264. useInputToRestoreState: boolean;
  92265. /** @hidden */
  92266. _viewMatrix: Matrix;
  92267. /** @hidden */
  92268. _useCtrlForPanning: boolean;
  92269. /** @hidden */
  92270. _panningMouseButton: number;
  92271. /**
  92272. * Defines the input associated to the camera.
  92273. */
  92274. inputs: ArcRotateCameraInputsManager;
  92275. /** @hidden */
  92276. _reset: () => void;
  92277. /**
  92278. * Defines the allowed panning axis.
  92279. */
  92280. panningAxis: Vector3;
  92281. protected _localDirection: Vector3;
  92282. protected _transformedDirection: Vector3;
  92283. private _bouncingBehavior;
  92284. /**
  92285. * Gets the bouncing behavior of the camera if it has been enabled.
  92286. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  92287. */
  92288. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  92289. /**
  92290. * Defines if the bouncing behavior of the camera is enabled on the camera.
  92291. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  92292. */
  92293. useBouncingBehavior: boolean;
  92294. private _framingBehavior;
  92295. /**
  92296. * Gets the framing behavior of the camera if it has been enabled.
  92297. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  92298. */
  92299. readonly framingBehavior: Nullable<FramingBehavior>;
  92300. /**
  92301. * Defines if the framing behavior of the camera is enabled on the camera.
  92302. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  92303. */
  92304. useFramingBehavior: boolean;
  92305. private _autoRotationBehavior;
  92306. /**
  92307. * Gets the auto rotation behavior of the camera if it has been enabled.
  92308. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  92309. */
  92310. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  92311. /**
  92312. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  92313. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  92314. */
  92315. useAutoRotationBehavior: boolean;
  92316. /**
  92317. * Observable triggered when the mesh target has been changed on the camera.
  92318. */
  92319. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  92320. /**
  92321. * Event raised when the camera is colliding with a mesh.
  92322. */
  92323. onCollide: (collidedMesh: AbstractMesh) => void;
  92324. /**
  92325. * Defines whether the camera should check collision with the objects oh the scene.
  92326. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  92327. */
  92328. checkCollisions: boolean;
  92329. /**
  92330. * Defines the collision radius of the camera.
  92331. * This simulates a sphere around the camera.
  92332. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  92333. */
  92334. collisionRadius: Vector3;
  92335. protected _collider: Collider;
  92336. protected _previousPosition: Vector3;
  92337. protected _collisionVelocity: Vector3;
  92338. protected _newPosition: Vector3;
  92339. protected _previousAlpha: number;
  92340. protected _previousBeta: number;
  92341. protected _previousRadius: number;
  92342. protected _collisionTriggered: boolean;
  92343. protected _targetBoundingCenter: Nullable<Vector3>;
  92344. private _computationVector;
  92345. private _tempAxisVector;
  92346. private _tempAxisRotationMatrix;
  92347. /**
  92348. * Instantiates a new ArcRotateCamera in a given scene
  92349. * @param name Defines the name of the camera
  92350. * @param alpha Defines the camera rotation along the logitudinal axis
  92351. * @param beta Defines the camera rotation along the latitudinal axis
  92352. * @param radius Defines the camera distance from its target
  92353. * @param target Defines the camera target
  92354. * @param scene Defines the scene the camera belongs to
  92355. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  92356. */
  92357. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  92358. /** @hidden */
  92359. _initCache(): void;
  92360. /** @hidden */
  92361. _updateCache(ignoreParentClass?: boolean): void;
  92362. protected _getTargetPosition(): Vector3;
  92363. private _storedAlpha;
  92364. private _storedBeta;
  92365. private _storedRadius;
  92366. private _storedTarget;
  92367. /**
  92368. * Stores the current state of the camera (alpha, beta, radius and target)
  92369. * @returns the camera itself
  92370. */
  92371. storeState(): Camera;
  92372. /**
  92373. * @hidden
  92374. * Restored camera state. You must call storeState() first
  92375. */
  92376. _restoreStateValues(): boolean;
  92377. /** @hidden */
  92378. _isSynchronizedViewMatrix(): boolean;
  92379. /**
  92380. * Attached controls to the current camera.
  92381. * @param element Defines the element the controls should be listened from
  92382. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92383. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  92384. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  92385. */
  92386. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  92387. /**
  92388. * Detach the current controls from the camera.
  92389. * The camera will stop reacting to inputs.
  92390. * @param element Defines the element to stop listening the inputs from
  92391. */
  92392. detachControl(element: HTMLElement): void;
  92393. /** @hidden */
  92394. _checkInputs(): void;
  92395. protected _checkLimits(): void;
  92396. /**
  92397. * Rebuilds angles (alpha, beta) and radius from the give position and target
  92398. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  92399. */
  92400. rebuildAnglesAndRadius(updateView?: boolean): void;
  92401. /**
  92402. * Use a position to define the current camera related information like aplha, beta and radius
  92403. * @param position Defines the position to set the camera at
  92404. */
  92405. setPosition(position: Vector3): void;
  92406. /**
  92407. * Defines the target the camera should look at.
  92408. * This will automatically adapt alpha beta and radius to fit within the new target.
  92409. * @param target Defines the new target as a Vector or a mesh
  92410. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  92411. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  92412. */
  92413. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  92414. /** @hidden */
  92415. _getViewMatrix(): Matrix;
  92416. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  92417. /**
  92418. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  92419. * @param meshes Defines the mesh to zoom on
  92420. * @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)
  92421. */
  92422. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  92423. /**
  92424. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  92425. * The target will be changed but the radius
  92426. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  92427. * @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)
  92428. */
  92429. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  92430. min: Vector3;
  92431. max: Vector3;
  92432. distance: number;
  92433. }, doNotUpdateMaxZ?: boolean): void;
  92434. /**
  92435. * @override
  92436. * Override Camera.createRigCamera
  92437. */
  92438. createRigCamera(name: string, cameraIndex: number): Camera;
  92439. /**
  92440. * @hidden
  92441. * @override
  92442. * Override Camera._updateRigCameras
  92443. */
  92444. _updateRigCameras(): void;
  92445. /**
  92446. * Destroy the camera and release the current resources hold by it.
  92447. */
  92448. dispose(): void;
  92449. /**
  92450. * Gets the current object class name.
  92451. * @return the class name
  92452. */
  92453. getClassName(): string;
  92454. }
  92455. }
  92456. declare module BABYLON {
  92457. /**
  92458. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  92459. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  92460. */
  92461. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  92462. /**
  92463. * Gets the name of the behavior.
  92464. */
  92465. readonly name: string;
  92466. private _zoomStopsAnimation;
  92467. private _idleRotationSpeed;
  92468. private _idleRotationWaitTime;
  92469. private _idleRotationSpinupTime;
  92470. /**
  92471. * Sets the flag that indicates if user zooming should stop animation.
  92472. */
  92473. /**
  92474. * Gets the flag that indicates if user zooming should stop animation.
  92475. */
  92476. zoomStopsAnimation: boolean;
  92477. /**
  92478. * Sets the default speed at which the camera rotates around the model.
  92479. */
  92480. /**
  92481. * Gets the default speed at which the camera rotates around the model.
  92482. */
  92483. idleRotationSpeed: number;
  92484. /**
  92485. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  92486. */
  92487. /**
  92488. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  92489. */
  92490. idleRotationWaitTime: number;
  92491. /**
  92492. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  92493. */
  92494. /**
  92495. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  92496. */
  92497. idleRotationSpinupTime: number;
  92498. /**
  92499. * Gets a value indicating if the camera is currently rotating because of this behavior
  92500. */
  92501. readonly rotationInProgress: boolean;
  92502. private _onPrePointerObservableObserver;
  92503. private _onAfterCheckInputsObserver;
  92504. private _attachedCamera;
  92505. private _isPointerDown;
  92506. private _lastFrameTime;
  92507. private _lastInteractionTime;
  92508. private _cameraRotationSpeed;
  92509. /**
  92510. * Initializes the behavior.
  92511. */
  92512. init(): void;
  92513. /**
  92514. * Attaches the behavior to its arc rotate camera.
  92515. * @param camera Defines the camera to attach the behavior to
  92516. */
  92517. attach(camera: ArcRotateCamera): void;
  92518. /**
  92519. * Detaches the behavior from its current arc rotate camera.
  92520. */
  92521. detach(): void;
  92522. /**
  92523. * Returns true if user is scrolling.
  92524. * @return true if user is scrolling.
  92525. */
  92526. private _userIsZooming;
  92527. private _lastFrameRadius;
  92528. private _shouldAnimationStopForInteraction;
  92529. /**
  92530. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  92531. */
  92532. private _applyUserInteraction;
  92533. private _userIsMoving;
  92534. }
  92535. }
  92536. declare module BABYLON {
  92537. /**
  92538. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  92539. */
  92540. export class AttachToBoxBehavior implements Behavior<Mesh> {
  92541. private ui;
  92542. /**
  92543. * The name of the behavior
  92544. */
  92545. name: string;
  92546. /**
  92547. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  92548. */
  92549. distanceAwayFromFace: number;
  92550. /**
  92551. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  92552. */
  92553. distanceAwayFromBottomOfFace: number;
  92554. private _faceVectors;
  92555. private _target;
  92556. private _scene;
  92557. private _onRenderObserver;
  92558. private _tmpMatrix;
  92559. private _tmpVector;
  92560. /**
  92561. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  92562. * @param ui The transform node that should be attched to the mesh
  92563. */
  92564. constructor(ui: TransformNode);
  92565. /**
  92566. * Initializes the behavior
  92567. */
  92568. init(): void;
  92569. private _closestFace;
  92570. private _zeroVector;
  92571. private _lookAtTmpMatrix;
  92572. private _lookAtToRef;
  92573. /**
  92574. * Attaches the AttachToBoxBehavior to the passed in mesh
  92575. * @param target The mesh that the specified node will be attached to
  92576. */
  92577. attach(target: Mesh): void;
  92578. /**
  92579. * Detaches the behavior from the mesh
  92580. */
  92581. detach(): void;
  92582. }
  92583. }
  92584. declare module BABYLON {
  92585. /**
  92586. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  92587. */
  92588. export class FadeInOutBehavior implements Behavior<Mesh> {
  92589. /**
  92590. * Time in milliseconds to delay before fading in (Default: 0)
  92591. */
  92592. delay: number;
  92593. /**
  92594. * Time in milliseconds for the mesh to fade in (Default: 300)
  92595. */
  92596. fadeInTime: number;
  92597. private _millisecondsPerFrame;
  92598. private _hovered;
  92599. private _hoverValue;
  92600. private _ownerNode;
  92601. /**
  92602. * Instatiates the FadeInOutBehavior
  92603. */
  92604. constructor();
  92605. /**
  92606. * The name of the behavior
  92607. */
  92608. readonly name: string;
  92609. /**
  92610. * Initializes the behavior
  92611. */
  92612. init(): void;
  92613. /**
  92614. * Attaches the fade behavior on the passed in mesh
  92615. * @param ownerNode The mesh that will be faded in/out once attached
  92616. */
  92617. attach(ownerNode: Mesh): void;
  92618. /**
  92619. * Detaches the behavior from the mesh
  92620. */
  92621. detach(): void;
  92622. /**
  92623. * Triggers the mesh to begin fading in or out
  92624. * @param value if the object should fade in or out (true to fade in)
  92625. */
  92626. fadeIn(value: boolean): void;
  92627. private _update;
  92628. private _setAllVisibility;
  92629. }
  92630. }
  92631. declare module BABYLON {
  92632. /**
  92633. * Class containing a set of static utilities functions for managing Pivots
  92634. * @hidden
  92635. */
  92636. export class PivotTools {
  92637. private static _PivotCached;
  92638. private static _OldPivotPoint;
  92639. private static _PivotTranslation;
  92640. private static _PivotTmpVector;
  92641. /** @hidden */
  92642. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  92643. /** @hidden */
  92644. static _RestorePivotPoint(mesh: AbstractMesh): void;
  92645. }
  92646. }
  92647. declare module BABYLON {
  92648. /**
  92649. * Class containing static functions to help procedurally build meshes
  92650. */
  92651. export class PlaneBuilder {
  92652. /**
  92653. * Creates a plane mesh
  92654. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  92655. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  92656. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  92657. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92658. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  92659. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92660. * @param name defines the name of the mesh
  92661. * @param options defines the options used to create the mesh
  92662. * @param scene defines the hosting scene
  92663. * @returns the plane mesh
  92664. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  92665. */
  92666. static CreatePlane(name: string, options: {
  92667. size?: number;
  92668. width?: number;
  92669. height?: number;
  92670. sideOrientation?: number;
  92671. frontUVs?: Vector4;
  92672. backUVs?: Vector4;
  92673. updatable?: boolean;
  92674. sourcePlane?: Plane;
  92675. }, scene: Scene): Mesh;
  92676. }
  92677. }
  92678. declare module BABYLON {
  92679. /**
  92680. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  92681. */
  92682. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  92683. private static _AnyMouseID;
  92684. private _attachedNode;
  92685. private _dragPlane;
  92686. private _scene;
  92687. private _pointerObserver;
  92688. private _beforeRenderObserver;
  92689. private static _planeScene;
  92690. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  92691. /**
  92692. * 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)
  92693. */
  92694. maxDragAngle: number;
  92695. /**
  92696. * @hidden
  92697. */
  92698. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  92699. /**
  92700. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  92701. */
  92702. currentDraggingPointerID: number;
  92703. /**
  92704. * The last position where the pointer hit the drag plane in world space
  92705. */
  92706. lastDragPosition: Vector3;
  92707. /**
  92708. * If the behavior is currently in a dragging state
  92709. */
  92710. dragging: boolean;
  92711. /**
  92712. * 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)
  92713. */
  92714. dragDeltaRatio: number;
  92715. /**
  92716. * If the drag plane orientation should be updated during the dragging (Default: true)
  92717. */
  92718. updateDragPlane: boolean;
  92719. private _debugMode;
  92720. private _moving;
  92721. /**
  92722. * Fires each time the attached mesh is dragged with the pointer
  92723. * * delta between last drag position and current drag position in world space
  92724. * * dragDistance along the drag axis
  92725. * * dragPlaneNormal normal of the current drag plane used during the drag
  92726. * * dragPlanePoint in world space where the drag intersects the drag plane
  92727. */
  92728. onDragObservable: Observable<{
  92729. delta: Vector3;
  92730. dragPlanePoint: Vector3;
  92731. dragPlaneNormal: Vector3;
  92732. dragDistance: number;
  92733. pointerId: number;
  92734. }>;
  92735. /**
  92736. * Fires each time a drag begins (eg. mouse down on mesh)
  92737. */
  92738. onDragStartObservable: Observable<{
  92739. dragPlanePoint: Vector3;
  92740. pointerId: number;
  92741. }>;
  92742. /**
  92743. * Fires each time a drag ends (eg. mouse release after drag)
  92744. */
  92745. onDragEndObservable: Observable<{
  92746. dragPlanePoint: Vector3;
  92747. pointerId: number;
  92748. }>;
  92749. /**
  92750. * If the attached mesh should be moved when dragged
  92751. */
  92752. moveAttached: boolean;
  92753. /**
  92754. * If the drag behavior will react to drag events (Default: true)
  92755. */
  92756. enabled: boolean;
  92757. /**
  92758. * If camera controls should be detached during the drag
  92759. */
  92760. detachCameraControls: boolean;
  92761. /**
  92762. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  92763. */
  92764. useObjectOrienationForDragging: boolean;
  92765. private _options;
  92766. /**
  92767. * Creates a pointer drag behavior that can be attached to a mesh
  92768. * @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)
  92769. */
  92770. constructor(options?: {
  92771. dragAxis?: Vector3;
  92772. dragPlaneNormal?: Vector3;
  92773. });
  92774. /**
  92775. * Predicate to determine if it is valid to move the object to a new position when it is moved
  92776. */
  92777. validateDrag: (targetPosition: Vector3) => boolean;
  92778. /**
  92779. * The name of the behavior
  92780. */
  92781. readonly name: string;
  92782. /**
  92783. * Initializes the behavior
  92784. */
  92785. init(): void;
  92786. private _tmpVector;
  92787. private _alternatePickedPoint;
  92788. private _worldDragAxis;
  92789. private _targetPosition;
  92790. private _attachedElement;
  92791. /**
  92792. * Attaches the drag behavior the passed in mesh
  92793. * @param ownerNode The mesh that will be dragged around once attached
  92794. */
  92795. attach(ownerNode: AbstractMesh): void;
  92796. /**
  92797. * Force relase the drag action by code.
  92798. */
  92799. releaseDrag(): void;
  92800. private _startDragRay;
  92801. private _lastPointerRay;
  92802. /**
  92803. * Simulates the start of a pointer drag event on the behavior
  92804. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  92805. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  92806. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  92807. */
  92808. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  92809. private _startDrag;
  92810. private _dragDelta;
  92811. private _moveDrag;
  92812. private _pickWithRayOnDragPlane;
  92813. private _pointA;
  92814. private _pointB;
  92815. private _pointC;
  92816. private _lineA;
  92817. private _lineB;
  92818. private _localAxis;
  92819. private _lookAt;
  92820. private _updateDragPlanePosition;
  92821. /**
  92822. * Detaches the behavior from the mesh
  92823. */
  92824. detach(): void;
  92825. }
  92826. }
  92827. declare module BABYLON {
  92828. /**
  92829. * A behavior that when attached to a mesh will allow the mesh to be scaled
  92830. */
  92831. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  92832. private _dragBehaviorA;
  92833. private _dragBehaviorB;
  92834. private _startDistance;
  92835. private _initialScale;
  92836. private _targetScale;
  92837. private _ownerNode;
  92838. private _sceneRenderObserver;
  92839. /**
  92840. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  92841. */
  92842. constructor();
  92843. /**
  92844. * The name of the behavior
  92845. */
  92846. readonly name: string;
  92847. /**
  92848. * Initializes the behavior
  92849. */
  92850. init(): void;
  92851. private _getCurrentDistance;
  92852. /**
  92853. * Attaches the scale behavior the passed in mesh
  92854. * @param ownerNode The mesh that will be scaled around once attached
  92855. */
  92856. attach(ownerNode: Mesh): void;
  92857. /**
  92858. * Detaches the behavior from the mesh
  92859. */
  92860. detach(): void;
  92861. }
  92862. }
  92863. declare module BABYLON {
  92864. /**
  92865. * 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
  92866. */
  92867. export class SixDofDragBehavior implements Behavior<Mesh> {
  92868. private static _virtualScene;
  92869. private _ownerNode;
  92870. private _sceneRenderObserver;
  92871. private _scene;
  92872. private _targetPosition;
  92873. private _virtualOriginMesh;
  92874. private _virtualDragMesh;
  92875. private _pointerObserver;
  92876. private _moving;
  92877. private _startingOrientation;
  92878. /**
  92879. * 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)
  92880. */
  92881. private zDragFactor;
  92882. /**
  92883. * If the object should rotate to face the drag origin
  92884. */
  92885. rotateDraggedObject: boolean;
  92886. /**
  92887. * If the behavior is currently in a dragging state
  92888. */
  92889. dragging: boolean;
  92890. /**
  92891. * 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)
  92892. */
  92893. dragDeltaRatio: number;
  92894. /**
  92895. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  92896. */
  92897. currentDraggingPointerID: number;
  92898. /**
  92899. * If camera controls should be detached during the drag
  92900. */
  92901. detachCameraControls: boolean;
  92902. /**
  92903. * Fires each time a drag starts
  92904. */
  92905. onDragStartObservable: Observable<{}>;
  92906. /**
  92907. * Fires each time a drag ends (eg. mouse release after drag)
  92908. */
  92909. onDragEndObservable: Observable<{}>;
  92910. /**
  92911. * 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
  92912. */
  92913. constructor();
  92914. /**
  92915. * The name of the behavior
  92916. */
  92917. readonly name: string;
  92918. /**
  92919. * Initializes the behavior
  92920. */
  92921. init(): void;
  92922. /**
  92923. * Attaches the scale behavior the passed in mesh
  92924. * @param ownerNode The mesh that will be scaled around once attached
  92925. */
  92926. attach(ownerNode: Mesh): void;
  92927. /**
  92928. * Detaches the behavior from the mesh
  92929. */
  92930. detach(): void;
  92931. }
  92932. }
  92933. declare module BABYLON {
  92934. /**
  92935. * Class used to apply inverse kinematics to bones
  92936. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  92937. */
  92938. export class BoneIKController {
  92939. private static _tmpVecs;
  92940. private static _tmpQuat;
  92941. private static _tmpMats;
  92942. /**
  92943. * Gets or sets the target mesh
  92944. */
  92945. targetMesh: AbstractMesh;
  92946. /** Gets or sets the mesh used as pole */
  92947. poleTargetMesh: AbstractMesh;
  92948. /**
  92949. * Gets or sets the bone used as pole
  92950. */
  92951. poleTargetBone: Nullable<Bone>;
  92952. /**
  92953. * Gets or sets the target position
  92954. */
  92955. targetPosition: Vector3;
  92956. /**
  92957. * Gets or sets the pole target position
  92958. */
  92959. poleTargetPosition: Vector3;
  92960. /**
  92961. * Gets or sets the pole target local offset
  92962. */
  92963. poleTargetLocalOffset: Vector3;
  92964. /**
  92965. * Gets or sets the pole angle
  92966. */
  92967. poleAngle: number;
  92968. /**
  92969. * Gets or sets the mesh associated with the controller
  92970. */
  92971. mesh: AbstractMesh;
  92972. /**
  92973. * 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)
  92974. */
  92975. slerpAmount: number;
  92976. private _bone1Quat;
  92977. private _bone1Mat;
  92978. private _bone2Ang;
  92979. private _bone1;
  92980. private _bone2;
  92981. private _bone1Length;
  92982. private _bone2Length;
  92983. private _maxAngle;
  92984. private _maxReach;
  92985. private _rightHandedSystem;
  92986. private _bendAxis;
  92987. private _slerping;
  92988. private _adjustRoll;
  92989. /**
  92990. * Gets or sets maximum allowed angle
  92991. */
  92992. maxAngle: number;
  92993. /**
  92994. * Creates a new BoneIKController
  92995. * @param mesh defines the mesh to control
  92996. * @param bone defines the bone to control
  92997. * @param options defines options to set up the controller
  92998. */
  92999. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  93000. targetMesh?: AbstractMesh;
  93001. poleTargetMesh?: AbstractMesh;
  93002. poleTargetBone?: Bone;
  93003. poleTargetLocalOffset?: Vector3;
  93004. poleAngle?: number;
  93005. bendAxis?: Vector3;
  93006. maxAngle?: number;
  93007. slerpAmount?: number;
  93008. });
  93009. private _setMaxAngle;
  93010. /**
  93011. * Force the controller to update the bones
  93012. */
  93013. update(): void;
  93014. }
  93015. }
  93016. declare module BABYLON {
  93017. /**
  93018. * Class used to make a bone look toward a point in space
  93019. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  93020. */
  93021. export class BoneLookController {
  93022. private static _tmpVecs;
  93023. private static _tmpQuat;
  93024. private static _tmpMats;
  93025. /**
  93026. * The target Vector3 that the bone will look at
  93027. */
  93028. target: Vector3;
  93029. /**
  93030. * The mesh that the bone is attached to
  93031. */
  93032. mesh: AbstractMesh;
  93033. /**
  93034. * The bone that will be looking to the target
  93035. */
  93036. bone: Bone;
  93037. /**
  93038. * The up axis of the coordinate system that is used when the bone is rotated
  93039. */
  93040. upAxis: Vector3;
  93041. /**
  93042. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  93043. */
  93044. upAxisSpace: Space;
  93045. /**
  93046. * Used to make an adjustment to the yaw of the bone
  93047. */
  93048. adjustYaw: number;
  93049. /**
  93050. * Used to make an adjustment to the pitch of the bone
  93051. */
  93052. adjustPitch: number;
  93053. /**
  93054. * Used to make an adjustment to the roll of the bone
  93055. */
  93056. adjustRoll: number;
  93057. /**
  93058. * 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)
  93059. */
  93060. slerpAmount: number;
  93061. private _minYaw;
  93062. private _maxYaw;
  93063. private _minPitch;
  93064. private _maxPitch;
  93065. private _minYawSin;
  93066. private _minYawCos;
  93067. private _maxYawSin;
  93068. private _maxYawCos;
  93069. private _midYawConstraint;
  93070. private _minPitchTan;
  93071. private _maxPitchTan;
  93072. private _boneQuat;
  93073. private _slerping;
  93074. private _transformYawPitch;
  93075. private _transformYawPitchInv;
  93076. private _firstFrameSkipped;
  93077. private _yawRange;
  93078. private _fowardAxis;
  93079. /**
  93080. * Gets or sets the minimum yaw angle that the bone can look to
  93081. */
  93082. minYaw: number;
  93083. /**
  93084. * Gets or sets the maximum yaw angle that the bone can look to
  93085. */
  93086. maxYaw: number;
  93087. /**
  93088. * Gets or sets the minimum pitch angle that the bone can look to
  93089. */
  93090. minPitch: number;
  93091. /**
  93092. * Gets or sets the maximum pitch angle that the bone can look to
  93093. */
  93094. maxPitch: number;
  93095. /**
  93096. * Create a BoneLookController
  93097. * @param mesh the mesh that the bone belongs to
  93098. * @param bone the bone that will be looking to the target
  93099. * @param target the target Vector3 to look at
  93100. * @param options optional settings:
  93101. * * maxYaw: the maximum angle the bone will yaw to
  93102. * * minYaw: the minimum angle the bone will yaw to
  93103. * * maxPitch: the maximum angle the bone will pitch to
  93104. * * minPitch: the minimum angle the bone will yaw to
  93105. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  93106. * * upAxis: the up axis of the coordinate system
  93107. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  93108. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  93109. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  93110. * * adjustYaw: used to make an adjustment to the yaw of the bone
  93111. * * adjustPitch: used to make an adjustment to the pitch of the bone
  93112. * * adjustRoll: used to make an adjustment to the roll of the bone
  93113. **/
  93114. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  93115. maxYaw?: number;
  93116. minYaw?: number;
  93117. maxPitch?: number;
  93118. minPitch?: number;
  93119. slerpAmount?: number;
  93120. upAxis?: Vector3;
  93121. upAxisSpace?: Space;
  93122. yawAxis?: Vector3;
  93123. pitchAxis?: Vector3;
  93124. adjustYaw?: number;
  93125. adjustPitch?: number;
  93126. adjustRoll?: number;
  93127. });
  93128. /**
  93129. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  93130. */
  93131. update(): void;
  93132. private _getAngleDiff;
  93133. private _getAngleBetween;
  93134. private _isAngleBetween;
  93135. }
  93136. }
  93137. declare module BABYLON {
  93138. /**
  93139. * Manage the gamepad inputs to control an arc rotate camera.
  93140. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93141. */
  93142. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  93143. /**
  93144. * Defines the camera the input is attached to.
  93145. */
  93146. camera: ArcRotateCamera;
  93147. /**
  93148. * Defines the gamepad the input is gathering event from.
  93149. */
  93150. gamepad: Nullable<Gamepad>;
  93151. /**
  93152. * Defines the gamepad rotation sensiblity.
  93153. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  93154. */
  93155. gamepadRotationSensibility: number;
  93156. /**
  93157. * Defines the gamepad move sensiblity.
  93158. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  93159. */
  93160. gamepadMoveSensibility: number;
  93161. private _onGamepadConnectedObserver;
  93162. private _onGamepadDisconnectedObserver;
  93163. /**
  93164. * Attach the input controls to a specific dom element to get the input from.
  93165. * @param element Defines the element the controls should be listened from
  93166. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93167. */
  93168. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93169. /**
  93170. * Detach the current controls from the specified dom element.
  93171. * @param element Defines the element to stop listening the inputs from
  93172. */
  93173. detachControl(element: Nullable<HTMLElement>): void;
  93174. /**
  93175. * Update the current camera state depending on the inputs that have been used this frame.
  93176. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93177. */
  93178. checkInputs(): void;
  93179. /**
  93180. * Gets the class name of the current intput.
  93181. * @returns the class name
  93182. */
  93183. getClassName(): string;
  93184. /**
  93185. * Get the friendly name associated with the input class.
  93186. * @returns the input friendly name
  93187. */
  93188. getSimpleName(): string;
  93189. }
  93190. }
  93191. declare module BABYLON {
  93192. interface ArcRotateCameraInputsManager {
  93193. /**
  93194. * Add orientation input support to the input manager.
  93195. * @returns the current input manager
  93196. */
  93197. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  93198. }
  93199. /**
  93200. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  93201. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93202. */
  93203. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  93204. /**
  93205. * Defines the camera the input is attached to.
  93206. */
  93207. camera: ArcRotateCamera;
  93208. /**
  93209. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  93210. */
  93211. alphaCorrection: number;
  93212. /**
  93213. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  93214. */
  93215. gammaCorrection: number;
  93216. private _alpha;
  93217. private _gamma;
  93218. private _dirty;
  93219. private _deviceOrientationHandler;
  93220. /**
  93221. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  93222. */
  93223. constructor();
  93224. /**
  93225. * Attach the input controls to a specific dom element to get the input from.
  93226. * @param element Defines the element the controls should be listened from
  93227. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93228. */
  93229. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93230. /** @hidden */
  93231. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  93232. /**
  93233. * Update the current camera state depending on the inputs that have been used this frame.
  93234. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93235. */
  93236. checkInputs(): void;
  93237. /**
  93238. * Detach the current controls from the specified dom element.
  93239. * @param element Defines the element to stop listening the inputs from
  93240. */
  93241. detachControl(element: Nullable<HTMLElement>): void;
  93242. /**
  93243. * Gets the class name of the current intput.
  93244. * @returns the class name
  93245. */
  93246. getClassName(): string;
  93247. /**
  93248. * Get the friendly name associated with the input class.
  93249. * @returns the input friendly name
  93250. */
  93251. getSimpleName(): string;
  93252. }
  93253. }
  93254. declare module BABYLON {
  93255. /**
  93256. * Listen to mouse events to control the camera.
  93257. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93258. */
  93259. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  93260. /**
  93261. * Defines the camera the input is attached to.
  93262. */
  93263. camera: FlyCamera;
  93264. /**
  93265. * Defines if touch is enabled. (Default is true.)
  93266. */
  93267. touchEnabled: boolean;
  93268. /**
  93269. * Defines the buttons associated with the input to handle camera rotation.
  93270. */
  93271. buttons: number[];
  93272. /**
  93273. * Assign buttons for Yaw control.
  93274. */
  93275. buttonsYaw: number[];
  93276. /**
  93277. * Assign buttons for Pitch control.
  93278. */
  93279. buttonsPitch: number[];
  93280. /**
  93281. * Assign buttons for Roll control.
  93282. */
  93283. buttonsRoll: number[];
  93284. /**
  93285. * Detect if any button is being pressed while mouse is moved.
  93286. * -1 = Mouse locked.
  93287. * 0 = Left button.
  93288. * 1 = Middle Button.
  93289. * 2 = Right Button.
  93290. */
  93291. activeButton: number;
  93292. /**
  93293. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  93294. * Higher values reduce its sensitivity.
  93295. */
  93296. angularSensibility: number;
  93297. private _mousemoveCallback;
  93298. private _observer;
  93299. private _rollObserver;
  93300. private previousPosition;
  93301. private noPreventDefault;
  93302. private element;
  93303. /**
  93304. * Listen to mouse events to control the camera.
  93305. * @param touchEnabled Define if touch is enabled. (Default is true.)
  93306. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93307. */
  93308. constructor(touchEnabled?: boolean);
  93309. /**
  93310. * Attach the mouse control to the HTML DOM element.
  93311. * @param element Defines the element that listens to the input events.
  93312. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  93313. */
  93314. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93315. /**
  93316. * Detach the current controls from the specified dom element.
  93317. * @param element Defines the element to stop listening the inputs from
  93318. */
  93319. detachControl(element: Nullable<HTMLElement>): void;
  93320. /**
  93321. * Gets the class name of the current input.
  93322. * @returns the class name.
  93323. */
  93324. getClassName(): string;
  93325. /**
  93326. * Get the friendly name associated with the input class.
  93327. * @returns the input's friendly name.
  93328. */
  93329. getSimpleName(): string;
  93330. private _pointerInput;
  93331. private _onMouseMove;
  93332. /**
  93333. * Rotate camera by mouse offset.
  93334. */
  93335. private rotateCamera;
  93336. }
  93337. }
  93338. declare module BABYLON {
  93339. /**
  93340. * Default Inputs manager for the FlyCamera.
  93341. * It groups all the default supported inputs for ease of use.
  93342. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93343. */
  93344. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  93345. /**
  93346. * Instantiates a new FlyCameraInputsManager.
  93347. * @param camera Defines the camera the inputs belong to.
  93348. */
  93349. constructor(camera: FlyCamera);
  93350. /**
  93351. * Add keyboard input support to the input manager.
  93352. * @returns the new FlyCameraKeyboardMoveInput().
  93353. */
  93354. addKeyboard(): FlyCameraInputsManager;
  93355. /**
  93356. * Add mouse input support to the input manager.
  93357. * @param touchEnabled Enable touch screen support.
  93358. * @returns the new FlyCameraMouseInput().
  93359. */
  93360. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  93361. }
  93362. }
  93363. declare module BABYLON {
  93364. /**
  93365. * This is a flying camera, designed for 3D movement and rotation in all directions,
  93366. * such as in a 3D Space Shooter or a Flight Simulator.
  93367. */
  93368. export class FlyCamera extends TargetCamera {
  93369. /**
  93370. * Define the collision ellipsoid of the camera.
  93371. * This is helpful for simulating a camera body, like a player's body.
  93372. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  93373. */
  93374. ellipsoid: Vector3;
  93375. /**
  93376. * Define an offset for the position of the ellipsoid around the camera.
  93377. * This can be helpful if the camera is attached away from the player's body center,
  93378. * such as at its head.
  93379. */
  93380. ellipsoidOffset: Vector3;
  93381. /**
  93382. * Enable or disable collisions of the camera with the rest of the scene objects.
  93383. */
  93384. checkCollisions: boolean;
  93385. /**
  93386. * Enable or disable gravity on the camera.
  93387. */
  93388. applyGravity: boolean;
  93389. /**
  93390. * Define the current direction the camera is moving to.
  93391. */
  93392. cameraDirection: Vector3;
  93393. /**
  93394. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  93395. * This overrides and empties cameraRotation.
  93396. */
  93397. rotationQuaternion: Quaternion;
  93398. /**
  93399. * Track Roll to maintain the wanted Rolling when looking around.
  93400. */
  93401. _trackRoll: number;
  93402. /**
  93403. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  93404. */
  93405. rollCorrect: number;
  93406. /**
  93407. * Mimic a banked turn, Rolling the camera when Yawing.
  93408. * It's recommended to use rollCorrect = 10 for faster banking correction.
  93409. */
  93410. bankedTurn: boolean;
  93411. /**
  93412. * Limit in radians for how much Roll banking will add. (Default: 90°)
  93413. */
  93414. bankedTurnLimit: number;
  93415. /**
  93416. * Value of 0 disables the banked Roll.
  93417. * Value of 1 is equal to the Yaw angle in radians.
  93418. */
  93419. bankedTurnMultiplier: number;
  93420. /**
  93421. * The inputs manager loads all the input sources, such as keyboard and mouse.
  93422. */
  93423. inputs: FlyCameraInputsManager;
  93424. /**
  93425. * Gets the input sensibility for mouse input.
  93426. * Higher values reduce sensitivity.
  93427. */
  93428. /**
  93429. * Sets the input sensibility for a mouse input.
  93430. * Higher values reduce sensitivity.
  93431. */
  93432. angularSensibility: number;
  93433. /**
  93434. * Get the keys for camera movement forward.
  93435. */
  93436. /**
  93437. * Set the keys for camera movement forward.
  93438. */
  93439. keysForward: number[];
  93440. /**
  93441. * Get the keys for camera movement backward.
  93442. */
  93443. keysBackward: number[];
  93444. /**
  93445. * Get the keys for camera movement up.
  93446. */
  93447. /**
  93448. * Set the keys for camera movement up.
  93449. */
  93450. keysUp: number[];
  93451. /**
  93452. * Get the keys for camera movement down.
  93453. */
  93454. /**
  93455. * Set the keys for camera movement down.
  93456. */
  93457. keysDown: number[];
  93458. /**
  93459. * Get the keys for camera movement left.
  93460. */
  93461. /**
  93462. * Set the keys for camera movement left.
  93463. */
  93464. keysLeft: number[];
  93465. /**
  93466. * Set the keys for camera movement right.
  93467. */
  93468. /**
  93469. * Set the keys for camera movement right.
  93470. */
  93471. keysRight: number[];
  93472. /**
  93473. * Event raised when the camera collides with a mesh in the scene.
  93474. */
  93475. onCollide: (collidedMesh: AbstractMesh) => void;
  93476. private _collider;
  93477. private _needMoveForGravity;
  93478. private _oldPosition;
  93479. private _diffPosition;
  93480. private _newPosition;
  93481. /** @hidden */
  93482. _localDirection: Vector3;
  93483. /** @hidden */
  93484. _transformedDirection: Vector3;
  93485. /**
  93486. * Instantiates a FlyCamera.
  93487. * This is a flying camera, designed for 3D movement and rotation in all directions,
  93488. * such as in a 3D Space Shooter or a Flight Simulator.
  93489. * @param name Define the name of the camera in the scene.
  93490. * @param position Define the starting position of the camera in the scene.
  93491. * @param scene Define the scene the camera belongs to.
  93492. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  93493. */
  93494. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93495. /**
  93496. * Attach a control to the HTML DOM element.
  93497. * @param element Defines the element that listens to the input events.
  93498. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  93499. */
  93500. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93501. /**
  93502. * Detach a control from the HTML DOM element.
  93503. * The camera will stop reacting to that input.
  93504. * @param element Defines the element that listens to the input events.
  93505. */
  93506. detachControl(element: HTMLElement): void;
  93507. private _collisionMask;
  93508. /**
  93509. * Get the mask that the camera ignores in collision events.
  93510. */
  93511. /**
  93512. * Set the mask that the camera ignores in collision events.
  93513. */
  93514. collisionMask: number;
  93515. /** @hidden */
  93516. _collideWithWorld(displacement: Vector3): void;
  93517. /** @hidden */
  93518. private _onCollisionPositionChange;
  93519. /** @hidden */
  93520. _checkInputs(): void;
  93521. /** @hidden */
  93522. _decideIfNeedsToMove(): boolean;
  93523. /** @hidden */
  93524. _updatePosition(): void;
  93525. /**
  93526. * Restore the Roll to its target value at the rate specified.
  93527. * @param rate - Higher means slower restoring.
  93528. * @hidden
  93529. */
  93530. restoreRoll(rate: number): void;
  93531. /**
  93532. * Destroy the camera and release the current resources held by it.
  93533. */
  93534. dispose(): void;
  93535. /**
  93536. * Get the current object class name.
  93537. * @returns the class name.
  93538. */
  93539. getClassName(): string;
  93540. }
  93541. }
  93542. declare module BABYLON {
  93543. /**
  93544. * Listen to keyboard events to control the camera.
  93545. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93546. */
  93547. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  93548. /**
  93549. * Defines the camera the input is attached to.
  93550. */
  93551. camera: FlyCamera;
  93552. /**
  93553. * The list of keyboard keys used to control the forward move of the camera.
  93554. */
  93555. keysForward: number[];
  93556. /**
  93557. * The list of keyboard keys used to control the backward move of the camera.
  93558. */
  93559. keysBackward: number[];
  93560. /**
  93561. * The list of keyboard keys used to control the forward move of the camera.
  93562. */
  93563. keysUp: number[];
  93564. /**
  93565. * The list of keyboard keys used to control the backward move of the camera.
  93566. */
  93567. keysDown: number[];
  93568. /**
  93569. * The list of keyboard keys used to control the right strafe move of the camera.
  93570. */
  93571. keysRight: number[];
  93572. /**
  93573. * The list of keyboard keys used to control the left strafe move of the camera.
  93574. */
  93575. keysLeft: number[];
  93576. private _keys;
  93577. private _onCanvasBlurObserver;
  93578. private _onKeyboardObserver;
  93579. private _engine;
  93580. private _scene;
  93581. /**
  93582. * Attach the input controls to a specific dom element to get the input from.
  93583. * @param element Defines the element the controls should be listened from
  93584. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93585. */
  93586. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93587. /**
  93588. * Detach the current controls from the specified dom element.
  93589. * @param element Defines the element to stop listening the inputs from
  93590. */
  93591. detachControl(element: Nullable<HTMLElement>): void;
  93592. /**
  93593. * Gets the class name of the current intput.
  93594. * @returns the class name
  93595. */
  93596. getClassName(): string;
  93597. /** @hidden */
  93598. _onLostFocus(e: FocusEvent): void;
  93599. /**
  93600. * Get the friendly name associated with the input class.
  93601. * @returns the input friendly name
  93602. */
  93603. getSimpleName(): string;
  93604. /**
  93605. * Update the current camera state depending on the inputs that have been used this frame.
  93606. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93607. */
  93608. checkInputs(): void;
  93609. }
  93610. }
  93611. declare module BABYLON {
  93612. /**
  93613. * Manage the mouse wheel inputs to control a follow camera.
  93614. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93615. */
  93616. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  93617. /**
  93618. * Defines the camera the input is attached to.
  93619. */
  93620. camera: FollowCamera;
  93621. /**
  93622. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  93623. */
  93624. axisControlRadius: boolean;
  93625. /**
  93626. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  93627. */
  93628. axisControlHeight: boolean;
  93629. /**
  93630. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  93631. */
  93632. axisControlRotation: boolean;
  93633. /**
  93634. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  93635. * relation to mouseWheel events.
  93636. */
  93637. wheelPrecision: number;
  93638. /**
  93639. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  93640. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  93641. */
  93642. wheelDeltaPercentage: number;
  93643. private _wheel;
  93644. private _observer;
  93645. /**
  93646. * Attach the input controls to a specific dom element to get the input from.
  93647. * @param element Defines the element the controls should be listened from
  93648. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93649. */
  93650. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93651. /**
  93652. * Detach the current controls from the specified dom element.
  93653. * @param element Defines the element to stop listening the inputs from
  93654. */
  93655. detachControl(element: Nullable<HTMLElement>): void;
  93656. /**
  93657. * Gets the class name of the current intput.
  93658. * @returns the class name
  93659. */
  93660. getClassName(): string;
  93661. /**
  93662. * Get the friendly name associated with the input class.
  93663. * @returns the input friendly name
  93664. */
  93665. getSimpleName(): string;
  93666. }
  93667. }
  93668. declare module BABYLON {
  93669. /**
  93670. * Manage the pointers inputs to control an follow camera.
  93671. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93672. */
  93673. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  93674. /**
  93675. * Defines the camera the input is attached to.
  93676. */
  93677. camera: FollowCamera;
  93678. /**
  93679. * Gets the class name of the current input.
  93680. * @returns the class name
  93681. */
  93682. getClassName(): string;
  93683. /**
  93684. * Defines the pointer angular sensibility along the X axis or how fast is
  93685. * the camera rotating.
  93686. * A negative number will reverse the axis direction.
  93687. */
  93688. angularSensibilityX: number;
  93689. /**
  93690. * Defines the pointer angular sensibility along the Y axis or how fast is
  93691. * the camera rotating.
  93692. * A negative number will reverse the axis direction.
  93693. */
  93694. angularSensibilityY: number;
  93695. /**
  93696. * Defines the pointer pinch precision or how fast is the camera zooming.
  93697. * A negative number will reverse the axis direction.
  93698. */
  93699. pinchPrecision: number;
  93700. /**
  93701. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  93702. * from 0.
  93703. * It defines the percentage of current camera.radius to use as delta when
  93704. * pinch zoom is used.
  93705. */
  93706. pinchDeltaPercentage: number;
  93707. /**
  93708. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  93709. */
  93710. axisXControlRadius: boolean;
  93711. /**
  93712. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  93713. */
  93714. axisXControlHeight: boolean;
  93715. /**
  93716. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  93717. */
  93718. axisXControlRotation: boolean;
  93719. /**
  93720. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  93721. */
  93722. axisYControlRadius: boolean;
  93723. /**
  93724. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  93725. */
  93726. axisYControlHeight: boolean;
  93727. /**
  93728. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  93729. */
  93730. axisYControlRotation: boolean;
  93731. /**
  93732. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  93733. */
  93734. axisPinchControlRadius: boolean;
  93735. /**
  93736. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  93737. */
  93738. axisPinchControlHeight: boolean;
  93739. /**
  93740. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  93741. */
  93742. axisPinchControlRotation: boolean;
  93743. /**
  93744. * Log error messages if basic misconfiguration has occurred.
  93745. */
  93746. warningEnable: boolean;
  93747. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  93748. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  93749. private _warningCounter;
  93750. private _warning;
  93751. }
  93752. }
  93753. declare module BABYLON {
  93754. /**
  93755. * Default Inputs manager for the FollowCamera.
  93756. * It groups all the default supported inputs for ease of use.
  93757. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93758. */
  93759. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  93760. /**
  93761. * Instantiates a new FollowCameraInputsManager.
  93762. * @param camera Defines the camera the inputs belong to
  93763. */
  93764. constructor(camera: FollowCamera);
  93765. /**
  93766. * Add keyboard input support to the input manager.
  93767. * @returns the current input manager
  93768. */
  93769. addKeyboard(): FollowCameraInputsManager;
  93770. /**
  93771. * Add mouse wheel input support to the input manager.
  93772. * @returns the current input manager
  93773. */
  93774. addMouseWheel(): FollowCameraInputsManager;
  93775. /**
  93776. * Add pointers input support to the input manager.
  93777. * @returns the current input manager
  93778. */
  93779. addPointers(): FollowCameraInputsManager;
  93780. /**
  93781. * Add orientation input support to the input manager.
  93782. * @returns the current input manager
  93783. */
  93784. addVRDeviceOrientation(): FollowCameraInputsManager;
  93785. }
  93786. }
  93787. declare module BABYLON {
  93788. /**
  93789. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  93790. * an arc rotate version arcFollowCamera are available.
  93791. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93792. */
  93793. export class FollowCamera extends TargetCamera {
  93794. /**
  93795. * Distance the follow camera should follow an object at
  93796. */
  93797. radius: number;
  93798. /**
  93799. * Minimum allowed distance of the camera to the axis of rotation
  93800. * (The camera can not get closer).
  93801. * This can help limiting how the Camera is able to move in the scene.
  93802. */
  93803. lowerRadiusLimit: Nullable<number>;
  93804. /**
  93805. * Maximum allowed distance of the camera to the axis of rotation
  93806. * (The camera can not get further).
  93807. * This can help limiting how the Camera is able to move in the scene.
  93808. */
  93809. upperRadiusLimit: Nullable<number>;
  93810. /**
  93811. * Define a rotation offset between the camera and the object it follows
  93812. */
  93813. rotationOffset: number;
  93814. /**
  93815. * Minimum allowed angle to camera position relative to target object.
  93816. * This can help limiting how the Camera is able to move in the scene.
  93817. */
  93818. lowerRotationOffsetLimit: Nullable<number>;
  93819. /**
  93820. * Maximum allowed angle to camera position relative to target object.
  93821. * This can help limiting how the Camera is able to move in the scene.
  93822. */
  93823. upperRotationOffsetLimit: Nullable<number>;
  93824. /**
  93825. * Define a height offset between the camera and the object it follows.
  93826. * It can help following an object from the top (like a car chaing a plane)
  93827. */
  93828. heightOffset: number;
  93829. /**
  93830. * Minimum allowed height of camera position relative to target object.
  93831. * This can help limiting how the Camera is able to move in the scene.
  93832. */
  93833. lowerHeightOffsetLimit: Nullable<number>;
  93834. /**
  93835. * Maximum allowed height of camera position relative to target object.
  93836. * This can help limiting how the Camera is able to move in the scene.
  93837. */
  93838. upperHeightOffsetLimit: Nullable<number>;
  93839. /**
  93840. * Define how fast the camera can accelerate to follow it s target.
  93841. */
  93842. cameraAcceleration: number;
  93843. /**
  93844. * Define the speed limit of the camera following an object.
  93845. */
  93846. maxCameraSpeed: number;
  93847. /**
  93848. * Define the target of the camera.
  93849. */
  93850. lockedTarget: Nullable<AbstractMesh>;
  93851. /**
  93852. * Defines the input associated with the camera.
  93853. */
  93854. inputs: FollowCameraInputsManager;
  93855. /**
  93856. * Instantiates the follow camera.
  93857. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93858. * @param name Define the name of the camera in the scene
  93859. * @param position Define the position of the camera
  93860. * @param scene Define the scene the camera belong to
  93861. * @param lockedTarget Define the target of the camera
  93862. */
  93863. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  93864. private _follow;
  93865. /**
  93866. * Attached controls to the current camera.
  93867. * @param element Defines the element the controls should be listened from
  93868. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93869. */
  93870. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93871. /**
  93872. * Detach the current controls from the camera.
  93873. * The camera will stop reacting to inputs.
  93874. * @param element Defines the element to stop listening the inputs from
  93875. */
  93876. detachControl(element: HTMLElement): void;
  93877. /** @hidden */
  93878. _checkInputs(): void;
  93879. private _checkLimits;
  93880. /**
  93881. * Gets the camera class name.
  93882. * @returns the class name
  93883. */
  93884. getClassName(): string;
  93885. }
  93886. /**
  93887. * Arc Rotate version of the follow camera.
  93888. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  93889. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93890. */
  93891. export class ArcFollowCamera extends TargetCamera {
  93892. /** The longitudinal angle of the camera */
  93893. alpha: number;
  93894. /** The latitudinal angle of the camera */
  93895. beta: number;
  93896. /** The radius of the camera from its target */
  93897. radius: number;
  93898. /** Define the camera target (the messh it should follow) */
  93899. target: Nullable<AbstractMesh>;
  93900. private _cartesianCoordinates;
  93901. /**
  93902. * Instantiates a new ArcFollowCamera
  93903. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93904. * @param name Define the name of the camera
  93905. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  93906. * @param beta Define the rotation angle of the camera around the elevation axis
  93907. * @param radius Define the radius of the camera from its target point
  93908. * @param target Define the target of the camera
  93909. * @param scene Define the scene the camera belongs to
  93910. */
  93911. constructor(name: string,
  93912. /** The longitudinal angle of the camera */
  93913. alpha: number,
  93914. /** The latitudinal angle of the camera */
  93915. beta: number,
  93916. /** The radius of the camera from its target */
  93917. radius: number,
  93918. /** Define the camera target (the messh it should follow) */
  93919. target: Nullable<AbstractMesh>, scene: Scene);
  93920. private _follow;
  93921. /** @hidden */
  93922. _checkInputs(): void;
  93923. /**
  93924. * Returns the class name of the object.
  93925. * It is mostly used internally for serialization purposes.
  93926. */
  93927. getClassName(): string;
  93928. }
  93929. }
  93930. declare module BABYLON {
  93931. /**
  93932. * Manage the keyboard inputs to control the movement of a follow camera.
  93933. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93934. */
  93935. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  93936. /**
  93937. * Defines the camera the input is attached to.
  93938. */
  93939. camera: FollowCamera;
  93940. /**
  93941. * Defines the list of key codes associated with the up action (increase heightOffset)
  93942. */
  93943. keysHeightOffsetIncr: number[];
  93944. /**
  93945. * Defines the list of key codes associated with the down action (decrease heightOffset)
  93946. */
  93947. keysHeightOffsetDecr: number[];
  93948. /**
  93949. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  93950. */
  93951. keysHeightOffsetModifierAlt: boolean;
  93952. /**
  93953. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  93954. */
  93955. keysHeightOffsetModifierCtrl: boolean;
  93956. /**
  93957. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  93958. */
  93959. keysHeightOffsetModifierShift: boolean;
  93960. /**
  93961. * Defines the list of key codes associated with the left action (increase rotationOffset)
  93962. */
  93963. keysRotationOffsetIncr: number[];
  93964. /**
  93965. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  93966. */
  93967. keysRotationOffsetDecr: number[];
  93968. /**
  93969. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  93970. */
  93971. keysRotationOffsetModifierAlt: boolean;
  93972. /**
  93973. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  93974. */
  93975. keysRotationOffsetModifierCtrl: boolean;
  93976. /**
  93977. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  93978. */
  93979. keysRotationOffsetModifierShift: boolean;
  93980. /**
  93981. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  93982. */
  93983. keysRadiusIncr: number[];
  93984. /**
  93985. * Defines the list of key codes associated with the zoom-out action (increase radius)
  93986. */
  93987. keysRadiusDecr: number[];
  93988. /**
  93989. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  93990. */
  93991. keysRadiusModifierAlt: boolean;
  93992. /**
  93993. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  93994. */
  93995. keysRadiusModifierCtrl: boolean;
  93996. /**
  93997. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  93998. */
  93999. keysRadiusModifierShift: boolean;
  94000. /**
  94001. * Defines the rate of change of heightOffset.
  94002. */
  94003. heightSensibility: number;
  94004. /**
  94005. * Defines the rate of change of rotationOffset.
  94006. */
  94007. rotationSensibility: number;
  94008. /**
  94009. * Defines the rate of change of radius.
  94010. */
  94011. radiusSensibility: number;
  94012. private _keys;
  94013. private _ctrlPressed;
  94014. private _altPressed;
  94015. private _shiftPressed;
  94016. private _onCanvasBlurObserver;
  94017. private _onKeyboardObserver;
  94018. private _engine;
  94019. private _scene;
  94020. /**
  94021. * Attach the input controls to a specific dom element to get the input from.
  94022. * @param element Defines the element the controls should be listened from
  94023. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94024. */
  94025. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94026. /**
  94027. * Detach the current controls from the specified dom element.
  94028. * @param element Defines the element to stop listening the inputs from
  94029. */
  94030. detachControl(element: Nullable<HTMLElement>): void;
  94031. /**
  94032. * Update the current camera state depending on the inputs that have been used this frame.
  94033. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94034. */
  94035. checkInputs(): void;
  94036. /**
  94037. * Gets the class name of the current input.
  94038. * @returns the class name
  94039. */
  94040. getClassName(): string;
  94041. /**
  94042. * Get the friendly name associated with the input class.
  94043. * @returns the input friendly name
  94044. */
  94045. getSimpleName(): string;
  94046. /**
  94047. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  94048. * allow modification of the heightOffset value.
  94049. */
  94050. private _modifierHeightOffset;
  94051. /**
  94052. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  94053. * allow modification of the rotationOffset value.
  94054. */
  94055. private _modifierRotationOffset;
  94056. /**
  94057. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  94058. * allow modification of the radius value.
  94059. */
  94060. private _modifierRadius;
  94061. }
  94062. }
  94063. declare module BABYLON {
  94064. interface FreeCameraInputsManager {
  94065. /**
  94066. * Add orientation input support to the input manager.
  94067. * @returns the current input manager
  94068. */
  94069. addDeviceOrientation(): FreeCameraInputsManager;
  94070. }
  94071. /**
  94072. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  94073. * Screen rotation is taken into account.
  94074. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94075. */
  94076. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  94077. private _camera;
  94078. private _screenOrientationAngle;
  94079. private _constantTranform;
  94080. private _screenQuaternion;
  94081. private _alpha;
  94082. private _beta;
  94083. private _gamma;
  94084. /**
  94085. * Instantiates a new input
  94086. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94087. */
  94088. constructor();
  94089. /**
  94090. * Define the camera controlled by the input.
  94091. */
  94092. camera: FreeCamera;
  94093. /**
  94094. * Attach the input controls to a specific dom element to get the input from.
  94095. * @param element Defines the element the controls should be listened from
  94096. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94097. */
  94098. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94099. private _orientationChanged;
  94100. private _deviceOrientation;
  94101. /**
  94102. * Detach the current controls from the specified dom element.
  94103. * @param element Defines the element to stop listening the inputs from
  94104. */
  94105. detachControl(element: Nullable<HTMLElement>): void;
  94106. /**
  94107. * Update the current camera state depending on the inputs that have been used this frame.
  94108. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94109. */
  94110. checkInputs(): void;
  94111. /**
  94112. * Gets the class name of the current intput.
  94113. * @returns the class name
  94114. */
  94115. getClassName(): string;
  94116. /**
  94117. * Get the friendly name associated with the input class.
  94118. * @returns the input friendly name
  94119. */
  94120. getSimpleName(): string;
  94121. }
  94122. }
  94123. declare module BABYLON {
  94124. /**
  94125. * Manage the gamepad inputs to control a free camera.
  94126. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94127. */
  94128. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  94129. /**
  94130. * Define the camera the input is attached to.
  94131. */
  94132. camera: FreeCamera;
  94133. /**
  94134. * Define the Gamepad controlling the input
  94135. */
  94136. gamepad: Nullable<Gamepad>;
  94137. /**
  94138. * Defines the gamepad rotation sensiblity.
  94139. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  94140. */
  94141. gamepadAngularSensibility: number;
  94142. /**
  94143. * Defines the gamepad move sensiblity.
  94144. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  94145. */
  94146. gamepadMoveSensibility: number;
  94147. private _onGamepadConnectedObserver;
  94148. private _onGamepadDisconnectedObserver;
  94149. private _cameraTransform;
  94150. private _deltaTransform;
  94151. private _vector3;
  94152. private _vector2;
  94153. /**
  94154. * Attach the input controls to a specific dom element to get the input from.
  94155. * @param element Defines the element the controls should be listened from
  94156. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94157. */
  94158. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94159. /**
  94160. * Detach the current controls from the specified dom element.
  94161. * @param element Defines the element to stop listening the inputs from
  94162. */
  94163. detachControl(element: Nullable<HTMLElement>): void;
  94164. /**
  94165. * Update the current camera state depending on the inputs that have been used this frame.
  94166. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94167. */
  94168. checkInputs(): void;
  94169. /**
  94170. * Gets the class name of the current intput.
  94171. * @returns the class name
  94172. */
  94173. getClassName(): string;
  94174. /**
  94175. * Get the friendly name associated with the input class.
  94176. * @returns the input friendly name
  94177. */
  94178. getSimpleName(): string;
  94179. }
  94180. }
  94181. declare module BABYLON {
  94182. /**
  94183. * Defines the potential axis of a Joystick
  94184. */
  94185. export enum JoystickAxis {
  94186. /** X axis */
  94187. X = 0,
  94188. /** Y axis */
  94189. Y = 1,
  94190. /** Z axis */
  94191. Z = 2
  94192. }
  94193. /**
  94194. * Class used to define virtual joystick (used in touch mode)
  94195. */
  94196. export class VirtualJoystick {
  94197. /**
  94198. * Gets or sets a boolean indicating that left and right values must be inverted
  94199. */
  94200. reverseLeftRight: boolean;
  94201. /**
  94202. * Gets or sets a boolean indicating that up and down values must be inverted
  94203. */
  94204. reverseUpDown: boolean;
  94205. /**
  94206. * Gets the offset value for the position (ie. the change of the position value)
  94207. */
  94208. deltaPosition: Vector3;
  94209. /**
  94210. * Gets a boolean indicating if the virtual joystick was pressed
  94211. */
  94212. pressed: boolean;
  94213. /**
  94214. * Canvas the virtual joystick will render onto, default z-index of this is 5
  94215. */
  94216. static Canvas: Nullable<HTMLCanvasElement>;
  94217. private static _globalJoystickIndex;
  94218. private static vjCanvasContext;
  94219. private static vjCanvasWidth;
  94220. private static vjCanvasHeight;
  94221. private static halfWidth;
  94222. private _action;
  94223. private _axisTargetedByLeftAndRight;
  94224. private _axisTargetedByUpAndDown;
  94225. private _joystickSensibility;
  94226. private _inversedSensibility;
  94227. private _joystickPointerID;
  94228. private _joystickColor;
  94229. private _joystickPointerPos;
  94230. private _joystickPreviousPointerPos;
  94231. private _joystickPointerStartPos;
  94232. private _deltaJoystickVector;
  94233. private _leftJoystick;
  94234. private _touches;
  94235. private _onPointerDownHandlerRef;
  94236. private _onPointerMoveHandlerRef;
  94237. private _onPointerUpHandlerRef;
  94238. private _onResize;
  94239. /**
  94240. * Creates a new virtual joystick
  94241. * @param leftJoystick defines that the joystick is for left hand (false by default)
  94242. */
  94243. constructor(leftJoystick?: boolean);
  94244. /**
  94245. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  94246. * @param newJoystickSensibility defines the new sensibility
  94247. */
  94248. setJoystickSensibility(newJoystickSensibility: number): void;
  94249. private _onPointerDown;
  94250. private _onPointerMove;
  94251. private _onPointerUp;
  94252. /**
  94253. * Change the color of the virtual joystick
  94254. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  94255. */
  94256. setJoystickColor(newColor: string): void;
  94257. /**
  94258. * Defines a callback to call when the joystick is touched
  94259. * @param action defines the callback
  94260. */
  94261. setActionOnTouch(action: () => any): void;
  94262. /**
  94263. * Defines which axis you'd like to control for left & right
  94264. * @param axis defines the axis to use
  94265. */
  94266. setAxisForLeftRight(axis: JoystickAxis): void;
  94267. /**
  94268. * Defines which axis you'd like to control for up & down
  94269. * @param axis defines the axis to use
  94270. */
  94271. setAxisForUpDown(axis: JoystickAxis): void;
  94272. private _drawVirtualJoystick;
  94273. /**
  94274. * Release internal HTML canvas
  94275. */
  94276. releaseCanvas(): void;
  94277. }
  94278. }
  94279. declare module BABYLON {
  94280. interface FreeCameraInputsManager {
  94281. /**
  94282. * Add virtual joystick input support to the input manager.
  94283. * @returns the current input manager
  94284. */
  94285. addVirtualJoystick(): FreeCameraInputsManager;
  94286. }
  94287. /**
  94288. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  94289. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94290. */
  94291. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  94292. /**
  94293. * Defines the camera the input is attached to.
  94294. */
  94295. camera: FreeCamera;
  94296. private _leftjoystick;
  94297. private _rightjoystick;
  94298. /**
  94299. * Gets the left stick of the virtual joystick.
  94300. * @returns The virtual Joystick
  94301. */
  94302. getLeftJoystick(): VirtualJoystick;
  94303. /**
  94304. * Gets the right stick of the virtual joystick.
  94305. * @returns The virtual Joystick
  94306. */
  94307. getRightJoystick(): VirtualJoystick;
  94308. /**
  94309. * Update the current camera state depending on the inputs that have been used this frame.
  94310. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94311. */
  94312. checkInputs(): void;
  94313. /**
  94314. * Attach the input controls to a specific dom element to get the input from.
  94315. * @param element Defines the element the controls should be listened from
  94316. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94317. */
  94318. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94319. /**
  94320. * Detach the current controls from the specified dom element.
  94321. * @param element Defines the element to stop listening the inputs from
  94322. */
  94323. detachControl(element: Nullable<HTMLElement>): void;
  94324. /**
  94325. * Gets the class name of the current intput.
  94326. * @returns the class name
  94327. */
  94328. getClassName(): string;
  94329. /**
  94330. * Get the friendly name associated with the input class.
  94331. * @returns the input friendly name
  94332. */
  94333. getSimpleName(): string;
  94334. }
  94335. }
  94336. declare module BABYLON {
  94337. /**
  94338. * This represents a FPS type of camera controlled by touch.
  94339. * This is like a universal camera minus the Gamepad controls.
  94340. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94341. */
  94342. export class TouchCamera extends FreeCamera {
  94343. /**
  94344. * Defines the touch sensibility for rotation.
  94345. * The higher the faster.
  94346. */
  94347. touchAngularSensibility: number;
  94348. /**
  94349. * Defines the touch sensibility for move.
  94350. * The higher the faster.
  94351. */
  94352. touchMoveSensibility: number;
  94353. /**
  94354. * Instantiates a new touch camera.
  94355. * This represents a FPS type of camera controlled by touch.
  94356. * This is like a universal camera minus the Gamepad controls.
  94357. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94358. * @param name Define the name of the camera in the scene
  94359. * @param position Define the start position of the camera in the scene
  94360. * @param scene Define the scene the camera belongs to
  94361. */
  94362. constructor(name: string, position: Vector3, scene: Scene);
  94363. /**
  94364. * Gets the current object class name.
  94365. * @return the class name
  94366. */
  94367. getClassName(): string;
  94368. /** @hidden */
  94369. _setupInputs(): void;
  94370. }
  94371. }
  94372. declare module BABYLON {
  94373. /**
  94374. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  94375. * being tilted forward or back and left or right.
  94376. */
  94377. export class DeviceOrientationCamera extends FreeCamera {
  94378. private _initialQuaternion;
  94379. private _quaternionCache;
  94380. /**
  94381. * Creates a new device orientation camera
  94382. * @param name The name of the camera
  94383. * @param position The start position camera
  94384. * @param scene The scene the camera belongs to
  94385. */
  94386. constructor(name: string, position: Vector3, scene: Scene);
  94387. /**
  94388. * Gets the current instance class name ("DeviceOrientationCamera").
  94389. * This helps avoiding instanceof at run time.
  94390. * @returns the class name
  94391. */
  94392. getClassName(): string;
  94393. /**
  94394. * @hidden
  94395. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  94396. */
  94397. _checkInputs(): void;
  94398. /**
  94399. * Reset the camera to its default orientation on the specified axis only.
  94400. * @param axis The axis to reset
  94401. */
  94402. resetToCurrentRotation(axis?: Axis): void;
  94403. }
  94404. }
  94405. declare module BABYLON {
  94406. /**
  94407. * 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,
  94408. * which still works and will still be found in many Playgrounds.
  94409. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94410. */
  94411. export class UniversalCamera extends TouchCamera {
  94412. /**
  94413. * Defines the gamepad rotation sensiblity.
  94414. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  94415. */
  94416. gamepadAngularSensibility: number;
  94417. /**
  94418. * Defines the gamepad move sensiblity.
  94419. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  94420. */
  94421. gamepadMoveSensibility: number;
  94422. /**
  94423. * 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,
  94424. * which still works and will still be found in many Playgrounds.
  94425. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94426. * @param name Define the name of the camera in the scene
  94427. * @param position Define the start position of the camera in the scene
  94428. * @param scene Define the scene the camera belongs to
  94429. */
  94430. constructor(name: string, position: Vector3, scene: Scene);
  94431. /**
  94432. * Gets the current object class name.
  94433. * @return the class name
  94434. */
  94435. getClassName(): string;
  94436. }
  94437. }
  94438. declare module BABYLON {
  94439. /**
  94440. * This represents a FPS type of camera. This is only here for back compat purpose.
  94441. * Please use the UniversalCamera instead as both are identical.
  94442. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94443. */
  94444. export class GamepadCamera extends UniversalCamera {
  94445. /**
  94446. * Instantiates a new Gamepad Camera
  94447. * This represents a FPS type of camera. This is only here for back compat purpose.
  94448. * Please use the UniversalCamera instead as both are identical.
  94449. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94450. * @param name Define the name of the camera in the scene
  94451. * @param position Define the start position of the camera in the scene
  94452. * @param scene Define the scene the camera belongs to
  94453. */
  94454. constructor(name: string, position: Vector3, scene: Scene);
  94455. /**
  94456. * Gets the current object class name.
  94457. * @return the class name
  94458. */
  94459. getClassName(): string;
  94460. }
  94461. }
  94462. declare module BABYLON {
  94463. /** @hidden */
  94464. export var passPixelShader: {
  94465. name: string;
  94466. shader: string;
  94467. };
  94468. }
  94469. declare module BABYLON {
  94470. /** @hidden */
  94471. export var passCubePixelShader: {
  94472. name: string;
  94473. shader: string;
  94474. };
  94475. }
  94476. declare module BABYLON {
  94477. /**
  94478. * PassPostProcess which produces an output the same as it's input
  94479. */
  94480. export class PassPostProcess extends PostProcess {
  94481. /**
  94482. * Creates the PassPostProcess
  94483. * @param name The name of the effect.
  94484. * @param options The required width/height ratio to downsize to before computing the render pass.
  94485. * @param camera The camera to apply the render pass to.
  94486. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94487. * @param engine The engine which the post process will be applied. (default: current engine)
  94488. * @param reusable If the post process can be reused on the same frame. (default: false)
  94489. * @param textureType The type of texture to be used when performing the post processing.
  94490. * @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)
  94491. */
  94492. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  94493. }
  94494. /**
  94495. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  94496. */
  94497. export class PassCubePostProcess extends PostProcess {
  94498. private _face;
  94499. /**
  94500. * Gets or sets the cube face to display.
  94501. * * 0 is +X
  94502. * * 1 is -X
  94503. * * 2 is +Y
  94504. * * 3 is -Y
  94505. * * 4 is +Z
  94506. * * 5 is -Z
  94507. */
  94508. face: number;
  94509. /**
  94510. * Creates the PassCubePostProcess
  94511. * @param name The name of the effect.
  94512. * @param options The required width/height ratio to downsize to before computing the render pass.
  94513. * @param camera The camera to apply the render pass to.
  94514. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94515. * @param engine The engine which the post process will be applied. (default: current engine)
  94516. * @param reusable If the post process can be reused on the same frame. (default: false)
  94517. * @param textureType The type of texture to be used when performing the post processing.
  94518. * @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)
  94519. */
  94520. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  94521. }
  94522. }
  94523. declare module BABYLON {
  94524. /** @hidden */
  94525. export var anaglyphPixelShader: {
  94526. name: string;
  94527. shader: string;
  94528. };
  94529. }
  94530. declare module BABYLON {
  94531. /**
  94532. * Postprocess used to generate anaglyphic rendering
  94533. */
  94534. export class AnaglyphPostProcess extends PostProcess {
  94535. private _passedProcess;
  94536. /**
  94537. * Creates a new AnaglyphPostProcess
  94538. * @param name defines postprocess name
  94539. * @param options defines creation options or target ratio scale
  94540. * @param rigCameras defines cameras using this postprocess
  94541. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  94542. * @param engine defines hosting engine
  94543. * @param reusable defines if the postprocess will be reused multiple times per frame
  94544. */
  94545. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  94546. }
  94547. }
  94548. declare module BABYLON {
  94549. /**
  94550. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  94551. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94552. */
  94553. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  94554. /**
  94555. * Creates a new AnaglyphArcRotateCamera
  94556. * @param name defines camera name
  94557. * @param alpha defines alpha angle (in radians)
  94558. * @param beta defines beta angle (in radians)
  94559. * @param radius defines radius
  94560. * @param target defines camera target
  94561. * @param interaxialDistance defines distance between each color axis
  94562. * @param scene defines the hosting scene
  94563. */
  94564. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  94565. /**
  94566. * Gets camera class name
  94567. * @returns AnaglyphArcRotateCamera
  94568. */
  94569. getClassName(): string;
  94570. }
  94571. }
  94572. declare module BABYLON {
  94573. /**
  94574. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  94575. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94576. */
  94577. export class AnaglyphFreeCamera extends FreeCamera {
  94578. /**
  94579. * Creates a new AnaglyphFreeCamera
  94580. * @param name defines camera name
  94581. * @param position defines initial position
  94582. * @param interaxialDistance defines distance between each color axis
  94583. * @param scene defines the hosting scene
  94584. */
  94585. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  94586. /**
  94587. * Gets camera class name
  94588. * @returns AnaglyphFreeCamera
  94589. */
  94590. getClassName(): string;
  94591. }
  94592. }
  94593. declare module BABYLON {
  94594. /**
  94595. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  94596. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94597. */
  94598. export class AnaglyphGamepadCamera extends GamepadCamera {
  94599. /**
  94600. * Creates a new AnaglyphGamepadCamera
  94601. * @param name defines camera name
  94602. * @param position defines initial position
  94603. * @param interaxialDistance defines distance between each color axis
  94604. * @param scene defines the hosting scene
  94605. */
  94606. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  94607. /**
  94608. * Gets camera class name
  94609. * @returns AnaglyphGamepadCamera
  94610. */
  94611. getClassName(): string;
  94612. }
  94613. }
  94614. declare module BABYLON {
  94615. /**
  94616. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  94617. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94618. */
  94619. export class AnaglyphUniversalCamera extends UniversalCamera {
  94620. /**
  94621. * Creates a new AnaglyphUniversalCamera
  94622. * @param name defines camera name
  94623. * @param position defines initial position
  94624. * @param interaxialDistance defines distance between each color axis
  94625. * @param scene defines the hosting scene
  94626. */
  94627. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  94628. /**
  94629. * Gets camera class name
  94630. * @returns AnaglyphUniversalCamera
  94631. */
  94632. getClassName(): string;
  94633. }
  94634. }
  94635. declare module BABYLON {
  94636. /** @hidden */
  94637. export var stereoscopicInterlacePixelShader: {
  94638. name: string;
  94639. shader: string;
  94640. };
  94641. }
  94642. declare module BABYLON {
  94643. /**
  94644. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  94645. */
  94646. export class StereoscopicInterlacePostProcess extends PostProcess {
  94647. private _stepSize;
  94648. private _passedProcess;
  94649. /**
  94650. * Initializes a StereoscopicInterlacePostProcess
  94651. * @param name The name of the effect.
  94652. * @param rigCameras The rig cameras to be appled to the post process
  94653. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  94654. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94655. * @param engine The engine which the post process will be applied. (default: current engine)
  94656. * @param reusable If the post process can be reused on the same frame. (default: false)
  94657. */
  94658. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  94659. }
  94660. }
  94661. declare module BABYLON {
  94662. /**
  94663. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  94664. * @see http://doc.babylonjs.com/features/cameras
  94665. */
  94666. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  94667. /**
  94668. * Creates a new StereoscopicArcRotateCamera
  94669. * @param name defines camera name
  94670. * @param alpha defines alpha angle (in radians)
  94671. * @param beta defines beta angle (in radians)
  94672. * @param radius defines radius
  94673. * @param target defines camera target
  94674. * @param interaxialDistance defines distance between each color axis
  94675. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94676. * @param scene defines the hosting scene
  94677. */
  94678. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94679. /**
  94680. * Gets camera class name
  94681. * @returns StereoscopicArcRotateCamera
  94682. */
  94683. getClassName(): string;
  94684. }
  94685. }
  94686. declare module BABYLON {
  94687. /**
  94688. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  94689. * @see http://doc.babylonjs.com/features/cameras
  94690. */
  94691. export class StereoscopicFreeCamera extends FreeCamera {
  94692. /**
  94693. * Creates a new StereoscopicFreeCamera
  94694. * @param name defines camera name
  94695. * @param position defines initial position
  94696. * @param interaxialDistance defines distance between each color axis
  94697. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94698. * @param scene defines the hosting scene
  94699. */
  94700. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94701. /**
  94702. * Gets camera class name
  94703. * @returns StereoscopicFreeCamera
  94704. */
  94705. getClassName(): string;
  94706. }
  94707. }
  94708. declare module BABYLON {
  94709. /**
  94710. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  94711. * @see http://doc.babylonjs.com/features/cameras
  94712. */
  94713. export class StereoscopicGamepadCamera extends GamepadCamera {
  94714. /**
  94715. * Creates a new StereoscopicGamepadCamera
  94716. * @param name defines camera name
  94717. * @param position defines initial position
  94718. * @param interaxialDistance defines distance between each color axis
  94719. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94720. * @param scene defines the hosting scene
  94721. */
  94722. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94723. /**
  94724. * Gets camera class name
  94725. * @returns StereoscopicGamepadCamera
  94726. */
  94727. getClassName(): string;
  94728. }
  94729. }
  94730. declare module BABYLON {
  94731. /**
  94732. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  94733. * @see http://doc.babylonjs.com/features/cameras
  94734. */
  94735. export class StereoscopicUniversalCamera extends UniversalCamera {
  94736. /**
  94737. * Creates a new StereoscopicUniversalCamera
  94738. * @param name defines camera name
  94739. * @param position defines initial position
  94740. * @param interaxialDistance defines distance between each color axis
  94741. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94742. * @param scene defines the hosting scene
  94743. */
  94744. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94745. /**
  94746. * Gets camera class name
  94747. * @returns StereoscopicUniversalCamera
  94748. */
  94749. getClassName(): string;
  94750. }
  94751. }
  94752. declare module BABYLON {
  94753. /**
  94754. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  94755. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  94756. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  94757. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  94758. */
  94759. export class VirtualJoysticksCamera extends FreeCamera {
  94760. /**
  94761. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  94762. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  94763. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  94764. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  94765. * @param name Define the name of the camera in the scene
  94766. * @param position Define the start position of the camera in the scene
  94767. * @param scene Define the scene the camera belongs to
  94768. */
  94769. constructor(name: string, position: Vector3, scene: Scene);
  94770. /**
  94771. * Gets the current object class name.
  94772. * @return the class name
  94773. */
  94774. getClassName(): string;
  94775. }
  94776. }
  94777. declare module BABYLON {
  94778. /**
  94779. * This represents all the required metrics to create a VR camera.
  94780. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  94781. */
  94782. export class VRCameraMetrics {
  94783. /**
  94784. * Define the horizontal resolution off the screen.
  94785. */
  94786. hResolution: number;
  94787. /**
  94788. * Define the vertical resolution off the screen.
  94789. */
  94790. vResolution: number;
  94791. /**
  94792. * Define the horizontal screen size.
  94793. */
  94794. hScreenSize: number;
  94795. /**
  94796. * Define the vertical screen size.
  94797. */
  94798. vScreenSize: number;
  94799. /**
  94800. * Define the vertical screen center position.
  94801. */
  94802. vScreenCenter: number;
  94803. /**
  94804. * Define the distance of the eyes to the screen.
  94805. */
  94806. eyeToScreenDistance: number;
  94807. /**
  94808. * Define the distance between both lenses
  94809. */
  94810. lensSeparationDistance: number;
  94811. /**
  94812. * Define the distance between both viewer's eyes.
  94813. */
  94814. interpupillaryDistance: number;
  94815. /**
  94816. * Define the distortion factor of the VR postprocess.
  94817. * Please, touch with care.
  94818. */
  94819. distortionK: number[];
  94820. /**
  94821. * Define the chromatic aberration correction factors for the VR post process.
  94822. */
  94823. chromaAbCorrection: number[];
  94824. /**
  94825. * Define the scale factor of the post process.
  94826. * The smaller the better but the slower.
  94827. */
  94828. postProcessScaleFactor: number;
  94829. /**
  94830. * Define an offset for the lens center.
  94831. */
  94832. lensCenterOffset: number;
  94833. /**
  94834. * Define if the current vr camera should compensate the distortion of the lense or not.
  94835. */
  94836. compensateDistortion: boolean;
  94837. /**
  94838. * Gets the rendering aspect ratio based on the provided resolutions.
  94839. */
  94840. readonly aspectRatio: number;
  94841. /**
  94842. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  94843. */
  94844. readonly aspectRatioFov: number;
  94845. /**
  94846. * @hidden
  94847. */
  94848. readonly leftHMatrix: Matrix;
  94849. /**
  94850. * @hidden
  94851. */
  94852. readonly rightHMatrix: Matrix;
  94853. /**
  94854. * @hidden
  94855. */
  94856. readonly leftPreViewMatrix: Matrix;
  94857. /**
  94858. * @hidden
  94859. */
  94860. readonly rightPreViewMatrix: Matrix;
  94861. /**
  94862. * Get the default VRMetrics based on the most generic setup.
  94863. * @returns the default vr metrics
  94864. */
  94865. static GetDefault(): VRCameraMetrics;
  94866. }
  94867. }
  94868. declare module BABYLON {
  94869. /** @hidden */
  94870. export var vrDistortionCorrectionPixelShader: {
  94871. name: string;
  94872. shader: string;
  94873. };
  94874. }
  94875. declare module BABYLON {
  94876. /**
  94877. * VRDistortionCorrectionPostProcess used for mobile VR
  94878. */
  94879. export class VRDistortionCorrectionPostProcess extends PostProcess {
  94880. private _isRightEye;
  94881. private _distortionFactors;
  94882. private _postProcessScaleFactor;
  94883. private _lensCenterOffset;
  94884. private _scaleIn;
  94885. private _scaleFactor;
  94886. private _lensCenter;
  94887. /**
  94888. * Initializes the VRDistortionCorrectionPostProcess
  94889. * @param name The name of the effect.
  94890. * @param camera The camera to apply the render pass to.
  94891. * @param isRightEye If this is for the right eye distortion
  94892. * @param vrMetrics All the required metrics for the VR camera
  94893. */
  94894. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  94895. }
  94896. }
  94897. declare module BABYLON {
  94898. /**
  94899. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  94900. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  94901. */
  94902. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  94903. /**
  94904. * Creates a new VRDeviceOrientationArcRotateCamera
  94905. * @param name defines camera name
  94906. * @param alpha defines the camera rotation along the logitudinal axis
  94907. * @param beta defines the camera rotation along the latitudinal axis
  94908. * @param radius defines the camera distance from its target
  94909. * @param target defines the camera target
  94910. * @param scene defines the scene the camera belongs to
  94911. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  94912. * @param vrCameraMetrics defines the vr metrics associated to the camera
  94913. */
  94914. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  94915. /**
  94916. * Gets camera class name
  94917. * @returns VRDeviceOrientationArcRotateCamera
  94918. */
  94919. getClassName(): string;
  94920. }
  94921. }
  94922. declare module BABYLON {
  94923. /**
  94924. * Camera used to simulate VR rendering (based on FreeCamera)
  94925. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  94926. */
  94927. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  94928. /**
  94929. * Creates a new VRDeviceOrientationFreeCamera
  94930. * @param name defines camera name
  94931. * @param position defines the start position of the camera
  94932. * @param scene defines the scene the camera belongs to
  94933. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  94934. * @param vrCameraMetrics defines the vr metrics associated to the camera
  94935. */
  94936. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  94937. /**
  94938. * Gets camera class name
  94939. * @returns VRDeviceOrientationFreeCamera
  94940. */
  94941. getClassName(): string;
  94942. }
  94943. }
  94944. declare module BABYLON {
  94945. /**
  94946. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  94947. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  94948. */
  94949. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  94950. /**
  94951. * Creates a new VRDeviceOrientationGamepadCamera
  94952. * @param name defines camera name
  94953. * @param position defines the start position of the camera
  94954. * @param scene defines the scene the camera belongs to
  94955. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  94956. * @param vrCameraMetrics defines the vr metrics associated to the camera
  94957. */
  94958. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  94959. /**
  94960. * Gets camera class name
  94961. * @returns VRDeviceOrientationGamepadCamera
  94962. */
  94963. getClassName(): string;
  94964. }
  94965. }
  94966. declare module BABYLON {
  94967. /**
  94968. * Defines supported buttons for XBox360 compatible gamepads
  94969. */
  94970. export enum Xbox360Button {
  94971. /** A */
  94972. A = 0,
  94973. /** B */
  94974. B = 1,
  94975. /** X */
  94976. X = 2,
  94977. /** Y */
  94978. Y = 3,
  94979. /** Start */
  94980. Start = 4,
  94981. /** Back */
  94982. Back = 5,
  94983. /** Left button */
  94984. LB = 6,
  94985. /** Right button */
  94986. RB = 7,
  94987. /** Left stick */
  94988. LeftStick = 8,
  94989. /** Right stick */
  94990. RightStick = 9
  94991. }
  94992. /** Defines values for XBox360 DPad */
  94993. export enum Xbox360Dpad {
  94994. /** Up */
  94995. Up = 0,
  94996. /** Down */
  94997. Down = 1,
  94998. /** Left */
  94999. Left = 2,
  95000. /** Right */
  95001. Right = 3
  95002. }
  95003. /**
  95004. * Defines a XBox360 gamepad
  95005. */
  95006. export class Xbox360Pad extends Gamepad {
  95007. private _leftTrigger;
  95008. private _rightTrigger;
  95009. private _onlefttriggerchanged;
  95010. private _onrighttriggerchanged;
  95011. private _onbuttondown;
  95012. private _onbuttonup;
  95013. private _ondpaddown;
  95014. private _ondpadup;
  95015. /** Observable raised when a button is pressed */
  95016. onButtonDownObservable: Observable<Xbox360Button>;
  95017. /** Observable raised when a button is released */
  95018. onButtonUpObservable: Observable<Xbox360Button>;
  95019. /** Observable raised when a pad is pressed */
  95020. onPadDownObservable: Observable<Xbox360Dpad>;
  95021. /** Observable raised when a pad is released */
  95022. onPadUpObservable: Observable<Xbox360Dpad>;
  95023. private _buttonA;
  95024. private _buttonB;
  95025. private _buttonX;
  95026. private _buttonY;
  95027. private _buttonBack;
  95028. private _buttonStart;
  95029. private _buttonLB;
  95030. private _buttonRB;
  95031. private _buttonLeftStick;
  95032. private _buttonRightStick;
  95033. private _dPadUp;
  95034. private _dPadDown;
  95035. private _dPadLeft;
  95036. private _dPadRight;
  95037. private _isXboxOnePad;
  95038. /**
  95039. * Creates a new XBox360 gamepad object
  95040. * @param id defines the id of this gamepad
  95041. * @param index defines its index
  95042. * @param gamepad defines the internal HTML gamepad object
  95043. * @param xboxOne defines if it is a XBox One gamepad
  95044. */
  95045. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  95046. /**
  95047. * Defines the callback to call when left trigger is pressed
  95048. * @param callback defines the callback to use
  95049. */
  95050. onlefttriggerchanged(callback: (value: number) => void): void;
  95051. /**
  95052. * Defines the callback to call when right trigger is pressed
  95053. * @param callback defines the callback to use
  95054. */
  95055. onrighttriggerchanged(callback: (value: number) => void): void;
  95056. /**
  95057. * Gets the left trigger value
  95058. */
  95059. /**
  95060. * Sets the left trigger value
  95061. */
  95062. leftTrigger: number;
  95063. /**
  95064. * Gets the right trigger value
  95065. */
  95066. /**
  95067. * Sets the right trigger value
  95068. */
  95069. rightTrigger: number;
  95070. /**
  95071. * Defines the callback to call when a button is pressed
  95072. * @param callback defines the callback to use
  95073. */
  95074. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  95075. /**
  95076. * Defines the callback to call when a button is released
  95077. * @param callback defines the callback to use
  95078. */
  95079. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  95080. /**
  95081. * Defines the callback to call when a pad is pressed
  95082. * @param callback defines the callback to use
  95083. */
  95084. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  95085. /**
  95086. * Defines the callback to call when a pad is released
  95087. * @param callback defines the callback to use
  95088. */
  95089. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  95090. private _setButtonValue;
  95091. private _setDPadValue;
  95092. /**
  95093. * Gets the value of the `A` button
  95094. */
  95095. /**
  95096. * Sets the value of the `A` button
  95097. */
  95098. buttonA: number;
  95099. /**
  95100. * Gets the value of the `B` button
  95101. */
  95102. /**
  95103. * Sets the value of the `B` button
  95104. */
  95105. buttonB: number;
  95106. /**
  95107. * Gets the value of the `X` button
  95108. */
  95109. /**
  95110. * Sets the value of the `X` button
  95111. */
  95112. buttonX: number;
  95113. /**
  95114. * Gets the value of the `Y` button
  95115. */
  95116. /**
  95117. * Sets the value of the `Y` button
  95118. */
  95119. buttonY: number;
  95120. /**
  95121. * Gets the value of the `Start` button
  95122. */
  95123. /**
  95124. * Sets the value of the `Start` button
  95125. */
  95126. buttonStart: number;
  95127. /**
  95128. * Gets the value of the `Back` button
  95129. */
  95130. /**
  95131. * Sets the value of the `Back` button
  95132. */
  95133. buttonBack: number;
  95134. /**
  95135. * Gets the value of the `Left` button
  95136. */
  95137. /**
  95138. * Sets the value of the `Left` button
  95139. */
  95140. buttonLB: number;
  95141. /**
  95142. * Gets the value of the `Right` button
  95143. */
  95144. /**
  95145. * Sets the value of the `Right` button
  95146. */
  95147. buttonRB: number;
  95148. /**
  95149. * Gets the value of the Left joystick
  95150. */
  95151. /**
  95152. * Sets the value of the Left joystick
  95153. */
  95154. buttonLeftStick: number;
  95155. /**
  95156. * Gets the value of the Right joystick
  95157. */
  95158. /**
  95159. * Sets the value of the Right joystick
  95160. */
  95161. buttonRightStick: number;
  95162. /**
  95163. * Gets the value of D-pad up
  95164. */
  95165. /**
  95166. * Sets the value of D-pad up
  95167. */
  95168. dPadUp: number;
  95169. /**
  95170. * Gets the value of D-pad down
  95171. */
  95172. /**
  95173. * Sets the value of D-pad down
  95174. */
  95175. dPadDown: number;
  95176. /**
  95177. * Gets the value of D-pad left
  95178. */
  95179. /**
  95180. * Sets the value of D-pad left
  95181. */
  95182. dPadLeft: number;
  95183. /**
  95184. * Gets the value of D-pad right
  95185. */
  95186. /**
  95187. * Sets the value of D-pad right
  95188. */
  95189. dPadRight: number;
  95190. /**
  95191. * Force the gamepad to synchronize with device values
  95192. */
  95193. update(): void;
  95194. /**
  95195. * Disposes the gamepad
  95196. */
  95197. dispose(): void;
  95198. }
  95199. }
  95200. declare module BABYLON {
  95201. /**
  95202. * Base class of materials working in push mode in babylon JS
  95203. * @hidden
  95204. */
  95205. export class PushMaterial extends Material {
  95206. protected _activeEffect: Effect;
  95207. protected _normalMatrix: Matrix;
  95208. /**
  95209. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  95210. * This means that the material can keep using a previous shader while a new one is being compiled.
  95211. * This is mostly used when shader parallel compilation is supported (true by default)
  95212. */
  95213. allowShaderHotSwapping: boolean;
  95214. constructor(name: string, scene: Scene);
  95215. getEffect(): Effect;
  95216. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  95217. /**
  95218. * Binds the given world matrix to the active effect
  95219. *
  95220. * @param world the matrix to bind
  95221. */
  95222. bindOnlyWorldMatrix(world: Matrix): void;
  95223. /**
  95224. * Binds the given normal matrix to the active effect
  95225. *
  95226. * @param normalMatrix the matrix to bind
  95227. */
  95228. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  95229. bind(world: Matrix, mesh?: Mesh): void;
  95230. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  95231. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  95232. }
  95233. }
  95234. declare module BABYLON {
  95235. /**
  95236. * This groups all the flags used to control the materials channel.
  95237. */
  95238. export class MaterialFlags {
  95239. private static _DiffuseTextureEnabled;
  95240. /**
  95241. * Are diffuse textures enabled in the application.
  95242. */
  95243. static DiffuseTextureEnabled: boolean;
  95244. private static _AmbientTextureEnabled;
  95245. /**
  95246. * Are ambient textures enabled in the application.
  95247. */
  95248. static AmbientTextureEnabled: boolean;
  95249. private static _OpacityTextureEnabled;
  95250. /**
  95251. * Are opacity textures enabled in the application.
  95252. */
  95253. static OpacityTextureEnabled: boolean;
  95254. private static _ReflectionTextureEnabled;
  95255. /**
  95256. * Are reflection textures enabled in the application.
  95257. */
  95258. static ReflectionTextureEnabled: boolean;
  95259. private static _EmissiveTextureEnabled;
  95260. /**
  95261. * Are emissive textures enabled in the application.
  95262. */
  95263. static EmissiveTextureEnabled: boolean;
  95264. private static _SpecularTextureEnabled;
  95265. /**
  95266. * Are specular textures enabled in the application.
  95267. */
  95268. static SpecularTextureEnabled: boolean;
  95269. private static _BumpTextureEnabled;
  95270. /**
  95271. * Are bump textures enabled in the application.
  95272. */
  95273. static BumpTextureEnabled: boolean;
  95274. private static _LightmapTextureEnabled;
  95275. /**
  95276. * Are lightmap textures enabled in the application.
  95277. */
  95278. static LightmapTextureEnabled: boolean;
  95279. private static _RefractionTextureEnabled;
  95280. /**
  95281. * Are refraction textures enabled in the application.
  95282. */
  95283. static RefractionTextureEnabled: boolean;
  95284. private static _ColorGradingTextureEnabled;
  95285. /**
  95286. * Are color grading textures enabled in the application.
  95287. */
  95288. static ColorGradingTextureEnabled: boolean;
  95289. private static _FresnelEnabled;
  95290. /**
  95291. * Are fresnels enabled in the application.
  95292. */
  95293. static FresnelEnabled: boolean;
  95294. private static _ClearCoatTextureEnabled;
  95295. /**
  95296. * Are clear coat textures enabled in the application.
  95297. */
  95298. static ClearCoatTextureEnabled: boolean;
  95299. private static _ClearCoatBumpTextureEnabled;
  95300. /**
  95301. * Are clear coat bump textures enabled in the application.
  95302. */
  95303. static ClearCoatBumpTextureEnabled: boolean;
  95304. private static _ClearCoatTintTextureEnabled;
  95305. /**
  95306. * Are clear coat tint textures enabled in the application.
  95307. */
  95308. static ClearCoatTintTextureEnabled: boolean;
  95309. private static _SheenTextureEnabled;
  95310. /**
  95311. * Are sheen textures enabled in the application.
  95312. */
  95313. static SheenTextureEnabled: boolean;
  95314. private static _AnisotropicTextureEnabled;
  95315. /**
  95316. * Are anisotropic textures enabled in the application.
  95317. */
  95318. static AnisotropicTextureEnabled: boolean;
  95319. }
  95320. }
  95321. declare module BABYLON {
  95322. /** @hidden */
  95323. export var defaultFragmentDeclaration: {
  95324. name: string;
  95325. shader: string;
  95326. };
  95327. }
  95328. declare module BABYLON {
  95329. /** @hidden */
  95330. export var defaultUboDeclaration: {
  95331. name: string;
  95332. shader: string;
  95333. };
  95334. }
  95335. declare module BABYLON {
  95336. /** @hidden */
  95337. export var lightFragmentDeclaration: {
  95338. name: string;
  95339. shader: string;
  95340. };
  95341. }
  95342. declare module BABYLON {
  95343. /** @hidden */
  95344. export var lightUboDeclaration: {
  95345. name: string;
  95346. shader: string;
  95347. };
  95348. }
  95349. declare module BABYLON {
  95350. /** @hidden */
  95351. export var lightsFragmentFunctions: {
  95352. name: string;
  95353. shader: string;
  95354. };
  95355. }
  95356. declare module BABYLON {
  95357. /** @hidden */
  95358. export var shadowsFragmentFunctions: {
  95359. name: string;
  95360. shader: string;
  95361. };
  95362. }
  95363. declare module BABYLON {
  95364. /** @hidden */
  95365. export var fresnelFunction: {
  95366. name: string;
  95367. shader: string;
  95368. };
  95369. }
  95370. declare module BABYLON {
  95371. /** @hidden */
  95372. export var reflectionFunction: {
  95373. name: string;
  95374. shader: string;
  95375. };
  95376. }
  95377. declare module BABYLON {
  95378. /** @hidden */
  95379. export var bumpFragmentFunctions: {
  95380. name: string;
  95381. shader: string;
  95382. };
  95383. }
  95384. declare module BABYLON {
  95385. /** @hidden */
  95386. export var logDepthDeclaration: {
  95387. name: string;
  95388. shader: string;
  95389. };
  95390. }
  95391. declare module BABYLON {
  95392. /** @hidden */
  95393. export var bumpFragment: {
  95394. name: string;
  95395. shader: string;
  95396. };
  95397. }
  95398. declare module BABYLON {
  95399. /** @hidden */
  95400. export var depthPrePass: {
  95401. name: string;
  95402. shader: string;
  95403. };
  95404. }
  95405. declare module BABYLON {
  95406. /** @hidden */
  95407. export var lightFragment: {
  95408. name: string;
  95409. shader: string;
  95410. };
  95411. }
  95412. declare module BABYLON {
  95413. /** @hidden */
  95414. export var logDepthFragment: {
  95415. name: string;
  95416. shader: string;
  95417. };
  95418. }
  95419. declare module BABYLON {
  95420. /** @hidden */
  95421. export var defaultPixelShader: {
  95422. name: string;
  95423. shader: string;
  95424. };
  95425. }
  95426. declare module BABYLON {
  95427. /** @hidden */
  95428. export var defaultVertexDeclaration: {
  95429. name: string;
  95430. shader: string;
  95431. };
  95432. }
  95433. declare module BABYLON {
  95434. /** @hidden */
  95435. export var bumpVertexDeclaration: {
  95436. name: string;
  95437. shader: string;
  95438. };
  95439. }
  95440. declare module BABYLON {
  95441. /** @hidden */
  95442. export var bumpVertex: {
  95443. name: string;
  95444. shader: string;
  95445. };
  95446. }
  95447. declare module BABYLON {
  95448. /** @hidden */
  95449. export var fogVertex: {
  95450. name: string;
  95451. shader: string;
  95452. };
  95453. }
  95454. declare module BABYLON {
  95455. /** @hidden */
  95456. export var shadowsVertex: {
  95457. name: string;
  95458. shader: string;
  95459. };
  95460. }
  95461. declare module BABYLON {
  95462. /** @hidden */
  95463. export var pointCloudVertex: {
  95464. name: string;
  95465. shader: string;
  95466. };
  95467. }
  95468. declare module BABYLON {
  95469. /** @hidden */
  95470. export var logDepthVertex: {
  95471. name: string;
  95472. shader: string;
  95473. };
  95474. }
  95475. declare module BABYLON {
  95476. /** @hidden */
  95477. export var defaultVertexShader: {
  95478. name: string;
  95479. shader: string;
  95480. };
  95481. }
  95482. declare module BABYLON {
  95483. /** @hidden */
  95484. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  95485. MAINUV1: boolean;
  95486. MAINUV2: boolean;
  95487. DIFFUSE: boolean;
  95488. DIFFUSEDIRECTUV: number;
  95489. AMBIENT: boolean;
  95490. AMBIENTDIRECTUV: number;
  95491. OPACITY: boolean;
  95492. OPACITYDIRECTUV: number;
  95493. OPACITYRGB: boolean;
  95494. REFLECTION: boolean;
  95495. EMISSIVE: boolean;
  95496. EMISSIVEDIRECTUV: number;
  95497. SPECULAR: boolean;
  95498. SPECULARDIRECTUV: number;
  95499. BUMP: boolean;
  95500. BUMPDIRECTUV: number;
  95501. PARALLAX: boolean;
  95502. PARALLAXOCCLUSION: boolean;
  95503. SPECULAROVERALPHA: boolean;
  95504. CLIPPLANE: boolean;
  95505. CLIPPLANE2: boolean;
  95506. CLIPPLANE3: boolean;
  95507. CLIPPLANE4: boolean;
  95508. ALPHATEST: boolean;
  95509. DEPTHPREPASS: boolean;
  95510. ALPHAFROMDIFFUSE: boolean;
  95511. POINTSIZE: boolean;
  95512. FOG: boolean;
  95513. SPECULARTERM: boolean;
  95514. DIFFUSEFRESNEL: boolean;
  95515. OPACITYFRESNEL: boolean;
  95516. REFLECTIONFRESNEL: boolean;
  95517. REFRACTIONFRESNEL: boolean;
  95518. EMISSIVEFRESNEL: boolean;
  95519. FRESNEL: boolean;
  95520. NORMAL: boolean;
  95521. UV1: boolean;
  95522. UV2: boolean;
  95523. VERTEXCOLOR: boolean;
  95524. VERTEXALPHA: boolean;
  95525. NUM_BONE_INFLUENCERS: number;
  95526. BonesPerMesh: number;
  95527. BONETEXTURE: boolean;
  95528. INSTANCES: boolean;
  95529. GLOSSINESS: boolean;
  95530. ROUGHNESS: boolean;
  95531. EMISSIVEASILLUMINATION: boolean;
  95532. LINKEMISSIVEWITHDIFFUSE: boolean;
  95533. REFLECTIONFRESNELFROMSPECULAR: boolean;
  95534. LIGHTMAP: boolean;
  95535. LIGHTMAPDIRECTUV: number;
  95536. OBJECTSPACE_NORMALMAP: boolean;
  95537. USELIGHTMAPASSHADOWMAP: boolean;
  95538. REFLECTIONMAP_3D: boolean;
  95539. REFLECTIONMAP_SPHERICAL: boolean;
  95540. REFLECTIONMAP_PLANAR: boolean;
  95541. REFLECTIONMAP_CUBIC: boolean;
  95542. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  95543. REFLECTIONMAP_PROJECTION: boolean;
  95544. REFLECTIONMAP_SKYBOX: boolean;
  95545. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  95546. REFLECTIONMAP_EXPLICIT: boolean;
  95547. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  95548. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  95549. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  95550. INVERTCUBICMAP: boolean;
  95551. LOGARITHMICDEPTH: boolean;
  95552. REFRACTION: boolean;
  95553. REFRACTIONMAP_3D: boolean;
  95554. REFLECTIONOVERALPHA: boolean;
  95555. TWOSIDEDLIGHTING: boolean;
  95556. SHADOWFLOAT: boolean;
  95557. MORPHTARGETS: boolean;
  95558. MORPHTARGETS_NORMAL: boolean;
  95559. MORPHTARGETS_TANGENT: boolean;
  95560. NUM_MORPH_INFLUENCERS: number;
  95561. NONUNIFORMSCALING: boolean;
  95562. PREMULTIPLYALPHA: boolean;
  95563. IMAGEPROCESSING: boolean;
  95564. VIGNETTE: boolean;
  95565. VIGNETTEBLENDMODEMULTIPLY: boolean;
  95566. VIGNETTEBLENDMODEOPAQUE: boolean;
  95567. TONEMAPPING: boolean;
  95568. TONEMAPPING_ACES: boolean;
  95569. CONTRAST: boolean;
  95570. COLORCURVES: boolean;
  95571. COLORGRADING: boolean;
  95572. COLORGRADING3D: boolean;
  95573. SAMPLER3DGREENDEPTH: boolean;
  95574. SAMPLER3DBGRMAP: boolean;
  95575. IMAGEPROCESSINGPOSTPROCESS: boolean;
  95576. /**
  95577. * If the reflection texture on this material is in linear color space
  95578. * @hidden
  95579. */
  95580. IS_REFLECTION_LINEAR: boolean;
  95581. /**
  95582. * If the refraction texture on this material is in linear color space
  95583. * @hidden
  95584. */
  95585. IS_REFRACTION_LINEAR: boolean;
  95586. EXPOSURE: boolean;
  95587. constructor();
  95588. setReflectionMode(modeToEnable: string): void;
  95589. }
  95590. /**
  95591. * This is the default material used in Babylon. It is the best trade off between quality
  95592. * and performances.
  95593. * @see http://doc.babylonjs.com/babylon101/materials
  95594. */
  95595. export class StandardMaterial extends PushMaterial {
  95596. private _diffuseTexture;
  95597. /**
  95598. * The basic texture of the material as viewed under a light.
  95599. */
  95600. diffuseTexture: Nullable<BaseTexture>;
  95601. private _ambientTexture;
  95602. /**
  95603. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  95604. */
  95605. ambientTexture: Nullable<BaseTexture>;
  95606. private _opacityTexture;
  95607. /**
  95608. * Define the transparency of the material from a texture.
  95609. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  95610. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  95611. */
  95612. opacityTexture: Nullable<BaseTexture>;
  95613. private _reflectionTexture;
  95614. /**
  95615. * Define the texture used to display the reflection.
  95616. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95617. */
  95618. reflectionTexture: Nullable<BaseTexture>;
  95619. private _emissiveTexture;
  95620. /**
  95621. * Define texture of the material as if self lit.
  95622. * This will be mixed in the final result even in the absence of light.
  95623. */
  95624. emissiveTexture: Nullable<BaseTexture>;
  95625. private _specularTexture;
  95626. /**
  95627. * Define how the color and intensity of the highlight given by the light in the material.
  95628. */
  95629. specularTexture: Nullable<BaseTexture>;
  95630. private _bumpTexture;
  95631. /**
  95632. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  95633. * 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.
  95634. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  95635. */
  95636. bumpTexture: Nullable<BaseTexture>;
  95637. private _lightmapTexture;
  95638. /**
  95639. * Complex lighting can be computationally expensive to compute at runtime.
  95640. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  95641. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  95642. */
  95643. lightmapTexture: Nullable<BaseTexture>;
  95644. private _refractionTexture;
  95645. /**
  95646. * Define the texture used to display the refraction.
  95647. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95648. */
  95649. refractionTexture: Nullable<BaseTexture>;
  95650. /**
  95651. * The color of the material lit by the environmental background lighting.
  95652. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  95653. */
  95654. ambientColor: Color3;
  95655. /**
  95656. * The basic color of the material as viewed under a light.
  95657. */
  95658. diffuseColor: Color3;
  95659. /**
  95660. * Define how the color and intensity of the highlight given by the light in the material.
  95661. */
  95662. specularColor: Color3;
  95663. /**
  95664. * Define the color of the material as if self lit.
  95665. * This will be mixed in the final result even in the absence of light.
  95666. */
  95667. emissiveColor: Color3;
  95668. /**
  95669. * Defines how sharp are the highlights in the material.
  95670. * The bigger the value the sharper giving a more glossy feeling to the result.
  95671. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  95672. */
  95673. specularPower: number;
  95674. private _useAlphaFromDiffuseTexture;
  95675. /**
  95676. * Does the transparency come from the diffuse texture alpha channel.
  95677. */
  95678. useAlphaFromDiffuseTexture: boolean;
  95679. private _useEmissiveAsIllumination;
  95680. /**
  95681. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  95682. */
  95683. useEmissiveAsIllumination: boolean;
  95684. private _linkEmissiveWithDiffuse;
  95685. /**
  95686. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  95687. * the emissive level when the final color is close to one.
  95688. */
  95689. linkEmissiveWithDiffuse: boolean;
  95690. private _useSpecularOverAlpha;
  95691. /**
  95692. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  95693. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  95694. */
  95695. useSpecularOverAlpha: boolean;
  95696. private _useReflectionOverAlpha;
  95697. /**
  95698. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  95699. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  95700. */
  95701. useReflectionOverAlpha: boolean;
  95702. private _disableLighting;
  95703. /**
  95704. * Does lights from the scene impacts this material.
  95705. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  95706. */
  95707. disableLighting: boolean;
  95708. private _useObjectSpaceNormalMap;
  95709. /**
  95710. * Allows using an object space normal map (instead of tangent space).
  95711. */
  95712. useObjectSpaceNormalMap: boolean;
  95713. private _useParallax;
  95714. /**
  95715. * Is parallax enabled or not.
  95716. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  95717. */
  95718. useParallax: boolean;
  95719. private _useParallaxOcclusion;
  95720. /**
  95721. * Is parallax occlusion enabled or not.
  95722. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  95723. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  95724. */
  95725. useParallaxOcclusion: boolean;
  95726. /**
  95727. * 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.
  95728. */
  95729. parallaxScaleBias: number;
  95730. private _roughness;
  95731. /**
  95732. * Helps to define how blurry the reflections should appears in the material.
  95733. */
  95734. roughness: number;
  95735. /**
  95736. * In case of refraction, define the value of the indice of refraction.
  95737. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95738. */
  95739. indexOfRefraction: number;
  95740. /**
  95741. * Invert the refraction texture alongside the y axis.
  95742. * It can be useful with procedural textures or probe for instance.
  95743. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95744. */
  95745. invertRefractionY: boolean;
  95746. /**
  95747. * Defines the alpha limits in alpha test mode.
  95748. */
  95749. alphaCutOff: number;
  95750. private _useLightmapAsShadowmap;
  95751. /**
  95752. * In case of light mapping, define whether the map contains light or shadow informations.
  95753. */
  95754. useLightmapAsShadowmap: boolean;
  95755. private _diffuseFresnelParameters;
  95756. /**
  95757. * Define the diffuse fresnel parameters of the material.
  95758. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95759. */
  95760. diffuseFresnelParameters: FresnelParameters;
  95761. private _opacityFresnelParameters;
  95762. /**
  95763. * Define the opacity fresnel parameters of the material.
  95764. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95765. */
  95766. opacityFresnelParameters: FresnelParameters;
  95767. private _reflectionFresnelParameters;
  95768. /**
  95769. * Define the reflection fresnel parameters of the material.
  95770. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95771. */
  95772. reflectionFresnelParameters: FresnelParameters;
  95773. private _refractionFresnelParameters;
  95774. /**
  95775. * Define the refraction fresnel parameters of the material.
  95776. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95777. */
  95778. refractionFresnelParameters: FresnelParameters;
  95779. private _emissiveFresnelParameters;
  95780. /**
  95781. * Define the emissive fresnel parameters of the material.
  95782. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95783. */
  95784. emissiveFresnelParameters: FresnelParameters;
  95785. private _useReflectionFresnelFromSpecular;
  95786. /**
  95787. * If true automatically deducts the fresnels values from the material specularity.
  95788. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95789. */
  95790. useReflectionFresnelFromSpecular: boolean;
  95791. private _useGlossinessFromSpecularMapAlpha;
  95792. /**
  95793. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  95794. */
  95795. useGlossinessFromSpecularMapAlpha: boolean;
  95796. private _maxSimultaneousLights;
  95797. /**
  95798. * Defines the maximum number of lights that can be used in the material
  95799. */
  95800. maxSimultaneousLights: number;
  95801. private _invertNormalMapX;
  95802. /**
  95803. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  95804. */
  95805. invertNormalMapX: boolean;
  95806. private _invertNormalMapY;
  95807. /**
  95808. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  95809. */
  95810. invertNormalMapY: boolean;
  95811. private _twoSidedLighting;
  95812. /**
  95813. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  95814. */
  95815. twoSidedLighting: boolean;
  95816. /**
  95817. * Default configuration related to image processing available in the standard Material.
  95818. */
  95819. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  95820. /**
  95821. * Gets the image processing configuration used either in this material.
  95822. */
  95823. /**
  95824. * Sets the Default image processing configuration used either in the this material.
  95825. *
  95826. * If sets to null, the scene one is in use.
  95827. */
  95828. imageProcessingConfiguration: ImageProcessingConfiguration;
  95829. /**
  95830. * Keep track of the image processing observer to allow dispose and replace.
  95831. */
  95832. private _imageProcessingObserver;
  95833. /**
  95834. * Attaches a new image processing configuration to the Standard Material.
  95835. * @param configuration
  95836. */
  95837. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  95838. /**
  95839. * Gets wether the color curves effect is enabled.
  95840. */
  95841. /**
  95842. * Sets wether the color curves effect is enabled.
  95843. */
  95844. cameraColorCurvesEnabled: boolean;
  95845. /**
  95846. * Gets wether the color grading effect is enabled.
  95847. */
  95848. /**
  95849. * Gets wether the color grading effect is enabled.
  95850. */
  95851. cameraColorGradingEnabled: boolean;
  95852. /**
  95853. * Gets wether tonemapping is enabled or not.
  95854. */
  95855. /**
  95856. * Sets wether tonemapping is enabled or not
  95857. */
  95858. cameraToneMappingEnabled: boolean;
  95859. /**
  95860. * The camera exposure used on this material.
  95861. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  95862. * This corresponds to a photographic exposure.
  95863. */
  95864. /**
  95865. * The camera exposure used on this material.
  95866. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  95867. * This corresponds to a photographic exposure.
  95868. */
  95869. cameraExposure: number;
  95870. /**
  95871. * Gets The camera contrast used on this material.
  95872. */
  95873. /**
  95874. * Sets The camera contrast used on this material.
  95875. */
  95876. cameraContrast: number;
  95877. /**
  95878. * Gets the Color Grading 2D Lookup Texture.
  95879. */
  95880. /**
  95881. * Sets the Color Grading 2D Lookup Texture.
  95882. */
  95883. cameraColorGradingTexture: Nullable<BaseTexture>;
  95884. /**
  95885. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  95886. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  95887. * 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;
  95888. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  95889. */
  95890. /**
  95891. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  95892. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  95893. * 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;
  95894. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  95895. */
  95896. cameraColorCurves: Nullable<ColorCurves>;
  95897. /**
  95898. * Custom callback helping to override the default shader used in the material.
  95899. */
  95900. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  95901. protected _renderTargets: SmartArray<RenderTargetTexture>;
  95902. protected _worldViewProjectionMatrix: Matrix;
  95903. protected _globalAmbientColor: Color3;
  95904. protected _useLogarithmicDepth: boolean;
  95905. /**
  95906. * Instantiates a new standard material.
  95907. * This is the default material used in Babylon. It is the best trade off between quality
  95908. * and performances.
  95909. * @see http://doc.babylonjs.com/babylon101/materials
  95910. * @param name Define the name of the material in the scene
  95911. * @param scene Define the scene the material belong to
  95912. */
  95913. constructor(name: string, scene: Scene);
  95914. /**
  95915. * Gets a boolean indicating that current material needs to register RTT
  95916. */
  95917. readonly hasRenderTargetTextures: boolean;
  95918. /**
  95919. * Gets the current class name of the material e.g. "StandardMaterial"
  95920. * Mainly use in serialization.
  95921. * @returns the class name
  95922. */
  95923. getClassName(): string;
  95924. /**
  95925. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  95926. * You can try switching to logarithmic depth.
  95927. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  95928. */
  95929. useLogarithmicDepth: boolean;
  95930. /**
  95931. * Specifies if the material will require alpha blending
  95932. * @returns a boolean specifying if alpha blending is needed
  95933. */
  95934. needAlphaBlending(): boolean;
  95935. /**
  95936. * Specifies if this material should be rendered in alpha test mode
  95937. * @returns a boolean specifying if an alpha test is needed.
  95938. */
  95939. needAlphaTesting(): boolean;
  95940. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  95941. /**
  95942. * Get the texture used for alpha test purpose.
  95943. * @returns the diffuse texture in case of the standard material.
  95944. */
  95945. getAlphaTestTexture(): Nullable<BaseTexture>;
  95946. /**
  95947. * Get if the submesh is ready to be used and all its information available.
  95948. * Child classes can use it to update shaders
  95949. * @param mesh defines the mesh to check
  95950. * @param subMesh defines which submesh to check
  95951. * @param useInstances specifies that instances should be used
  95952. * @returns a boolean indicating that the submesh is ready or not
  95953. */
  95954. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  95955. /**
  95956. * Builds the material UBO layouts.
  95957. * Used internally during the effect preparation.
  95958. */
  95959. buildUniformLayout(): void;
  95960. /**
  95961. * Unbinds the material from the mesh
  95962. */
  95963. unbind(): void;
  95964. /**
  95965. * Binds the submesh to this material by preparing the effect and shader to draw
  95966. * @param world defines the world transformation matrix
  95967. * @param mesh defines the mesh containing the submesh
  95968. * @param subMesh defines the submesh to bind the material to
  95969. */
  95970. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  95971. /**
  95972. * Get the list of animatables in the material.
  95973. * @returns the list of animatables object used in the material
  95974. */
  95975. getAnimatables(): IAnimatable[];
  95976. /**
  95977. * Gets the active textures from the material
  95978. * @returns an array of textures
  95979. */
  95980. getActiveTextures(): BaseTexture[];
  95981. /**
  95982. * Specifies if the material uses a texture
  95983. * @param texture defines the texture to check against the material
  95984. * @returns a boolean specifying if the material uses the texture
  95985. */
  95986. hasTexture(texture: BaseTexture): boolean;
  95987. /**
  95988. * Disposes the material
  95989. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  95990. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  95991. */
  95992. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  95993. /**
  95994. * Makes a duplicate of the material, and gives it a new name
  95995. * @param name defines the new name for the duplicated material
  95996. * @returns the cloned material
  95997. */
  95998. clone(name: string): StandardMaterial;
  95999. /**
  96000. * Serializes this material in a JSON representation
  96001. * @returns the serialized material object
  96002. */
  96003. serialize(): any;
  96004. /**
  96005. * Creates a standard material from parsed material data
  96006. * @param source defines the JSON representation of the material
  96007. * @param scene defines the hosting scene
  96008. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  96009. * @returns a new standard material
  96010. */
  96011. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  96012. /**
  96013. * Are diffuse textures enabled in the application.
  96014. */
  96015. static DiffuseTextureEnabled: boolean;
  96016. /**
  96017. * Are ambient textures enabled in the application.
  96018. */
  96019. static AmbientTextureEnabled: boolean;
  96020. /**
  96021. * Are opacity textures enabled in the application.
  96022. */
  96023. static OpacityTextureEnabled: boolean;
  96024. /**
  96025. * Are reflection textures enabled in the application.
  96026. */
  96027. static ReflectionTextureEnabled: boolean;
  96028. /**
  96029. * Are emissive textures enabled in the application.
  96030. */
  96031. static EmissiveTextureEnabled: boolean;
  96032. /**
  96033. * Are specular textures enabled in the application.
  96034. */
  96035. static SpecularTextureEnabled: boolean;
  96036. /**
  96037. * Are bump textures enabled in the application.
  96038. */
  96039. static BumpTextureEnabled: boolean;
  96040. /**
  96041. * Are lightmap textures enabled in the application.
  96042. */
  96043. static LightmapTextureEnabled: boolean;
  96044. /**
  96045. * Are refraction textures enabled in the application.
  96046. */
  96047. static RefractionTextureEnabled: boolean;
  96048. /**
  96049. * Are color grading textures enabled in the application.
  96050. */
  96051. static ColorGradingTextureEnabled: boolean;
  96052. /**
  96053. * Are fresnels enabled in the application.
  96054. */
  96055. static FresnelEnabled: boolean;
  96056. }
  96057. }
  96058. declare module BABYLON {
  96059. /**
  96060. * A class extending Texture allowing drawing on a texture
  96061. * @see http://doc.babylonjs.com/how_to/dynamictexture
  96062. */
  96063. export class DynamicTexture extends Texture {
  96064. private _generateMipMaps;
  96065. private _canvas;
  96066. private _context;
  96067. private _engine;
  96068. /**
  96069. * Creates a DynamicTexture
  96070. * @param name defines the name of the texture
  96071. * @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
  96072. * @param scene defines the scene where you want the texture
  96073. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  96074. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  96075. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  96076. */
  96077. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  96078. /**
  96079. * Get the current class name of the texture useful for serialization or dynamic coding.
  96080. * @returns "DynamicTexture"
  96081. */
  96082. getClassName(): string;
  96083. /**
  96084. * Gets the current state of canRescale
  96085. */
  96086. readonly canRescale: boolean;
  96087. private _recreate;
  96088. /**
  96089. * Scales the texture
  96090. * @param ratio the scale factor to apply to both width and height
  96091. */
  96092. scale(ratio: number): void;
  96093. /**
  96094. * Resizes the texture
  96095. * @param width the new width
  96096. * @param height the new height
  96097. */
  96098. scaleTo(width: number, height: number): void;
  96099. /**
  96100. * Gets the context of the canvas used by the texture
  96101. * @returns the canvas context of the dynamic texture
  96102. */
  96103. getContext(): CanvasRenderingContext2D;
  96104. /**
  96105. * Clears the texture
  96106. */
  96107. clear(): void;
  96108. /**
  96109. * Updates the texture
  96110. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  96111. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  96112. */
  96113. update(invertY?: boolean, premulAlpha?: boolean): void;
  96114. /**
  96115. * Draws text onto the texture
  96116. * @param text defines the text to be drawn
  96117. * @param x defines the placement of the text from the left
  96118. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  96119. * @param font defines the font to be used with font-style, font-size, font-name
  96120. * @param color defines the color used for the text
  96121. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  96122. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  96123. * @param update defines whether texture is immediately update (default is true)
  96124. */
  96125. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  96126. /**
  96127. * Clones the texture
  96128. * @returns the clone of the texture.
  96129. */
  96130. clone(): DynamicTexture;
  96131. /**
  96132. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  96133. * @returns a serialized dynamic texture object
  96134. */
  96135. serialize(): any;
  96136. /** @hidden */
  96137. _rebuild(): void;
  96138. }
  96139. }
  96140. declare module BABYLON {
  96141. /** @hidden */
  96142. export var imageProcessingPixelShader: {
  96143. name: string;
  96144. shader: string;
  96145. };
  96146. }
  96147. declare module BABYLON {
  96148. /**
  96149. * ImageProcessingPostProcess
  96150. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  96151. */
  96152. export class ImageProcessingPostProcess extends PostProcess {
  96153. /**
  96154. * Default configuration related to image processing available in the PBR Material.
  96155. */
  96156. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  96157. /**
  96158. * Gets the image processing configuration used either in this material.
  96159. */
  96160. /**
  96161. * Sets the Default image processing configuration used either in the this material.
  96162. *
  96163. * If sets to null, the scene one is in use.
  96164. */
  96165. imageProcessingConfiguration: ImageProcessingConfiguration;
  96166. /**
  96167. * Keep track of the image processing observer to allow dispose and replace.
  96168. */
  96169. private _imageProcessingObserver;
  96170. /**
  96171. * Attaches a new image processing configuration to the PBR Material.
  96172. * @param configuration
  96173. */
  96174. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  96175. /**
  96176. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  96177. */
  96178. /**
  96179. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  96180. */
  96181. colorCurves: Nullable<ColorCurves>;
  96182. /**
  96183. * Gets wether the color curves effect is enabled.
  96184. */
  96185. /**
  96186. * Sets wether the color curves effect is enabled.
  96187. */
  96188. colorCurvesEnabled: boolean;
  96189. /**
  96190. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  96191. */
  96192. /**
  96193. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  96194. */
  96195. colorGradingTexture: Nullable<BaseTexture>;
  96196. /**
  96197. * Gets wether the color grading effect is enabled.
  96198. */
  96199. /**
  96200. * Gets wether the color grading effect is enabled.
  96201. */
  96202. colorGradingEnabled: boolean;
  96203. /**
  96204. * Gets exposure used in the effect.
  96205. */
  96206. /**
  96207. * Sets exposure used in the effect.
  96208. */
  96209. exposure: number;
  96210. /**
  96211. * Gets wether tonemapping is enabled or not.
  96212. */
  96213. /**
  96214. * Sets wether tonemapping is enabled or not
  96215. */
  96216. toneMappingEnabled: boolean;
  96217. /**
  96218. * Gets the type of tone mapping effect.
  96219. */
  96220. /**
  96221. * Sets the type of tone mapping effect.
  96222. */
  96223. toneMappingType: number;
  96224. /**
  96225. * Gets contrast used in the effect.
  96226. */
  96227. /**
  96228. * Sets contrast used in the effect.
  96229. */
  96230. contrast: number;
  96231. /**
  96232. * Gets Vignette stretch size.
  96233. */
  96234. /**
  96235. * Sets Vignette stretch size.
  96236. */
  96237. vignetteStretch: number;
  96238. /**
  96239. * Gets Vignette centre X Offset.
  96240. */
  96241. /**
  96242. * Sets Vignette centre X Offset.
  96243. */
  96244. vignetteCentreX: number;
  96245. /**
  96246. * Gets Vignette centre Y Offset.
  96247. */
  96248. /**
  96249. * Sets Vignette centre Y Offset.
  96250. */
  96251. vignetteCentreY: number;
  96252. /**
  96253. * Gets Vignette weight or intensity of the vignette effect.
  96254. */
  96255. /**
  96256. * Sets Vignette weight or intensity of the vignette effect.
  96257. */
  96258. vignetteWeight: number;
  96259. /**
  96260. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  96261. * if vignetteEnabled is set to true.
  96262. */
  96263. /**
  96264. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  96265. * if vignetteEnabled is set to true.
  96266. */
  96267. vignetteColor: Color4;
  96268. /**
  96269. * Gets Camera field of view used by the Vignette effect.
  96270. */
  96271. /**
  96272. * Sets Camera field of view used by the Vignette effect.
  96273. */
  96274. vignetteCameraFov: number;
  96275. /**
  96276. * Gets the vignette blend mode allowing different kind of effect.
  96277. */
  96278. /**
  96279. * Sets the vignette blend mode allowing different kind of effect.
  96280. */
  96281. vignetteBlendMode: number;
  96282. /**
  96283. * Gets wether the vignette effect is enabled.
  96284. */
  96285. /**
  96286. * Sets wether the vignette effect is enabled.
  96287. */
  96288. vignetteEnabled: boolean;
  96289. private _fromLinearSpace;
  96290. /**
  96291. * Gets wether the input of the processing is in Gamma or Linear Space.
  96292. */
  96293. /**
  96294. * Sets wether the input of the processing is in Gamma or Linear Space.
  96295. */
  96296. fromLinearSpace: boolean;
  96297. /**
  96298. * Defines cache preventing GC.
  96299. */
  96300. private _defines;
  96301. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  96302. /**
  96303. * "ImageProcessingPostProcess"
  96304. * @returns "ImageProcessingPostProcess"
  96305. */
  96306. getClassName(): string;
  96307. protected _updateParameters(): void;
  96308. dispose(camera?: Camera): void;
  96309. }
  96310. }
  96311. declare module BABYLON {
  96312. /**
  96313. * Class containing static functions to help procedurally build meshes
  96314. */
  96315. export class GroundBuilder {
  96316. /**
  96317. * Creates a ground mesh
  96318. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  96319. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  96320. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96321. * @param name defines the name of the mesh
  96322. * @param options defines the options used to create the mesh
  96323. * @param scene defines the hosting scene
  96324. * @returns the ground mesh
  96325. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  96326. */
  96327. static CreateGround(name: string, options: {
  96328. width?: number;
  96329. height?: number;
  96330. subdivisions?: number;
  96331. subdivisionsX?: number;
  96332. subdivisionsY?: number;
  96333. updatable?: boolean;
  96334. }, scene: any): Mesh;
  96335. /**
  96336. * Creates a tiled ground mesh
  96337. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  96338. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  96339. * * 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
  96340. * * 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
  96341. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  96342. * @param name defines the name of the mesh
  96343. * @param options defines the options used to create the mesh
  96344. * @param scene defines the hosting scene
  96345. * @returns the tiled ground mesh
  96346. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  96347. */
  96348. static CreateTiledGround(name: string, options: {
  96349. xmin: number;
  96350. zmin: number;
  96351. xmax: number;
  96352. zmax: number;
  96353. subdivisions?: {
  96354. w: number;
  96355. h: number;
  96356. };
  96357. precision?: {
  96358. w: number;
  96359. h: number;
  96360. };
  96361. updatable?: boolean;
  96362. }, scene: Scene): Mesh;
  96363. /**
  96364. * Creates a ground mesh from a height map
  96365. * * The parameter `url` sets the URL of the height map image resource.
  96366. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  96367. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  96368. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  96369. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  96370. * * 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.
  96371. * * 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).
  96372. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  96373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  96374. * @param name defines the name of the mesh
  96375. * @param url defines the url to the height map
  96376. * @param options defines the options used to create the mesh
  96377. * @param scene defines the hosting scene
  96378. * @returns the ground mesh
  96379. * @see https://doc.babylonjs.com/babylon101/height_map
  96380. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  96381. */
  96382. static CreateGroundFromHeightMap(name: string, url: string, options: {
  96383. width?: number;
  96384. height?: number;
  96385. subdivisions?: number;
  96386. minHeight?: number;
  96387. maxHeight?: number;
  96388. colorFilter?: Color3;
  96389. alphaFilter?: number;
  96390. updatable?: boolean;
  96391. onReady?: (mesh: GroundMesh) => void;
  96392. }, scene: Scene): GroundMesh;
  96393. }
  96394. }
  96395. declare module BABYLON {
  96396. /**
  96397. * Class containing static functions to help procedurally build meshes
  96398. */
  96399. export class TorusBuilder {
  96400. /**
  96401. * Creates a torus mesh
  96402. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  96403. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  96404. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  96405. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  96406. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  96407. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  96408. * @param name defines the name of the mesh
  96409. * @param options defines the options used to create the mesh
  96410. * @param scene defines the hosting scene
  96411. * @returns the torus mesh
  96412. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  96413. */
  96414. static CreateTorus(name: string, options: {
  96415. diameter?: number;
  96416. thickness?: number;
  96417. tessellation?: number;
  96418. updatable?: boolean;
  96419. sideOrientation?: number;
  96420. frontUVs?: Vector4;
  96421. backUVs?: Vector4;
  96422. }, scene: any): Mesh;
  96423. }
  96424. }
  96425. declare module BABYLON {
  96426. /**
  96427. * Class containing static functions to help procedurally build meshes
  96428. */
  96429. export class CylinderBuilder {
  96430. /**
  96431. * Creates a cylinder or a cone mesh
  96432. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  96433. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  96434. * * 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.
  96435. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  96436. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  96437. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  96438. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  96439. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  96440. * * 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).
  96441. * * 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
  96442. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  96443. * * 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
  96444. * * 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.
  96445. * * If `enclose` is false, a ring surface is one element.
  96446. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  96447. * * 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
  96448. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  96449. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  96450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  96451. * @param name defines the name of the mesh
  96452. * @param options defines the options used to create the mesh
  96453. * @param scene defines the hosting scene
  96454. * @returns the cylinder mesh
  96455. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  96456. */
  96457. static CreateCylinder(name: string, options: {
  96458. height?: number;
  96459. diameterTop?: number;
  96460. diameterBottom?: number;
  96461. diameter?: number;
  96462. tessellation?: number;
  96463. subdivisions?: number;
  96464. arc?: number;
  96465. faceColors?: Color4[];
  96466. faceUV?: Vector4[];
  96467. updatable?: boolean;
  96468. hasRings?: boolean;
  96469. enclose?: boolean;
  96470. sideOrientation?: number;
  96471. frontUVs?: Vector4;
  96472. backUVs?: Vector4;
  96473. }, scene: any): Mesh;
  96474. }
  96475. }
  96476. declare module BABYLON {
  96477. /**
  96478. * Manager for handling gamepads
  96479. */
  96480. export class GamepadManager {
  96481. private _scene?;
  96482. private _babylonGamepads;
  96483. private _oneGamepadConnected;
  96484. /** @hidden */
  96485. _isMonitoring: boolean;
  96486. private _gamepadEventSupported;
  96487. private _gamepadSupport;
  96488. /**
  96489. * observable to be triggered when the gamepad controller has been connected
  96490. */
  96491. onGamepadConnectedObservable: Observable<Gamepad>;
  96492. /**
  96493. * observable to be triggered when the gamepad controller has been disconnected
  96494. */
  96495. onGamepadDisconnectedObservable: Observable<Gamepad>;
  96496. private _onGamepadConnectedEvent;
  96497. private _onGamepadDisconnectedEvent;
  96498. /**
  96499. * Initializes the gamepad manager
  96500. * @param _scene BabylonJS scene
  96501. */
  96502. constructor(_scene?: Scene | undefined);
  96503. /**
  96504. * The gamepads in the game pad manager
  96505. */
  96506. readonly gamepads: Gamepad[];
  96507. /**
  96508. * Get the gamepad controllers based on type
  96509. * @param type The type of gamepad controller
  96510. * @returns Nullable gamepad
  96511. */
  96512. getGamepadByType(type?: number): Nullable<Gamepad>;
  96513. /**
  96514. * Disposes the gamepad manager
  96515. */
  96516. dispose(): void;
  96517. private _addNewGamepad;
  96518. private _startMonitoringGamepads;
  96519. private _stopMonitoringGamepads;
  96520. /** @hidden */
  96521. _checkGamepadsStatus(): void;
  96522. private _updateGamepadObjects;
  96523. }
  96524. }
  96525. declare module BABYLON {
  96526. interface Scene {
  96527. /** @hidden */
  96528. _gamepadManager: Nullable<GamepadManager>;
  96529. /**
  96530. * Gets the gamepad manager associated with the scene
  96531. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  96532. */
  96533. gamepadManager: GamepadManager;
  96534. }
  96535. /**
  96536. * Interface representing a free camera inputs manager
  96537. */
  96538. interface FreeCameraInputsManager {
  96539. /**
  96540. * Adds gamepad input support to the FreeCameraInputsManager.
  96541. * @returns the FreeCameraInputsManager
  96542. */
  96543. addGamepad(): FreeCameraInputsManager;
  96544. }
  96545. /**
  96546. * Interface representing an arc rotate camera inputs manager
  96547. */
  96548. interface ArcRotateCameraInputsManager {
  96549. /**
  96550. * Adds gamepad input support to the ArcRotateCamera InputManager.
  96551. * @returns the camera inputs manager
  96552. */
  96553. addGamepad(): ArcRotateCameraInputsManager;
  96554. }
  96555. /**
  96556. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  96557. */
  96558. export class GamepadSystemSceneComponent implements ISceneComponent {
  96559. /**
  96560. * The component name helpfull to identify the component in the list of scene components.
  96561. */
  96562. readonly name: string;
  96563. /**
  96564. * The scene the component belongs to.
  96565. */
  96566. scene: Scene;
  96567. /**
  96568. * Creates a new instance of the component for the given scene
  96569. * @param scene Defines the scene to register the component in
  96570. */
  96571. constructor(scene: Scene);
  96572. /**
  96573. * Registers the component in a given scene
  96574. */
  96575. register(): void;
  96576. /**
  96577. * Rebuilds the elements related to this component in case of
  96578. * context lost for instance.
  96579. */
  96580. rebuild(): void;
  96581. /**
  96582. * Disposes the component and the associated ressources
  96583. */
  96584. dispose(): void;
  96585. private _beforeCameraUpdate;
  96586. }
  96587. }
  96588. declare module BABYLON {
  96589. /**
  96590. * Options to modify the vr teleportation behavior.
  96591. */
  96592. export interface VRTeleportationOptions {
  96593. /**
  96594. * The name of the mesh which should be used as the teleportation floor. (default: null)
  96595. */
  96596. floorMeshName?: string;
  96597. /**
  96598. * A list of meshes to be used as the teleportation floor. (default: empty)
  96599. */
  96600. floorMeshes?: Mesh[];
  96601. }
  96602. /**
  96603. * Options to modify the vr experience helper's behavior.
  96604. */
  96605. export interface VRExperienceHelperOptions extends WebVROptions {
  96606. /**
  96607. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  96608. */
  96609. createDeviceOrientationCamera?: boolean;
  96610. /**
  96611. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  96612. */
  96613. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  96614. /**
  96615. * Uses the main button on the controller to toggle the laser casted. (default: true)
  96616. */
  96617. laserToggle?: boolean;
  96618. /**
  96619. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  96620. */
  96621. floorMeshes?: Mesh[];
  96622. /**
  96623. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  96624. */
  96625. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  96626. }
  96627. /**
  96628. * Event containing information after VR has been entered
  96629. */
  96630. export class OnAfterEnteringVRObservableEvent {
  96631. /**
  96632. * If entering vr was successful
  96633. */
  96634. success: boolean;
  96635. }
  96636. /**
  96637. * Helps to quickly add VR support to an existing scene.
  96638. * See http://doc.babylonjs.com/how_to/webvr_helper
  96639. */
  96640. export class VRExperienceHelper {
  96641. /** Options to modify the vr experience helper's behavior. */
  96642. webVROptions: VRExperienceHelperOptions;
  96643. private _scene;
  96644. private _position;
  96645. private _btnVR;
  96646. private _btnVRDisplayed;
  96647. private _webVRsupported;
  96648. private _webVRready;
  96649. private _webVRrequesting;
  96650. private _webVRpresenting;
  96651. private _hasEnteredVR;
  96652. private _fullscreenVRpresenting;
  96653. private _canvas;
  96654. private _webVRCamera;
  96655. private _vrDeviceOrientationCamera;
  96656. private _deviceOrientationCamera;
  96657. private _existingCamera;
  96658. private _onKeyDown;
  96659. private _onVrDisplayPresentChange;
  96660. private _onVRDisplayChanged;
  96661. private _onVRRequestPresentStart;
  96662. private _onVRRequestPresentComplete;
  96663. /**
  96664. * Observable raised right before entering VR.
  96665. */
  96666. onEnteringVRObservable: Observable<VRExperienceHelper>;
  96667. /**
  96668. * Observable raised when entering VR has completed.
  96669. */
  96670. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  96671. /**
  96672. * Observable raised when exiting VR.
  96673. */
  96674. onExitingVRObservable: Observable<VRExperienceHelper>;
  96675. /**
  96676. * Observable raised when controller mesh is loaded.
  96677. */
  96678. onControllerMeshLoadedObservable: Observable<WebVRController>;
  96679. /** Return this.onEnteringVRObservable
  96680. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  96681. */
  96682. readonly onEnteringVR: Observable<VRExperienceHelper>;
  96683. /** Return this.onExitingVRObservable
  96684. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  96685. */
  96686. readonly onExitingVR: Observable<VRExperienceHelper>;
  96687. /** Return this.onControllerMeshLoadedObservable
  96688. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  96689. */
  96690. readonly onControllerMeshLoaded: Observable<WebVRController>;
  96691. private _rayLength;
  96692. private _useCustomVRButton;
  96693. private _teleportationRequested;
  96694. private _teleportActive;
  96695. private _floorMeshName;
  96696. private _floorMeshesCollection;
  96697. private _rotationAllowed;
  96698. private _teleportBackwardsVector;
  96699. private _teleportationTarget;
  96700. private _isDefaultTeleportationTarget;
  96701. private _postProcessMove;
  96702. private _teleportationFillColor;
  96703. private _teleportationBorderColor;
  96704. private _rotationAngle;
  96705. private _haloCenter;
  96706. private _cameraGazer;
  96707. private _padSensibilityUp;
  96708. private _padSensibilityDown;
  96709. private _leftController;
  96710. private _rightController;
  96711. /**
  96712. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  96713. */
  96714. onNewMeshSelected: Observable<AbstractMesh>;
  96715. /**
  96716. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  96717. */
  96718. onNewMeshPicked: Observable<PickingInfo>;
  96719. private _circleEase;
  96720. /**
  96721. * Observable raised before camera teleportation
  96722. */
  96723. onBeforeCameraTeleport: Observable<Vector3>;
  96724. /**
  96725. * Observable raised after camera teleportation
  96726. */
  96727. onAfterCameraTeleport: Observable<Vector3>;
  96728. /**
  96729. * Observable raised when current selected mesh gets unselected
  96730. */
  96731. onSelectedMeshUnselected: Observable<AbstractMesh>;
  96732. private _raySelectionPredicate;
  96733. /**
  96734. * To be optionaly changed by user to define custom ray selection
  96735. */
  96736. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  96737. /**
  96738. * To be optionaly changed by user to define custom selection logic (after ray selection)
  96739. */
  96740. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  96741. /**
  96742. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  96743. */
  96744. teleportationEnabled: boolean;
  96745. private _defaultHeight;
  96746. private _teleportationInitialized;
  96747. private _interactionsEnabled;
  96748. private _interactionsRequested;
  96749. private _displayGaze;
  96750. private _displayLaserPointer;
  96751. /**
  96752. * The mesh used to display where the user is going to teleport.
  96753. */
  96754. /**
  96755. * Sets the mesh to be used to display where the user is going to teleport.
  96756. */
  96757. teleportationTarget: Mesh;
  96758. /**
  96759. * 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
  96760. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  96761. * See http://doc.babylonjs.com/resources/baking_transformations
  96762. */
  96763. gazeTrackerMesh: Mesh;
  96764. /**
  96765. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  96766. */
  96767. updateGazeTrackerScale: boolean;
  96768. /**
  96769. * If the gaze trackers color should be updated when selecting meshes
  96770. */
  96771. updateGazeTrackerColor: boolean;
  96772. /**
  96773. * The gaze tracking mesh corresponding to the left controller
  96774. */
  96775. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  96776. /**
  96777. * The gaze tracking mesh corresponding to the right controller
  96778. */
  96779. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  96780. /**
  96781. * If the ray of the gaze should be displayed.
  96782. */
  96783. /**
  96784. * Sets if the ray of the gaze should be displayed.
  96785. */
  96786. displayGaze: boolean;
  96787. /**
  96788. * If the ray of the LaserPointer should be displayed.
  96789. */
  96790. /**
  96791. * Sets if the ray of the LaserPointer should be displayed.
  96792. */
  96793. displayLaserPointer: boolean;
  96794. /**
  96795. * The deviceOrientationCamera used as the camera when not in VR.
  96796. */
  96797. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  96798. /**
  96799. * Based on the current WebVR support, returns the current VR camera used.
  96800. */
  96801. readonly currentVRCamera: Nullable<Camera>;
  96802. /**
  96803. * The webVRCamera which is used when in VR.
  96804. */
  96805. readonly webVRCamera: WebVRFreeCamera;
  96806. /**
  96807. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  96808. */
  96809. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  96810. private readonly _teleportationRequestInitiated;
  96811. /**
  96812. * Defines wether or not Pointer lock should be requested when switching to
  96813. * full screen.
  96814. */
  96815. requestPointerLockOnFullScreen: boolean;
  96816. /**
  96817. * Instantiates a VRExperienceHelper.
  96818. * Helps to quickly add VR support to an existing scene.
  96819. * @param scene The scene the VRExperienceHelper belongs to.
  96820. * @param webVROptions Options to modify the vr experience helper's behavior.
  96821. */
  96822. constructor(scene: Scene,
  96823. /** Options to modify the vr experience helper's behavior. */
  96824. webVROptions?: VRExperienceHelperOptions);
  96825. private _onDefaultMeshLoaded;
  96826. private _onResize;
  96827. private _onFullscreenChange;
  96828. /**
  96829. * Gets a value indicating if we are currently in VR mode.
  96830. */
  96831. readonly isInVRMode: boolean;
  96832. private onVrDisplayPresentChange;
  96833. private onVRDisplayChanged;
  96834. private moveButtonToBottomRight;
  96835. private displayVRButton;
  96836. private updateButtonVisibility;
  96837. private _cachedAngularSensibility;
  96838. /**
  96839. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  96840. * Otherwise, will use the fullscreen API.
  96841. */
  96842. enterVR(): void;
  96843. /**
  96844. * Attempt to exit VR, or fullscreen.
  96845. */
  96846. exitVR(): void;
  96847. /**
  96848. * The position of the vr experience helper.
  96849. */
  96850. /**
  96851. * Sets the position of the vr experience helper.
  96852. */
  96853. position: Vector3;
  96854. /**
  96855. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  96856. */
  96857. enableInteractions(): void;
  96858. private readonly _noControllerIsActive;
  96859. private beforeRender;
  96860. private _isTeleportationFloor;
  96861. /**
  96862. * Adds a floor mesh to be used for teleportation.
  96863. * @param floorMesh the mesh to be used for teleportation.
  96864. */
  96865. addFloorMesh(floorMesh: Mesh): void;
  96866. /**
  96867. * Removes a floor mesh from being used for teleportation.
  96868. * @param floorMesh the mesh to be removed.
  96869. */
  96870. removeFloorMesh(floorMesh: Mesh): void;
  96871. /**
  96872. * Enables interactions and teleportation using the VR controllers and gaze.
  96873. * @param vrTeleportationOptions options to modify teleportation behavior.
  96874. */
  96875. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  96876. private _onNewGamepadConnected;
  96877. private _tryEnableInteractionOnController;
  96878. private _onNewGamepadDisconnected;
  96879. private _enableInteractionOnController;
  96880. private _checkTeleportWithRay;
  96881. private _checkRotate;
  96882. private _checkTeleportBackwards;
  96883. private _enableTeleportationOnController;
  96884. private _createTeleportationCircles;
  96885. private _displayTeleportationTarget;
  96886. private _hideTeleportationTarget;
  96887. private _rotateCamera;
  96888. private _moveTeleportationSelectorTo;
  96889. private _workingVector;
  96890. private _workingQuaternion;
  96891. private _workingMatrix;
  96892. /**
  96893. * Teleports the users feet to the desired location
  96894. * @param location The location where the user's feet should be placed
  96895. */
  96896. teleportCamera(location: Vector3): void;
  96897. private _convertNormalToDirectionOfRay;
  96898. private _castRayAndSelectObject;
  96899. private _notifySelectedMeshUnselected;
  96900. /**
  96901. * Sets the color of the laser ray from the vr controllers.
  96902. * @param color new color for the ray.
  96903. */
  96904. changeLaserColor(color: Color3): void;
  96905. /**
  96906. * Sets the color of the ray from the vr headsets gaze.
  96907. * @param color new color for the ray.
  96908. */
  96909. changeGazeColor(color: Color3): void;
  96910. /**
  96911. * Exits VR and disposes of the vr experience helper
  96912. */
  96913. dispose(): void;
  96914. /**
  96915. * Gets the name of the VRExperienceHelper class
  96916. * @returns "VRExperienceHelper"
  96917. */
  96918. getClassName(): string;
  96919. }
  96920. }
  96921. declare module BABYLON {
  96922. /**
  96923. * Manages an XRSession
  96924. * @see https://doc.babylonjs.com/how_to/webxr
  96925. */
  96926. export class WebXRSessionManager implements IDisposable {
  96927. private scene;
  96928. /**
  96929. * Fires every time a new xrFrame arrives which can be used to update the camera
  96930. */
  96931. onXRFrameObservable: Observable<any>;
  96932. /**
  96933. * Fires when the xr session is ended either by the device or manually done
  96934. */
  96935. onXRSessionEnded: Observable<any>;
  96936. /** @hidden */
  96937. _xrSession: XRSession;
  96938. /** @hidden */
  96939. _frameOfReference: XRFrameOfReference;
  96940. /** @hidden */
  96941. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  96942. /** @hidden */
  96943. _currentXRFrame: Nullable<XRFrame>;
  96944. private _xrNavigator;
  96945. private _xrDevice;
  96946. private _tmpMatrix;
  96947. /**
  96948. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  96949. * @param scene The scene which the session should be created for
  96950. */
  96951. constructor(scene: Scene);
  96952. /**
  96953. * Initializes the manager
  96954. * After initialization enterXR can be called to start an XR session
  96955. * @returns Promise which resolves after it is initialized
  96956. */
  96957. initializeAsync(): Promise<void>;
  96958. /**
  96959. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  96960. * @param sessionCreationOptions xr options to create the session with
  96961. * @param frameOfReferenceType option to configure how the xr pose is expressed
  96962. * @returns Promise which resolves after it enters XR
  96963. */
  96964. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  96965. /**
  96966. * Stops the xrSession and restores the renderloop
  96967. * @returns Promise which resolves after it exits XR
  96968. */
  96969. exitXRAsync(): Promise<void>;
  96970. /**
  96971. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  96972. * @param ray ray to cast into the environment
  96973. * @returns Promise which resolves with a collision point in the environment if it exists
  96974. */
  96975. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  96976. /**
  96977. * Checks if a session would be supported for the creation options specified
  96978. * @param options creation options to check if they are supported
  96979. * @returns true if supported
  96980. */
  96981. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  96982. /**
  96983. * @hidden
  96984. * Converts the render layer of xrSession to a render target
  96985. * @param session session to create render target for
  96986. * @param scene scene the new render target should be created for
  96987. */
  96988. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  96989. /**
  96990. * Disposes of the session manager
  96991. */
  96992. dispose(): void;
  96993. }
  96994. }
  96995. declare module BABYLON {
  96996. /**
  96997. * WebXR Camera which holds the views for the xrSession
  96998. * @see https://doc.babylonjs.com/how_to/webxr
  96999. */
  97000. export class WebXRCamera extends FreeCamera {
  97001. private static _TmpMatrix;
  97002. /**
  97003. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  97004. * @param name the name of the camera
  97005. * @param scene the scene to add the camera to
  97006. */
  97007. constructor(name: string, scene: Scene);
  97008. private _updateNumberOfRigCameras;
  97009. /** @hidden */
  97010. _updateForDualEyeDebugging(pupilDistance?: number): void;
  97011. /**
  97012. * Updates the cameras position from the current pose information of the XR session
  97013. * @param xrSessionManager the session containing pose information
  97014. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  97015. */
  97016. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  97017. }
  97018. }
  97019. declare module BABYLON {
  97020. /**
  97021. * States of the webXR experience
  97022. */
  97023. export enum WebXRState {
  97024. /**
  97025. * Transitioning to being in XR mode
  97026. */
  97027. ENTERING_XR = 0,
  97028. /**
  97029. * Transitioning to non XR mode
  97030. */
  97031. EXITING_XR = 1,
  97032. /**
  97033. * In XR mode and presenting
  97034. */
  97035. IN_XR = 2,
  97036. /**
  97037. * Not entered XR mode
  97038. */
  97039. NOT_IN_XR = 3
  97040. }
  97041. /**
  97042. * Helper class used to enable XR
  97043. * @see https://doc.babylonjs.com/how_to/webxr
  97044. */
  97045. export class WebXRExperienceHelper implements IDisposable {
  97046. private scene;
  97047. /**
  97048. * 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
  97049. */
  97050. container: AbstractMesh;
  97051. /**
  97052. * Camera used to render xr content
  97053. */
  97054. camera: WebXRCamera;
  97055. /**
  97056. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  97057. */
  97058. state: WebXRState;
  97059. private _setState;
  97060. private static _TmpVector;
  97061. /**
  97062. * Fires when the state of the experience helper has changed
  97063. */
  97064. onStateChangedObservable: Observable<WebXRState>;
  97065. /** @hidden */
  97066. _sessionManager: WebXRSessionManager;
  97067. private _nonVRCamera;
  97068. private _originalSceneAutoClear;
  97069. private _supported;
  97070. /**
  97071. * Creates the experience helper
  97072. * @param scene the scene to attach the experience helper to
  97073. * @returns a promise for the experience helper
  97074. */
  97075. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  97076. /**
  97077. * Creates a WebXRExperienceHelper
  97078. * @param scene The scene the helper should be created in
  97079. */
  97080. private constructor();
  97081. /**
  97082. * Exits XR mode and returns the scene to its original state
  97083. * @returns promise that resolves after xr mode has exited
  97084. */
  97085. exitXRAsync(): Promise<void>;
  97086. /**
  97087. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  97088. * @param sessionCreationOptions options for the XR session
  97089. * @param frameOfReference frame of reference of the XR session
  97090. * @returns promise that resolves after xr mode has entered
  97091. */
  97092. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  97093. /**
  97094. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  97095. * @param ray ray to cast into the environment
  97096. * @returns Promise which resolves with a collision point in the environment if it exists
  97097. */
  97098. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  97099. /**
  97100. * Updates the global position of the camera by moving the camera's container
  97101. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  97102. * @param position The desired global position of the camera
  97103. */
  97104. setPositionOfCameraUsingContainer(position: Vector3): void;
  97105. /**
  97106. * Rotates the xr camera by rotating the camera's container around the camera's position
  97107. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  97108. * @param rotation the desired quaternion rotation to apply to the camera
  97109. */
  97110. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  97111. /**
  97112. * Checks if the creation options are supported by the xr session
  97113. * @param options creation options
  97114. * @returns true if supported
  97115. */
  97116. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  97117. /**
  97118. * Disposes of the experience helper
  97119. */
  97120. dispose(): void;
  97121. }
  97122. }
  97123. declare module BABYLON {
  97124. /**
  97125. * Button which can be used to enter a different mode of XR
  97126. */
  97127. export class WebXREnterExitUIButton {
  97128. /** button element */
  97129. element: HTMLElement;
  97130. /** XR initialization options for the button */
  97131. initializationOptions: XRSessionCreationOptions;
  97132. /**
  97133. * Creates a WebXREnterExitUIButton
  97134. * @param element button element
  97135. * @param initializationOptions XR initialization options for the button
  97136. */
  97137. constructor(
  97138. /** button element */
  97139. element: HTMLElement,
  97140. /** XR initialization options for the button */
  97141. initializationOptions: XRSessionCreationOptions);
  97142. /**
  97143. * Overwritable function which can be used to update the button's visuals when the state changes
  97144. * @param activeButton the current active button in the UI
  97145. */
  97146. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  97147. }
  97148. /**
  97149. * Options to create the webXR UI
  97150. */
  97151. export class WebXREnterExitUIOptions {
  97152. /**
  97153. * Context to enter xr with
  97154. */
  97155. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  97156. /**
  97157. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  97158. */
  97159. customButtons?: Array<WebXREnterExitUIButton>;
  97160. }
  97161. /**
  97162. * UI to allow the user to enter/exit XR mode
  97163. */
  97164. export class WebXREnterExitUI implements IDisposable {
  97165. private scene;
  97166. private _overlay;
  97167. private _buttons;
  97168. private _activeButton;
  97169. /**
  97170. * Fired every time the active button is changed.
  97171. *
  97172. * When xr is entered via a button that launches xr that button will be the callback parameter
  97173. *
  97174. * When exiting xr the callback parameter will be null)
  97175. */
  97176. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  97177. /**
  97178. * Creates UI to allow the user to enter/exit XR mode
  97179. * @param scene the scene to add the ui to
  97180. * @param helper the xr experience helper to enter/exit xr with
  97181. * @param options options to configure the UI
  97182. * @returns the created ui
  97183. */
  97184. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  97185. private constructor();
  97186. private _updateButtons;
  97187. /**
  97188. * Disposes of the object
  97189. */
  97190. dispose(): void;
  97191. }
  97192. }
  97193. declare module BABYLON {
  97194. /**
  97195. * Represents an XR input
  97196. */
  97197. export class WebXRController {
  97198. /**
  97199. * 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
  97200. */
  97201. grip?: AbstractMesh;
  97202. /**
  97203. * Pointer which can be used to select objects or attach a visible laser to
  97204. */
  97205. pointer: AbstractMesh;
  97206. /**
  97207. * Creates the controller
  97208. * @see https://doc.babylonjs.com/how_to/webxr
  97209. * @param scene the scene which the controller should be associated to
  97210. */
  97211. constructor(scene: Scene);
  97212. /**
  97213. * Disposes of the object
  97214. */
  97215. dispose(): void;
  97216. }
  97217. /**
  97218. * XR input used to track XR inputs such as controllers/rays
  97219. */
  97220. export class WebXRInput implements IDisposable {
  97221. private helper;
  97222. /**
  97223. * XR controllers being tracked
  97224. */
  97225. controllers: Array<WebXRController>;
  97226. private _tmpMatrix;
  97227. private _frameObserver;
  97228. /**
  97229. * Initializes the WebXRInput
  97230. * @param helper experience helper which the input should be created for
  97231. */
  97232. constructor(helper: WebXRExperienceHelper);
  97233. /**
  97234. * Disposes of the object
  97235. */
  97236. dispose(): void;
  97237. }
  97238. }
  97239. declare module BABYLON {
  97240. /**
  97241. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  97242. */
  97243. export class WebXRManagedOutputCanvas implements IDisposable {
  97244. private _canvas;
  97245. /**
  97246. * xrpresent context of the canvas which can be used to display/mirror xr content
  97247. */
  97248. canvasContext: Nullable<WebGLRenderingContext>;
  97249. /**
  97250. * Initializes the canvas to be added/removed upon entering/exiting xr
  97251. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  97252. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  97253. */
  97254. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  97255. /**
  97256. * Disposes of the object
  97257. */
  97258. dispose(): void;
  97259. private _setManagedOutputCanvas;
  97260. private _addCanvas;
  97261. private _removeCanvas;
  97262. }
  97263. }
  97264. declare module BABYLON {
  97265. /**
  97266. * Contains an array of blocks representing the octree
  97267. */
  97268. export interface IOctreeContainer<T> {
  97269. /**
  97270. * Blocks within the octree
  97271. */
  97272. blocks: Array<OctreeBlock<T>>;
  97273. }
  97274. /**
  97275. * Class used to store a cell in an octree
  97276. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97277. */
  97278. export class OctreeBlock<T> {
  97279. /**
  97280. * Gets the content of the current block
  97281. */
  97282. entries: T[];
  97283. /**
  97284. * Gets the list of block children
  97285. */
  97286. blocks: Array<OctreeBlock<T>>;
  97287. private _depth;
  97288. private _maxDepth;
  97289. private _capacity;
  97290. private _minPoint;
  97291. private _maxPoint;
  97292. private _boundingVectors;
  97293. private _creationFunc;
  97294. /**
  97295. * Creates a new block
  97296. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  97297. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  97298. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  97299. * @param depth defines the current depth of this block in the octree
  97300. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  97301. * @param creationFunc defines a callback to call when an element is added to the block
  97302. */
  97303. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  97304. /**
  97305. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  97306. */
  97307. readonly capacity: number;
  97308. /**
  97309. * Gets the minimum vector (in world space) of the block's bounding box
  97310. */
  97311. readonly minPoint: Vector3;
  97312. /**
  97313. * Gets the maximum vector (in world space) of the block's bounding box
  97314. */
  97315. readonly maxPoint: Vector3;
  97316. /**
  97317. * Add a new element to this block
  97318. * @param entry defines the element to add
  97319. */
  97320. addEntry(entry: T): void;
  97321. /**
  97322. * Remove an element from this block
  97323. * @param entry defines the element to remove
  97324. */
  97325. removeEntry(entry: T): void;
  97326. /**
  97327. * Add an array of elements to this block
  97328. * @param entries defines the array of elements to add
  97329. */
  97330. addEntries(entries: T[]): void;
  97331. /**
  97332. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  97333. * @param frustumPlanes defines the frustum planes to test
  97334. * @param selection defines the array to store current content if selection is positive
  97335. * @param allowDuplicate defines if the selection array can contains duplicated entries
  97336. */
  97337. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  97338. /**
  97339. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  97340. * @param sphereCenter defines the bounding sphere center
  97341. * @param sphereRadius defines the bounding sphere radius
  97342. * @param selection defines the array to store current content if selection is positive
  97343. * @param allowDuplicate defines if the selection array can contains duplicated entries
  97344. */
  97345. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  97346. /**
  97347. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  97348. * @param ray defines the ray to test with
  97349. * @param selection defines the array to store current content if selection is positive
  97350. */
  97351. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  97352. /**
  97353. * Subdivide the content into child blocks (this block will then be empty)
  97354. */
  97355. createInnerBlocks(): void;
  97356. /**
  97357. * @hidden
  97358. */
  97359. 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;
  97360. }
  97361. }
  97362. declare module BABYLON {
  97363. /**
  97364. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  97365. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97366. */
  97367. export class Octree<T> {
  97368. /** 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.) */
  97369. maxDepth: number;
  97370. /**
  97371. * Blocks within the octree containing objects
  97372. */
  97373. blocks: Array<OctreeBlock<T>>;
  97374. /**
  97375. * Content stored in the octree
  97376. */
  97377. dynamicContent: T[];
  97378. private _maxBlockCapacity;
  97379. private _selectionContent;
  97380. private _creationFunc;
  97381. /**
  97382. * Creates a octree
  97383. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97384. * @param creationFunc function to be used to instatiate the octree
  97385. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  97386. * @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.)
  97387. */
  97388. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  97389. /** 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.) */
  97390. maxDepth?: number);
  97391. /**
  97392. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  97393. * @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);
  97394. * @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);
  97395. * @param entries meshes to be added to the octree blocks
  97396. */
  97397. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  97398. /**
  97399. * Adds a mesh to the octree
  97400. * @param entry Mesh to add to the octree
  97401. */
  97402. addMesh(entry: T): void;
  97403. /**
  97404. * Remove an element from the octree
  97405. * @param entry defines the element to remove
  97406. */
  97407. removeMesh(entry: T): void;
  97408. /**
  97409. * Selects an array of meshes within the frustum
  97410. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  97411. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  97412. * @returns array of meshes within the frustum
  97413. */
  97414. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  97415. /**
  97416. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  97417. * @param sphereCenter defines the bounding sphere center
  97418. * @param sphereRadius defines the bounding sphere radius
  97419. * @param allowDuplicate defines if the selection array can contains duplicated entries
  97420. * @returns an array of objects that intersect the sphere
  97421. */
  97422. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  97423. /**
  97424. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  97425. * @param ray defines the ray to test with
  97426. * @returns array of intersected objects
  97427. */
  97428. intersectsRay(ray: Ray): SmartArray<T>;
  97429. /**
  97430. * Adds a mesh into the octree block if it intersects the block
  97431. */
  97432. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  97433. /**
  97434. * Adds a submesh into the octree block if it intersects the block
  97435. */
  97436. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  97437. }
  97438. }
  97439. declare module BABYLON {
  97440. interface Scene {
  97441. /**
  97442. * @hidden
  97443. * Backing Filed
  97444. */
  97445. _selectionOctree: Octree<AbstractMesh>;
  97446. /**
  97447. * Gets the octree used to boost mesh selection (picking)
  97448. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97449. */
  97450. selectionOctree: Octree<AbstractMesh>;
  97451. /**
  97452. * Creates or updates the octree used to boost selection (picking)
  97453. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97454. * @param maxCapacity defines the maximum capacity per leaf
  97455. * @param maxDepth defines the maximum depth of the octree
  97456. * @returns an octree of AbstractMesh
  97457. */
  97458. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  97459. }
  97460. interface AbstractMesh {
  97461. /**
  97462. * @hidden
  97463. * Backing Field
  97464. */
  97465. _submeshesOctree: Octree<SubMesh>;
  97466. /**
  97467. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  97468. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  97469. * @param maxCapacity defines the maximum size of each block (64 by default)
  97470. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  97471. * @returns the new octree
  97472. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  97473. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97474. */
  97475. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  97476. }
  97477. /**
  97478. * Defines the octree scene component responsible to manage any octrees
  97479. * in a given scene.
  97480. */
  97481. export class OctreeSceneComponent {
  97482. /**
  97483. * The component name helpfull to identify the component in the list of scene components.
  97484. */
  97485. readonly name: string;
  97486. /**
  97487. * The scene the component belongs to.
  97488. */
  97489. scene: Scene;
  97490. /**
  97491. * Indicates if the meshes have been checked to make sure they are isEnabled()
  97492. */
  97493. readonly checksIsEnabled: boolean;
  97494. /**
  97495. * Creates a new instance of the component for the given scene
  97496. * @param scene Defines the scene to register the component in
  97497. */
  97498. constructor(scene: Scene);
  97499. /**
  97500. * Registers the component in a given scene
  97501. */
  97502. register(): void;
  97503. /**
  97504. * Return the list of active meshes
  97505. * @returns the list of active meshes
  97506. */
  97507. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  97508. /**
  97509. * Return the list of active sub meshes
  97510. * @param mesh The mesh to get the candidates sub meshes from
  97511. * @returns the list of active sub meshes
  97512. */
  97513. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  97514. private _tempRay;
  97515. /**
  97516. * Return the list of sub meshes intersecting with a given local ray
  97517. * @param mesh defines the mesh to find the submesh for
  97518. * @param localRay defines the ray in local space
  97519. * @returns the list of intersecting sub meshes
  97520. */
  97521. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  97522. /**
  97523. * Return the list of sub meshes colliding with a collider
  97524. * @param mesh defines the mesh to find the submesh for
  97525. * @param collider defines the collider to evaluate the collision against
  97526. * @returns the list of colliding sub meshes
  97527. */
  97528. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  97529. /**
  97530. * Rebuilds the elements related to this component in case of
  97531. * context lost for instance.
  97532. */
  97533. rebuild(): void;
  97534. /**
  97535. * Disposes the component and the associated ressources.
  97536. */
  97537. dispose(): void;
  97538. }
  97539. }
  97540. declare module BABYLON {
  97541. /**
  97542. * Class containing static functions to help procedurally build meshes
  97543. */
  97544. export class LinesBuilder {
  97545. /**
  97546. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  97547. * * 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
  97548. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  97549. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  97550. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  97551. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  97552. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  97553. * * 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
  97554. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  97555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97556. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  97557. * @param name defines the name of the new line system
  97558. * @param options defines the options used to create the line system
  97559. * @param scene defines the hosting scene
  97560. * @returns a new line system mesh
  97561. */
  97562. static CreateLineSystem(name: string, options: {
  97563. lines: Vector3[][];
  97564. updatable?: boolean;
  97565. instance?: Nullable<LinesMesh>;
  97566. colors?: Nullable<Color4[][]>;
  97567. useVertexAlpha?: boolean;
  97568. }, scene: Nullable<Scene>): LinesMesh;
  97569. /**
  97570. * Creates a line mesh
  97571. * 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
  97572. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  97573. * * The parameter `points` is an array successive Vector3
  97574. * * 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
  97575. * * The optional parameter `colors` is an array of successive Color4, one per line point
  97576. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  97577. * * When updating an instance, remember that only point positions can change, not the number of points
  97578. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97579. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  97580. * @param name defines the name of the new line system
  97581. * @param options defines the options used to create the line system
  97582. * @param scene defines the hosting scene
  97583. * @returns a new line mesh
  97584. */
  97585. static CreateLines(name: string, options: {
  97586. points: Vector3[];
  97587. updatable?: boolean;
  97588. instance?: Nullable<LinesMesh>;
  97589. colors?: Color4[];
  97590. useVertexAlpha?: boolean;
  97591. }, scene?: Nullable<Scene>): LinesMesh;
  97592. /**
  97593. * Creates a dashed line mesh
  97594. * * 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
  97595. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  97596. * * The parameter `points` is an array successive Vector3
  97597. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  97598. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  97599. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  97600. * * 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
  97601. * * When updating an instance, remember that only point positions can change, not the number of points
  97602. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97603. * @param name defines the name of the mesh
  97604. * @param options defines the options used to create the mesh
  97605. * @param scene defines the hosting scene
  97606. * @returns the dashed line mesh
  97607. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  97608. */
  97609. static CreateDashedLines(name: string, options: {
  97610. points: Vector3[];
  97611. dashSize?: number;
  97612. gapSize?: number;
  97613. dashNb?: number;
  97614. updatable?: boolean;
  97615. instance?: LinesMesh;
  97616. }, scene?: Nullable<Scene>): LinesMesh;
  97617. }
  97618. }
  97619. declare module BABYLON {
  97620. /**
  97621. * Renders a layer on top of an existing scene
  97622. */
  97623. export class UtilityLayerRenderer implements IDisposable {
  97624. /** the original scene that will be rendered on top of */
  97625. originalScene: Scene;
  97626. private _pointerCaptures;
  97627. private _lastPointerEvents;
  97628. private static _DefaultUtilityLayer;
  97629. private static _DefaultKeepDepthUtilityLayer;
  97630. /**
  97631. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  97632. */
  97633. pickUtilitySceneFirst: boolean;
  97634. /**
  97635. * 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)
  97636. */
  97637. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  97638. /**
  97639. * 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)
  97640. */
  97641. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  97642. /**
  97643. * The scene that is rendered on top of the original scene
  97644. */
  97645. utilityLayerScene: Scene;
  97646. /**
  97647. * If the utility layer should automatically be rendered on top of existing scene
  97648. */
  97649. shouldRender: boolean;
  97650. /**
  97651. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  97652. */
  97653. onlyCheckPointerDownEvents: boolean;
  97654. /**
  97655. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  97656. */
  97657. processAllEvents: boolean;
  97658. /**
  97659. * Observable raised when the pointer move from the utility layer scene to the main scene
  97660. */
  97661. onPointerOutObservable: Observable<number>;
  97662. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  97663. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  97664. private _afterRenderObserver;
  97665. private _sceneDisposeObserver;
  97666. private _originalPointerObserver;
  97667. /**
  97668. * Instantiates a UtilityLayerRenderer
  97669. * @param originalScene the original scene that will be rendered on top of
  97670. * @param handleEvents boolean indicating if the utility layer should handle events
  97671. */
  97672. constructor(
  97673. /** the original scene that will be rendered on top of */
  97674. originalScene: Scene, handleEvents?: boolean);
  97675. private _notifyObservers;
  97676. /**
  97677. * Renders the utility layers scene on top of the original scene
  97678. */
  97679. render(): void;
  97680. /**
  97681. * Disposes of the renderer
  97682. */
  97683. dispose(): void;
  97684. private _updateCamera;
  97685. }
  97686. }
  97687. declare module BABYLON {
  97688. /**
  97689. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  97690. */
  97691. export class Gizmo implements IDisposable {
  97692. /** The utility layer the gizmo will be added to */
  97693. gizmoLayer: UtilityLayerRenderer;
  97694. /**
  97695. * The root mesh of the gizmo
  97696. */
  97697. _rootMesh: Mesh;
  97698. private _attachedMesh;
  97699. /**
  97700. * Ratio for the scale of the gizmo (Default: 1)
  97701. */
  97702. scaleRatio: number;
  97703. private _tmpMatrix;
  97704. /**
  97705. * If a custom mesh has been set (Default: false)
  97706. */
  97707. protected _customMeshSet: boolean;
  97708. /**
  97709. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  97710. * * When set, interactions will be enabled
  97711. */
  97712. attachedMesh: Nullable<AbstractMesh>;
  97713. /**
  97714. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  97715. * @param mesh The mesh to replace the default mesh of the gizmo
  97716. */
  97717. setCustomMesh(mesh: Mesh): void;
  97718. /**
  97719. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  97720. */
  97721. updateGizmoRotationToMatchAttachedMesh: boolean;
  97722. /**
  97723. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  97724. */
  97725. updateGizmoPositionToMatchAttachedMesh: boolean;
  97726. /**
  97727. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  97728. */
  97729. protected _updateScale: boolean;
  97730. protected _interactionsEnabled: boolean;
  97731. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97732. private _beforeRenderObserver;
  97733. /**
  97734. * Creates a gizmo
  97735. * @param gizmoLayer The utility layer the gizmo will be added to
  97736. */
  97737. constructor(
  97738. /** The utility layer the gizmo will be added to */
  97739. gizmoLayer?: UtilityLayerRenderer);
  97740. private _tempVector;
  97741. /**
  97742. * @hidden
  97743. * Updates the gizmo to match the attached mesh's position/rotation
  97744. */
  97745. protected _update(): void;
  97746. /**
  97747. * Disposes of the gizmo
  97748. */
  97749. dispose(): void;
  97750. }
  97751. }
  97752. declare module BABYLON {
  97753. /**
  97754. * Single axis drag gizmo
  97755. */
  97756. export class AxisDragGizmo extends Gizmo {
  97757. /**
  97758. * Drag behavior responsible for the gizmos dragging interactions
  97759. */
  97760. dragBehavior: PointerDragBehavior;
  97761. private _pointerObserver;
  97762. /**
  97763. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  97764. */
  97765. snapDistance: number;
  97766. /**
  97767. * Event that fires each time the gizmo snaps to a new location.
  97768. * * snapDistance is the the change in distance
  97769. */
  97770. onSnapObservable: Observable<{
  97771. snapDistance: number;
  97772. }>;
  97773. /** @hidden */
  97774. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  97775. /** @hidden */
  97776. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  97777. /**
  97778. * Creates an AxisDragGizmo
  97779. * @param gizmoLayer The utility layer the gizmo will be added to
  97780. * @param dragAxis The axis which the gizmo will be able to drag on
  97781. * @param color The color of the gizmo
  97782. */
  97783. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  97784. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97785. /**
  97786. * Disposes of the gizmo
  97787. */
  97788. dispose(): void;
  97789. }
  97790. }
  97791. declare module BABYLON.Debug {
  97792. /**
  97793. * The Axes viewer will show 3 axes in a specific point in space
  97794. */
  97795. export class AxesViewer {
  97796. private _xAxis;
  97797. private _yAxis;
  97798. private _zAxis;
  97799. private _scaleLinesFactor;
  97800. private _instanced;
  97801. /**
  97802. * Gets the hosting scene
  97803. */
  97804. scene: Scene;
  97805. /**
  97806. * Gets or sets a number used to scale line length
  97807. */
  97808. scaleLines: number;
  97809. /** Gets the node hierarchy used to render x-axis */
  97810. readonly xAxis: TransformNode;
  97811. /** Gets the node hierarchy used to render y-axis */
  97812. readonly yAxis: TransformNode;
  97813. /** Gets the node hierarchy used to render z-axis */
  97814. readonly zAxis: TransformNode;
  97815. /**
  97816. * Creates a new AxesViewer
  97817. * @param scene defines the hosting scene
  97818. * @param scaleLines defines a number used to scale line length (1 by default)
  97819. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  97820. * @param xAxis defines the node hierarchy used to render the x-axis
  97821. * @param yAxis defines the node hierarchy used to render the y-axis
  97822. * @param zAxis defines the node hierarchy used to render the z-axis
  97823. */
  97824. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  97825. /**
  97826. * Force the viewer to update
  97827. * @param position defines the position of the viewer
  97828. * @param xaxis defines the x axis of the viewer
  97829. * @param yaxis defines the y axis of the viewer
  97830. * @param zaxis defines the z axis of the viewer
  97831. */
  97832. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  97833. /**
  97834. * Creates an instance of this axes viewer.
  97835. * @returns a new axes viewer with instanced meshes
  97836. */
  97837. createInstance(): AxesViewer;
  97838. /** Releases resources */
  97839. dispose(): void;
  97840. private static _SetRenderingGroupId;
  97841. }
  97842. }
  97843. declare module BABYLON.Debug {
  97844. /**
  97845. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  97846. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  97847. */
  97848. export class BoneAxesViewer extends AxesViewer {
  97849. /**
  97850. * Gets or sets the target mesh where to display the axes viewer
  97851. */
  97852. mesh: Nullable<Mesh>;
  97853. /**
  97854. * Gets or sets the target bone where to display the axes viewer
  97855. */
  97856. bone: Nullable<Bone>;
  97857. /** Gets current position */
  97858. pos: Vector3;
  97859. /** Gets direction of X axis */
  97860. xaxis: Vector3;
  97861. /** Gets direction of Y axis */
  97862. yaxis: Vector3;
  97863. /** Gets direction of Z axis */
  97864. zaxis: Vector3;
  97865. /**
  97866. * Creates a new BoneAxesViewer
  97867. * @param scene defines the hosting scene
  97868. * @param bone defines the target bone
  97869. * @param mesh defines the target mesh
  97870. * @param scaleLines defines a scaling factor for line length (1 by default)
  97871. */
  97872. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  97873. /**
  97874. * Force the viewer to update
  97875. */
  97876. update(): void;
  97877. /** Releases resources */
  97878. dispose(): void;
  97879. }
  97880. }
  97881. declare module BABYLON {
  97882. /**
  97883. * Interface used to define scene explorer extensibility option
  97884. */
  97885. export interface IExplorerExtensibilityOption {
  97886. /**
  97887. * Define the option label
  97888. */
  97889. label: string;
  97890. /**
  97891. * Defines the action to execute on click
  97892. */
  97893. action: (entity: any) => void;
  97894. }
  97895. /**
  97896. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  97897. */
  97898. export interface IExplorerExtensibilityGroup {
  97899. /**
  97900. * Defines a predicate to test if a given type mut be extended
  97901. */
  97902. predicate: (entity: any) => boolean;
  97903. /**
  97904. * Gets the list of options added to a type
  97905. */
  97906. entries: IExplorerExtensibilityOption[];
  97907. }
  97908. /**
  97909. * Interface used to define the options to use to create the Inspector
  97910. */
  97911. export interface IInspectorOptions {
  97912. /**
  97913. * Display in overlay mode (default: false)
  97914. */
  97915. overlay?: boolean;
  97916. /**
  97917. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  97918. */
  97919. globalRoot?: HTMLElement;
  97920. /**
  97921. * Display the Scene explorer
  97922. */
  97923. showExplorer?: boolean;
  97924. /**
  97925. * Display the property inspector
  97926. */
  97927. showInspector?: boolean;
  97928. /**
  97929. * Display in embed mode (both panes on the right)
  97930. */
  97931. embedMode?: boolean;
  97932. /**
  97933. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  97934. */
  97935. handleResize?: boolean;
  97936. /**
  97937. * Allow the panes to popup (default: true)
  97938. */
  97939. enablePopup?: boolean;
  97940. /**
  97941. * Allow the panes to be closed by users (default: true)
  97942. */
  97943. enableClose?: boolean;
  97944. /**
  97945. * Optional list of extensibility entries
  97946. */
  97947. explorerExtensibility?: IExplorerExtensibilityGroup[];
  97948. /**
  97949. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  97950. */
  97951. inspectorURL?: string;
  97952. }
  97953. interface Scene {
  97954. /**
  97955. * @hidden
  97956. * Backing field
  97957. */
  97958. _debugLayer: DebugLayer;
  97959. /**
  97960. * Gets the debug layer (aka Inspector) associated with the scene
  97961. * @see http://doc.babylonjs.com/features/playground_debuglayer
  97962. */
  97963. debugLayer: DebugLayer;
  97964. }
  97965. /**
  97966. * The debug layer (aka Inspector) is the go to tool in order to better understand
  97967. * what is happening in your scene
  97968. * @see http://doc.babylonjs.com/features/playground_debuglayer
  97969. */
  97970. export class DebugLayer {
  97971. /**
  97972. * Define the url to get the inspector script from.
  97973. * By default it uses the babylonjs CDN.
  97974. * @ignoreNaming
  97975. */
  97976. static InspectorURL: string;
  97977. private _scene;
  97978. private BJSINSPECTOR;
  97979. /**
  97980. * Observable triggered when a property is changed through the inspector.
  97981. */
  97982. onPropertyChangedObservable: Observable<{
  97983. object: any;
  97984. property: string;
  97985. value: any;
  97986. initialValue: any;
  97987. }>;
  97988. /**
  97989. * Instantiates a new debug layer.
  97990. * The debug layer (aka Inspector) is the go to tool in order to better understand
  97991. * what is happening in your scene
  97992. * @see http://doc.babylonjs.com/features/playground_debuglayer
  97993. * @param scene Defines the scene to inspect
  97994. */
  97995. constructor(scene: Scene);
  97996. /** Creates the inspector window. */
  97997. private _createInspector;
  97998. /**
  97999. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  98000. * @param entity defines the entity to select
  98001. * @param lineContainerTitle defines the specific block to highlight
  98002. */
  98003. select(entity: any, lineContainerTitle?: string): void;
  98004. /** Get the inspector from bundle or global */
  98005. private _getGlobalInspector;
  98006. /**
  98007. * Get if the inspector is visible or not.
  98008. * @returns true if visible otherwise, false
  98009. */
  98010. isVisible(): boolean;
  98011. /**
  98012. * Hide the inspector and close its window.
  98013. */
  98014. hide(): void;
  98015. /**
  98016. * Launch the debugLayer.
  98017. * @param config Define the configuration of the inspector
  98018. * @return a promise fulfilled when the debug layer is visible
  98019. */
  98020. show(config?: IInspectorOptions): Promise<DebugLayer>;
  98021. }
  98022. }
  98023. declare module BABYLON {
  98024. /**
  98025. * Class containing static functions to help procedurally build meshes
  98026. */
  98027. export class BoxBuilder {
  98028. /**
  98029. * Creates a box mesh
  98030. * * The parameter `size` sets the size (float) of each box side (default 1)
  98031. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  98032. * * 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)
  98033. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  98034. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98035. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98036. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98037. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  98038. * @param name defines the name of the mesh
  98039. * @param options defines the options used to create the mesh
  98040. * @param scene defines the hosting scene
  98041. * @returns the box mesh
  98042. */
  98043. static CreateBox(name: string, options: {
  98044. size?: number;
  98045. width?: number;
  98046. height?: number;
  98047. depth?: number;
  98048. faceUV?: Vector4[];
  98049. faceColors?: Color4[];
  98050. sideOrientation?: number;
  98051. frontUVs?: Vector4;
  98052. backUVs?: Vector4;
  98053. updatable?: boolean;
  98054. }, scene?: Nullable<Scene>): Mesh;
  98055. }
  98056. }
  98057. declare module BABYLON {
  98058. /**
  98059. * Class containing static functions to help procedurally build meshes
  98060. */
  98061. export class SphereBuilder {
  98062. /**
  98063. * Creates a sphere mesh
  98064. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  98065. * * 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`)
  98066. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  98067. * * 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
  98068. * * 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)
  98069. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98070. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98071. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98072. * @param name defines the name of the mesh
  98073. * @param options defines the options used to create the mesh
  98074. * @param scene defines the hosting scene
  98075. * @returns the sphere mesh
  98076. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  98077. */
  98078. static CreateSphere(name: string, options: {
  98079. segments?: number;
  98080. diameter?: number;
  98081. diameterX?: number;
  98082. diameterY?: number;
  98083. diameterZ?: number;
  98084. arc?: number;
  98085. slice?: number;
  98086. sideOrientation?: number;
  98087. frontUVs?: Vector4;
  98088. backUVs?: Vector4;
  98089. updatable?: boolean;
  98090. }, scene: any): Mesh;
  98091. }
  98092. }
  98093. declare module BABYLON.Debug {
  98094. /**
  98095. * Used to show the physics impostor around the specific mesh
  98096. */
  98097. export class PhysicsViewer {
  98098. /** @hidden */
  98099. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  98100. /** @hidden */
  98101. protected _meshes: Array<Nullable<AbstractMesh>>;
  98102. /** @hidden */
  98103. protected _scene: Nullable<Scene>;
  98104. /** @hidden */
  98105. protected _numMeshes: number;
  98106. /** @hidden */
  98107. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  98108. private _renderFunction;
  98109. private _utilityLayer;
  98110. private _debugBoxMesh;
  98111. private _debugSphereMesh;
  98112. private _debugMaterial;
  98113. /**
  98114. * Creates a new PhysicsViewer
  98115. * @param scene defines the hosting scene
  98116. */
  98117. constructor(scene: Scene);
  98118. /** @hidden */
  98119. protected _updateDebugMeshes(): void;
  98120. /**
  98121. * Renders a specified physic impostor
  98122. * @param impostor defines the impostor to render
  98123. * @returns the new debug mesh used to render the impostor
  98124. */
  98125. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  98126. /**
  98127. * Hides a specified physic impostor
  98128. * @param impostor defines the impostor to hide
  98129. */
  98130. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  98131. private _getDebugMaterial;
  98132. private _getDebugBoxMesh;
  98133. private _getDebugSphereMesh;
  98134. private _getDebugMesh;
  98135. /** Releases all resources */
  98136. dispose(): void;
  98137. }
  98138. }
  98139. declare module BABYLON {
  98140. /**
  98141. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  98142. * in order to better appreciate the issue one might have.
  98143. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  98144. */
  98145. export class RayHelper {
  98146. /**
  98147. * Defines the ray we are currently tryin to visualize.
  98148. */
  98149. ray: Nullable<Ray>;
  98150. private _renderPoints;
  98151. private _renderLine;
  98152. private _renderFunction;
  98153. private _scene;
  98154. private _updateToMeshFunction;
  98155. private _attachedToMesh;
  98156. private _meshSpaceDirection;
  98157. private _meshSpaceOrigin;
  98158. /**
  98159. * Helper function to create a colored helper in a scene in one line.
  98160. * @param ray Defines the ray we are currently tryin to visualize
  98161. * @param scene Defines the scene the ray is used in
  98162. * @param color Defines the color we want to see the ray in
  98163. * @returns The newly created ray helper.
  98164. */
  98165. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  98166. /**
  98167. * Instantiate a new ray helper.
  98168. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  98169. * in order to better appreciate the issue one might have.
  98170. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  98171. * @param ray Defines the ray we are currently tryin to visualize
  98172. */
  98173. constructor(ray: Ray);
  98174. /**
  98175. * Shows the ray we are willing to debug.
  98176. * @param scene Defines the scene the ray needs to be rendered in
  98177. * @param color Defines the color the ray needs to be rendered in
  98178. */
  98179. show(scene: Scene, color?: Color3): void;
  98180. /**
  98181. * Hides the ray we are debugging.
  98182. */
  98183. hide(): void;
  98184. private _render;
  98185. /**
  98186. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  98187. * @param mesh Defines the mesh we want the helper attached to
  98188. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  98189. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  98190. * @param length Defines the length of the ray
  98191. */
  98192. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  98193. /**
  98194. * Detach the ray helper from the mesh it has previously been attached to.
  98195. */
  98196. detachFromMesh(): void;
  98197. private _updateToMesh;
  98198. /**
  98199. * Dispose the helper and release its associated resources.
  98200. */
  98201. dispose(): void;
  98202. }
  98203. }
  98204. declare module BABYLON.Debug {
  98205. /**
  98206. * Class used to render a debug view of a given skeleton
  98207. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  98208. */
  98209. export class SkeletonViewer {
  98210. /** defines the skeleton to render */
  98211. skeleton: Skeleton;
  98212. /** defines the mesh attached to the skeleton */
  98213. mesh: AbstractMesh;
  98214. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  98215. autoUpdateBonesMatrices: boolean;
  98216. /** defines the rendering group id to use with the viewer */
  98217. renderingGroupId: number;
  98218. /** Gets or sets the color used to render the skeleton */
  98219. color: Color3;
  98220. private _scene;
  98221. private _debugLines;
  98222. private _debugMesh;
  98223. private _isEnabled;
  98224. private _renderFunction;
  98225. private _utilityLayer;
  98226. /**
  98227. * Returns the mesh used to render the bones
  98228. */
  98229. readonly debugMesh: Nullable<LinesMesh>;
  98230. /**
  98231. * Creates a new SkeletonViewer
  98232. * @param skeleton defines the skeleton to render
  98233. * @param mesh defines the mesh attached to the skeleton
  98234. * @param scene defines the hosting scene
  98235. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  98236. * @param renderingGroupId defines the rendering group id to use with the viewer
  98237. */
  98238. constructor(
  98239. /** defines the skeleton to render */
  98240. skeleton: Skeleton,
  98241. /** defines the mesh attached to the skeleton */
  98242. mesh: AbstractMesh, scene: Scene,
  98243. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  98244. autoUpdateBonesMatrices?: boolean,
  98245. /** defines the rendering group id to use with the viewer */
  98246. renderingGroupId?: number);
  98247. /** Gets or sets a boolean indicating if the viewer is enabled */
  98248. isEnabled: boolean;
  98249. private _getBonePosition;
  98250. private _getLinesForBonesWithLength;
  98251. private _getLinesForBonesNoLength;
  98252. /** Update the viewer to sync with current skeleton state */
  98253. update(): void;
  98254. /** Release associated resources */
  98255. dispose(): void;
  98256. }
  98257. }
  98258. declare module BABYLON {
  98259. /**
  98260. * Options to create the null engine
  98261. */
  98262. export class NullEngineOptions {
  98263. /**
  98264. * Render width (Default: 512)
  98265. */
  98266. renderWidth: number;
  98267. /**
  98268. * Render height (Default: 256)
  98269. */
  98270. renderHeight: number;
  98271. /**
  98272. * Texture size (Default: 512)
  98273. */
  98274. textureSize: number;
  98275. /**
  98276. * If delta time between frames should be constant
  98277. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98278. */
  98279. deterministicLockstep: boolean;
  98280. /**
  98281. * Maximum about of steps between frames (Default: 4)
  98282. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98283. */
  98284. lockstepMaxSteps: number;
  98285. }
  98286. /**
  98287. * The null engine class provides support for headless version of babylon.js.
  98288. * This can be used in server side scenario or for testing purposes
  98289. */
  98290. export class NullEngine extends Engine {
  98291. private _options;
  98292. /**
  98293. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98294. */
  98295. isDeterministicLockStep(): boolean;
  98296. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  98297. getLockstepMaxSteps(): number;
  98298. /**
  98299. * Sets hardware scaling, used to save performance if needed
  98300. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  98301. */
  98302. getHardwareScalingLevel(): number;
  98303. constructor(options?: NullEngineOptions);
  98304. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  98305. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  98306. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  98307. getRenderWidth(useScreen?: boolean): number;
  98308. getRenderHeight(useScreen?: boolean): number;
  98309. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  98310. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  98311. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  98312. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  98313. bindSamplers(effect: Effect): void;
  98314. enableEffect(effect: Effect): void;
  98315. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  98316. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  98317. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  98318. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  98319. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  98320. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  98321. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  98322. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  98323. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  98324. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  98325. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  98326. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  98327. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  98328. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  98329. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  98330. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  98331. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  98332. setFloat(uniform: WebGLUniformLocation, value: number): void;
  98333. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  98334. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  98335. setBool(uniform: WebGLUniformLocation, bool: number): void;
  98336. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  98337. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  98338. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  98339. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  98340. bindBuffers(vertexBuffers: {
  98341. [key: string]: VertexBuffer;
  98342. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  98343. wipeCaches(bruteForce?: boolean): void;
  98344. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  98345. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  98346. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  98347. /** @hidden */
  98348. _createTexture(): WebGLTexture;
  98349. /** @hidden */
  98350. _releaseTexture(texture: InternalTexture): void;
  98351. 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;
  98352. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  98353. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  98354. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  98355. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  98356. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  98357. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  98358. areAllEffectsReady(): boolean;
  98359. /**
  98360. * @hidden
  98361. * Get the current error code of the webGL context
  98362. * @returns the error code
  98363. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  98364. */
  98365. getError(): number;
  98366. /** @hidden */
  98367. _getUnpackAlignement(): number;
  98368. /** @hidden */
  98369. _unpackFlipY(value: boolean): void;
  98370. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  98371. /**
  98372. * Updates a dynamic vertex buffer.
  98373. * @param vertexBuffer the vertex buffer to update
  98374. * @param data the data used to update the vertex buffer
  98375. * @param byteOffset the byte offset of the data (optional)
  98376. * @param byteLength the byte length of the data (optional)
  98377. */
  98378. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  98379. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  98380. /** @hidden */
  98381. _bindTexture(channel: number, texture: InternalTexture): void;
  98382. /** @hidden */
  98383. _releaseBuffer(buffer: WebGLBuffer): boolean;
  98384. releaseEffects(): void;
  98385. displayLoadingUI(): void;
  98386. hideLoadingUI(): void;
  98387. /** @hidden */
  98388. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98389. /** @hidden */
  98390. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98391. /** @hidden */
  98392. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98393. /** @hidden */
  98394. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  98395. }
  98396. }
  98397. declare module BABYLON {
  98398. /** @hidden */
  98399. export class _OcclusionDataStorage {
  98400. /** @hidden */
  98401. occlusionInternalRetryCounter: number;
  98402. /** @hidden */
  98403. isOcclusionQueryInProgress: boolean;
  98404. /** @hidden */
  98405. isOccluded: boolean;
  98406. /** @hidden */
  98407. occlusionRetryCount: number;
  98408. /** @hidden */
  98409. occlusionType: number;
  98410. /** @hidden */
  98411. occlusionQueryAlgorithmType: number;
  98412. }
  98413. interface Engine {
  98414. /**
  98415. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  98416. * @return the new query
  98417. */
  98418. createQuery(): WebGLQuery;
  98419. /**
  98420. * Delete and release a webGL query
  98421. * @param query defines the query to delete
  98422. * @return the current engine
  98423. */
  98424. deleteQuery(query: WebGLQuery): Engine;
  98425. /**
  98426. * Check if a given query has resolved and got its value
  98427. * @param query defines the query to check
  98428. * @returns true if the query got its value
  98429. */
  98430. isQueryResultAvailable(query: WebGLQuery): boolean;
  98431. /**
  98432. * Gets the value of a given query
  98433. * @param query defines the query to check
  98434. * @returns the value of the query
  98435. */
  98436. getQueryResult(query: WebGLQuery): number;
  98437. /**
  98438. * Initiates an occlusion query
  98439. * @param algorithmType defines the algorithm to use
  98440. * @param query defines the query to use
  98441. * @returns the current engine
  98442. * @see http://doc.babylonjs.com/features/occlusionquery
  98443. */
  98444. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  98445. /**
  98446. * Ends an occlusion query
  98447. * @see http://doc.babylonjs.com/features/occlusionquery
  98448. * @param algorithmType defines the algorithm to use
  98449. * @returns the current engine
  98450. */
  98451. endOcclusionQuery(algorithmType: number): Engine;
  98452. /**
  98453. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  98454. * Please note that only one query can be issued at a time
  98455. * @returns a time token used to track the time span
  98456. */
  98457. startTimeQuery(): Nullable<_TimeToken>;
  98458. /**
  98459. * Ends a time query
  98460. * @param token defines the token used to measure the time span
  98461. * @returns the time spent (in ns)
  98462. */
  98463. endTimeQuery(token: _TimeToken): int;
  98464. /** @hidden */
  98465. _currentNonTimestampToken: Nullable<_TimeToken>;
  98466. /** @hidden */
  98467. _createTimeQuery(): WebGLQuery;
  98468. /** @hidden */
  98469. _deleteTimeQuery(query: WebGLQuery): void;
  98470. /** @hidden */
  98471. _getGlAlgorithmType(algorithmType: number): number;
  98472. /** @hidden */
  98473. _getTimeQueryResult(query: WebGLQuery): any;
  98474. /** @hidden */
  98475. _getTimeQueryAvailability(query: WebGLQuery): any;
  98476. }
  98477. interface AbstractMesh {
  98478. /**
  98479. * Backing filed
  98480. * @hidden
  98481. */
  98482. __occlusionDataStorage: _OcclusionDataStorage;
  98483. /**
  98484. * Access property
  98485. * @hidden
  98486. */
  98487. _occlusionDataStorage: _OcclusionDataStorage;
  98488. /**
  98489. * 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.
  98490. * The default value is -1 which means don't break the query and wait till the result
  98491. * @see http://doc.babylonjs.com/features/occlusionquery
  98492. */
  98493. occlusionRetryCount: number;
  98494. /**
  98495. * 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:
  98496. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  98497. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  98498. * * 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.
  98499. * @see http://doc.babylonjs.com/features/occlusionquery
  98500. */
  98501. occlusionType: number;
  98502. /**
  98503. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  98504. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  98505. * * 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.
  98506. * @see http://doc.babylonjs.com/features/occlusionquery
  98507. */
  98508. occlusionQueryAlgorithmType: number;
  98509. /**
  98510. * 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
  98511. * @see http://doc.babylonjs.com/features/occlusionquery
  98512. */
  98513. isOccluded: boolean;
  98514. /**
  98515. * Flag to check the progress status of the query
  98516. * @see http://doc.babylonjs.com/features/occlusionquery
  98517. */
  98518. isOcclusionQueryInProgress: boolean;
  98519. }
  98520. }
  98521. declare module BABYLON {
  98522. /** @hidden */
  98523. export var _forceTransformFeedbackToBundle: boolean;
  98524. interface Engine {
  98525. /**
  98526. * Creates a webGL transform feedback object
  98527. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  98528. * @returns the webGL transform feedback object
  98529. */
  98530. createTransformFeedback(): WebGLTransformFeedback;
  98531. /**
  98532. * Delete a webGL transform feedback object
  98533. * @param value defines the webGL transform feedback object to delete
  98534. */
  98535. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  98536. /**
  98537. * Bind a webGL transform feedback object to the webgl context
  98538. * @param value defines the webGL transform feedback object to bind
  98539. */
  98540. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  98541. /**
  98542. * Begins a transform feedback operation
  98543. * @param usePoints defines if points or triangles must be used
  98544. */
  98545. beginTransformFeedback(usePoints: boolean): void;
  98546. /**
  98547. * Ends a transform feedback operation
  98548. */
  98549. endTransformFeedback(): void;
  98550. /**
  98551. * Specify the varyings to use with transform feedback
  98552. * @param program defines the associated webGL program
  98553. * @param value defines the list of strings representing the varying names
  98554. */
  98555. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  98556. /**
  98557. * Bind a webGL buffer for a transform feedback operation
  98558. * @param value defines the webGL buffer to bind
  98559. */
  98560. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  98561. }
  98562. }
  98563. declare module BABYLON {
  98564. /**
  98565. * Gather the list of clipboard event types as constants.
  98566. */
  98567. export class ClipboardEventTypes {
  98568. /**
  98569. * The clipboard event is fired when a copy command is active (pressed).
  98570. */
  98571. static readonly COPY: number;
  98572. /**
  98573. * The clipboard event is fired when a cut command is active (pressed).
  98574. */
  98575. static readonly CUT: number;
  98576. /**
  98577. * The clipboard event is fired when a paste command is active (pressed).
  98578. */
  98579. static readonly PASTE: number;
  98580. }
  98581. /**
  98582. * This class is used to store clipboard related info for the onClipboardObservable event.
  98583. */
  98584. export class ClipboardInfo {
  98585. /**
  98586. * Defines the type of event (BABYLON.ClipboardEventTypes)
  98587. */
  98588. type: number;
  98589. /**
  98590. * Defines the related dom event
  98591. */
  98592. event: ClipboardEvent;
  98593. /**
  98594. *Creates an instance of ClipboardInfo.
  98595. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  98596. * @param event Defines the related dom event
  98597. */
  98598. constructor(
  98599. /**
  98600. * Defines the type of event (BABYLON.ClipboardEventTypes)
  98601. */
  98602. type: number,
  98603. /**
  98604. * Defines the related dom event
  98605. */
  98606. event: ClipboardEvent);
  98607. /**
  98608. * Get the clipboard event's type from the keycode.
  98609. * @param keyCode Defines the keyCode for the current keyboard event.
  98610. * @return {number}
  98611. */
  98612. static GetTypeFromCharacter(keyCode: number): number;
  98613. }
  98614. }
  98615. declare module BABYLON {
  98616. /**
  98617. * Class used to represent data loading progression
  98618. */
  98619. export class SceneLoaderProgressEvent {
  98620. /** defines if data length to load can be evaluated */
  98621. readonly lengthComputable: boolean;
  98622. /** defines the loaded data length */
  98623. readonly loaded: number;
  98624. /** defines the data length to load */
  98625. readonly total: number;
  98626. /**
  98627. * Create a new progress event
  98628. * @param lengthComputable defines if data length to load can be evaluated
  98629. * @param loaded defines the loaded data length
  98630. * @param total defines the data length to load
  98631. */
  98632. constructor(
  98633. /** defines if data length to load can be evaluated */
  98634. lengthComputable: boolean,
  98635. /** defines the loaded data length */
  98636. loaded: number,
  98637. /** defines the data length to load */
  98638. total: number);
  98639. /**
  98640. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  98641. * @param event defines the source event
  98642. * @returns a new SceneLoaderProgressEvent
  98643. */
  98644. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  98645. }
  98646. /**
  98647. * Interface used by SceneLoader plugins to define supported file extensions
  98648. */
  98649. export interface ISceneLoaderPluginExtensions {
  98650. /**
  98651. * Defines the list of supported extensions
  98652. */
  98653. [extension: string]: {
  98654. isBinary: boolean;
  98655. };
  98656. }
  98657. /**
  98658. * Interface used by SceneLoader plugin factory
  98659. */
  98660. export interface ISceneLoaderPluginFactory {
  98661. /**
  98662. * Defines the name of the factory
  98663. */
  98664. name: string;
  98665. /**
  98666. * Function called to create a new plugin
  98667. * @return the new plugin
  98668. */
  98669. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  98670. /**
  98671. * Boolean indicating if the plugin can direct load specific data
  98672. */
  98673. canDirectLoad?: (data: string) => boolean;
  98674. }
  98675. /**
  98676. * Interface used to define a SceneLoader plugin
  98677. */
  98678. export interface ISceneLoaderPlugin {
  98679. /**
  98680. * The friendly name of this plugin.
  98681. */
  98682. name: string;
  98683. /**
  98684. * The file extensions supported by this plugin.
  98685. */
  98686. extensions: string | ISceneLoaderPluginExtensions;
  98687. /**
  98688. * Import meshes into a scene.
  98689. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98690. * @param scene The scene to import into
  98691. * @param data The data to import
  98692. * @param rootUrl The root url for scene and resources
  98693. * @param meshes The meshes array to import into
  98694. * @param particleSystems The particle systems array to import into
  98695. * @param skeletons The skeletons array to import into
  98696. * @param onError The callback when import fails
  98697. * @returns True if successful or false otherwise
  98698. */
  98699. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  98700. /**
  98701. * Load into a scene.
  98702. * @param scene The scene to load into
  98703. * @param data The data to import
  98704. * @param rootUrl The root url for scene and resources
  98705. * @param onError The callback when import fails
  98706. * @returns true if successful or false otherwise
  98707. */
  98708. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  98709. /**
  98710. * The callback that returns true if the data can be directly loaded.
  98711. */
  98712. canDirectLoad?: (data: string) => boolean;
  98713. /**
  98714. * The callback that allows custom handling of the root url based on the response url.
  98715. */
  98716. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  98717. /**
  98718. * Load into an asset container.
  98719. * @param scene The scene to load into
  98720. * @param data The data to import
  98721. * @param rootUrl The root url for scene and resources
  98722. * @param onError The callback when import fails
  98723. * @returns The loaded asset container
  98724. */
  98725. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  98726. }
  98727. /**
  98728. * Interface used to define an async SceneLoader plugin
  98729. */
  98730. export interface ISceneLoaderPluginAsync {
  98731. /**
  98732. * The friendly name of this plugin.
  98733. */
  98734. name: string;
  98735. /**
  98736. * The file extensions supported by this plugin.
  98737. */
  98738. extensions: string | ISceneLoaderPluginExtensions;
  98739. /**
  98740. * Import meshes into a scene.
  98741. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98742. * @param scene The scene to import into
  98743. * @param data The data to import
  98744. * @param rootUrl The root url for scene and resources
  98745. * @param onProgress The callback when the load progresses
  98746. * @param fileName Defines the name of the file to load
  98747. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  98748. */
  98749. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  98750. meshes: AbstractMesh[];
  98751. particleSystems: IParticleSystem[];
  98752. skeletons: Skeleton[];
  98753. animationGroups: AnimationGroup[];
  98754. }>;
  98755. /**
  98756. * Load into a scene.
  98757. * @param scene The scene to load into
  98758. * @param data The data to import
  98759. * @param rootUrl The root url for scene and resources
  98760. * @param onProgress The callback when the load progresses
  98761. * @param fileName Defines the name of the file to load
  98762. * @returns Nothing
  98763. */
  98764. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  98765. /**
  98766. * The callback that returns true if the data can be directly loaded.
  98767. */
  98768. canDirectLoad?: (data: string) => boolean;
  98769. /**
  98770. * The callback that allows custom handling of the root url based on the response url.
  98771. */
  98772. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  98773. /**
  98774. * Load into an asset container.
  98775. * @param scene The scene to load into
  98776. * @param data The data to import
  98777. * @param rootUrl The root url for scene and resources
  98778. * @param onProgress The callback when the load progresses
  98779. * @param fileName Defines the name of the file to load
  98780. * @returns The loaded asset container
  98781. */
  98782. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  98783. }
  98784. /**
  98785. * Class used to load scene from various file formats using registered plugins
  98786. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  98787. */
  98788. export class SceneLoader {
  98789. /**
  98790. * No logging while loading
  98791. */
  98792. static readonly NO_LOGGING: number;
  98793. /**
  98794. * Minimal logging while loading
  98795. */
  98796. static readonly MINIMAL_LOGGING: number;
  98797. /**
  98798. * Summary logging while loading
  98799. */
  98800. static readonly SUMMARY_LOGGING: number;
  98801. /**
  98802. * Detailled logging while loading
  98803. */
  98804. static readonly DETAILED_LOGGING: number;
  98805. /**
  98806. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  98807. */
  98808. static ForceFullSceneLoadingForIncremental: boolean;
  98809. /**
  98810. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  98811. */
  98812. static ShowLoadingScreen: boolean;
  98813. /**
  98814. * Defines the current logging level (while loading the scene)
  98815. * @ignorenaming
  98816. */
  98817. static loggingLevel: number;
  98818. /**
  98819. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  98820. */
  98821. static CleanBoneMatrixWeights: boolean;
  98822. /**
  98823. * Event raised when a plugin is used to load a scene
  98824. */
  98825. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  98826. private static _registeredPlugins;
  98827. private static _getDefaultPlugin;
  98828. private static _getPluginForExtension;
  98829. private static _getPluginForDirectLoad;
  98830. private static _getPluginForFilename;
  98831. private static _getDirectLoad;
  98832. private static _loadData;
  98833. private static _getFileInfo;
  98834. /**
  98835. * Gets a plugin that can load the given extension
  98836. * @param extension defines the extension to load
  98837. * @returns a plugin or null if none works
  98838. */
  98839. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  98840. /**
  98841. * Gets a boolean indicating that the given extension can be loaded
  98842. * @param extension defines the extension to load
  98843. * @returns true if the extension is supported
  98844. */
  98845. static IsPluginForExtensionAvailable(extension: string): boolean;
  98846. /**
  98847. * Adds a new plugin to the list of registered plugins
  98848. * @param plugin defines the plugin to add
  98849. */
  98850. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  98851. /**
  98852. * Import meshes into a scene
  98853. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98854. * @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)
  98855. * @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)
  98856. * @param scene the instance of BABYLON.Scene to append to
  98857. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  98858. * @param onProgress a callback with a progress event for each file being loaded
  98859. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98860. * @param pluginExtension the extension used to determine the plugin
  98861. * @returns The loaded plugin
  98862. */
  98863. 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>;
  98864. /**
  98865. * Import meshes into a scene
  98866. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98867. * @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)
  98868. * @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)
  98869. * @param scene the instance of BABYLON.Scene to append to
  98870. * @param onProgress a callback with a progress event for each file being loaded
  98871. * @param pluginExtension the extension used to determine the plugin
  98872. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  98873. */
  98874. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  98875. meshes: AbstractMesh[];
  98876. particleSystems: IParticleSystem[];
  98877. skeletons: Skeleton[];
  98878. animationGroups: AnimationGroup[];
  98879. }>;
  98880. /**
  98881. * Load a scene
  98882. * @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)
  98883. * @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)
  98884. * @param engine is the instance of BABYLON.Engine to use to create the scene
  98885. * @param onSuccess a callback with the scene when import succeeds
  98886. * @param onProgress a callback with a progress event for each file being loaded
  98887. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98888. * @param pluginExtension the extension used to determine the plugin
  98889. * @returns The loaded plugin
  98890. */
  98891. 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>;
  98892. /**
  98893. * Load a scene
  98894. * @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)
  98895. * @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)
  98896. * @param engine is the instance of BABYLON.Engine to use to create the scene
  98897. * @param onProgress a callback with a progress event for each file being loaded
  98898. * @param pluginExtension the extension used to determine the plugin
  98899. * @returns The loaded scene
  98900. */
  98901. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  98902. /**
  98903. * Append a scene
  98904. * @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)
  98905. * @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)
  98906. * @param scene is the instance of BABYLON.Scene to append to
  98907. * @param onSuccess a callback with the scene when import succeeds
  98908. * @param onProgress a callback with a progress event for each file being loaded
  98909. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98910. * @param pluginExtension the extension used to determine the plugin
  98911. * @returns The loaded plugin
  98912. */
  98913. 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>;
  98914. /**
  98915. * Append a scene
  98916. * @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)
  98917. * @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)
  98918. * @param scene is the instance of BABYLON.Scene to append to
  98919. * @param onProgress a callback with a progress event for each file being loaded
  98920. * @param pluginExtension the extension used to determine the plugin
  98921. * @returns The given scene
  98922. */
  98923. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  98924. /**
  98925. * Load a scene into an asset container
  98926. * @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)
  98927. * @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)
  98928. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  98929. * @param onSuccess a callback with the scene when import succeeds
  98930. * @param onProgress a callback with a progress event for each file being loaded
  98931. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98932. * @param pluginExtension the extension used to determine the plugin
  98933. * @returns The loaded plugin
  98934. */
  98935. 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>;
  98936. /**
  98937. * Load a scene into an asset container
  98938. * @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)
  98939. * @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)
  98940. * @param scene is the instance of Scene to append to
  98941. * @param onProgress a callback with a progress event for each file being loaded
  98942. * @param pluginExtension the extension used to determine the plugin
  98943. * @returns The loaded asset container
  98944. */
  98945. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  98946. }
  98947. }
  98948. declare module BABYLON {
  98949. /**
  98950. * Google Daydream controller
  98951. */
  98952. export class DaydreamController extends WebVRController {
  98953. /**
  98954. * Base Url for the controller model.
  98955. */
  98956. static MODEL_BASE_URL: string;
  98957. /**
  98958. * File name for the controller model.
  98959. */
  98960. static MODEL_FILENAME: string;
  98961. /**
  98962. * Gamepad Id prefix used to identify Daydream Controller.
  98963. */
  98964. static readonly GAMEPAD_ID_PREFIX: string;
  98965. /**
  98966. * Creates a new DaydreamController from a gamepad
  98967. * @param vrGamepad the gamepad that the controller should be created from
  98968. */
  98969. constructor(vrGamepad: any);
  98970. /**
  98971. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98972. * @param scene scene in which to add meshes
  98973. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98974. */
  98975. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98976. /**
  98977. * Called once for each button that changed state since the last frame
  98978. * @param buttonIdx Which button index changed
  98979. * @param state New state of the button
  98980. * @param changes Which properties on the state changed since last frame
  98981. */
  98982. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98983. }
  98984. }
  98985. declare module BABYLON {
  98986. /**
  98987. * Gear VR Controller
  98988. */
  98989. export class GearVRController extends WebVRController {
  98990. /**
  98991. * Base Url for the controller model.
  98992. */
  98993. static MODEL_BASE_URL: string;
  98994. /**
  98995. * File name for the controller model.
  98996. */
  98997. static MODEL_FILENAME: string;
  98998. /**
  98999. * Gamepad Id prefix used to identify this controller.
  99000. */
  99001. static readonly GAMEPAD_ID_PREFIX: string;
  99002. private readonly _buttonIndexToObservableNameMap;
  99003. /**
  99004. * Creates a new GearVRController from a gamepad
  99005. * @param vrGamepad the gamepad that the controller should be created from
  99006. */
  99007. constructor(vrGamepad: any);
  99008. /**
  99009. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  99010. * @param scene scene in which to add meshes
  99011. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  99012. */
  99013. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  99014. /**
  99015. * Called once for each button that changed state since the last frame
  99016. * @param buttonIdx Which button index changed
  99017. * @param state New state of the button
  99018. * @param changes Which properties on the state changed since last frame
  99019. */
  99020. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99021. }
  99022. }
  99023. declare module BABYLON {
  99024. /**
  99025. * Generic Controller
  99026. */
  99027. export class GenericController extends WebVRController {
  99028. /**
  99029. * Base Url for the controller model.
  99030. */
  99031. static readonly MODEL_BASE_URL: string;
  99032. /**
  99033. * File name for the controller model.
  99034. */
  99035. static readonly MODEL_FILENAME: string;
  99036. /**
  99037. * Creates a new GenericController from a gamepad
  99038. * @param vrGamepad the gamepad that the controller should be created from
  99039. */
  99040. constructor(vrGamepad: any);
  99041. /**
  99042. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  99043. * @param scene scene in which to add meshes
  99044. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  99045. */
  99046. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  99047. /**
  99048. * Called once for each button that changed state since the last frame
  99049. * @param buttonIdx Which button index changed
  99050. * @param state New state of the button
  99051. * @param changes Which properties on the state changed since last frame
  99052. */
  99053. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99054. }
  99055. }
  99056. declare module BABYLON {
  99057. /**
  99058. * Oculus Touch Controller
  99059. */
  99060. export class OculusTouchController extends WebVRController {
  99061. /**
  99062. * Base Url for the controller model.
  99063. */
  99064. static MODEL_BASE_URL: string;
  99065. /**
  99066. * File name for the left controller model.
  99067. */
  99068. static MODEL_LEFT_FILENAME: string;
  99069. /**
  99070. * File name for the right controller model.
  99071. */
  99072. static MODEL_RIGHT_FILENAME: string;
  99073. /**
  99074. * Fired when the secondary trigger on this controller is modified
  99075. */
  99076. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  99077. /**
  99078. * Fired when the thumb rest on this controller is modified
  99079. */
  99080. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  99081. /**
  99082. * Creates a new OculusTouchController from a gamepad
  99083. * @param vrGamepad the gamepad that the controller should be created from
  99084. */
  99085. constructor(vrGamepad: any);
  99086. /**
  99087. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  99088. * @param scene scene in which to add meshes
  99089. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  99090. */
  99091. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  99092. /**
  99093. * Fired when the A button on this controller is modified
  99094. */
  99095. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99096. /**
  99097. * Fired when the B button on this controller is modified
  99098. */
  99099. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99100. /**
  99101. * Fired when the X button on this controller is modified
  99102. */
  99103. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99104. /**
  99105. * Fired when the Y button on this controller is modified
  99106. */
  99107. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99108. /**
  99109. * Called once for each button that changed state since the last frame
  99110. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  99111. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  99112. * 2) secondary trigger (same)
  99113. * 3) A (right) X (left), touch, pressed = value
  99114. * 4) B / Y
  99115. * 5) thumb rest
  99116. * @param buttonIdx Which button index changed
  99117. * @param state New state of the button
  99118. * @param changes Which properties on the state changed since last frame
  99119. */
  99120. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99121. }
  99122. }
  99123. declare module BABYLON {
  99124. /**
  99125. * Vive Controller
  99126. */
  99127. export class ViveController extends WebVRController {
  99128. /**
  99129. * Base Url for the controller model.
  99130. */
  99131. static MODEL_BASE_URL: string;
  99132. /**
  99133. * File name for the controller model.
  99134. */
  99135. static MODEL_FILENAME: string;
  99136. /**
  99137. * Creates a new ViveController from a gamepad
  99138. * @param vrGamepad the gamepad that the controller should be created from
  99139. */
  99140. constructor(vrGamepad: any);
  99141. /**
  99142. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  99143. * @param scene scene in which to add meshes
  99144. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  99145. */
  99146. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  99147. /**
  99148. * Fired when the left button on this controller is modified
  99149. */
  99150. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99151. /**
  99152. * Fired when the right button on this controller is modified
  99153. */
  99154. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99155. /**
  99156. * Fired when the menu button on this controller is modified
  99157. */
  99158. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99159. /**
  99160. * Called once for each button that changed state since the last frame
  99161. * Vive mapping:
  99162. * 0: touchpad
  99163. * 1: trigger
  99164. * 2: left AND right buttons
  99165. * 3: menu button
  99166. * @param buttonIdx Which button index changed
  99167. * @param state New state of the button
  99168. * @param changes Which properties on the state changed since last frame
  99169. */
  99170. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99171. }
  99172. }
  99173. declare module BABYLON {
  99174. /**
  99175. * Defines the WindowsMotionController object that the state of the windows motion controller
  99176. */
  99177. export class WindowsMotionController extends WebVRController {
  99178. /**
  99179. * The base url used to load the left and right controller models
  99180. */
  99181. static MODEL_BASE_URL: string;
  99182. /**
  99183. * The name of the left controller model file
  99184. */
  99185. static MODEL_LEFT_FILENAME: string;
  99186. /**
  99187. * The name of the right controller model file
  99188. */
  99189. static MODEL_RIGHT_FILENAME: string;
  99190. /**
  99191. * The controller name prefix for this controller type
  99192. */
  99193. static readonly GAMEPAD_ID_PREFIX: string;
  99194. /**
  99195. * The controller id pattern for this controller type
  99196. */
  99197. private static readonly GAMEPAD_ID_PATTERN;
  99198. private _loadedMeshInfo;
  99199. private readonly _mapping;
  99200. /**
  99201. * Fired when the trackpad on this controller is clicked
  99202. */
  99203. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  99204. /**
  99205. * Fired when the trackpad on this controller is modified
  99206. */
  99207. onTrackpadValuesChangedObservable: Observable<StickValues>;
  99208. /**
  99209. * The current x and y values of this controller's trackpad
  99210. */
  99211. trackpad: StickValues;
  99212. /**
  99213. * Creates a new WindowsMotionController from a gamepad
  99214. * @param vrGamepad the gamepad that the controller should be created from
  99215. */
  99216. constructor(vrGamepad: any);
  99217. /**
  99218. * Fired when the trigger on this controller is modified
  99219. */
  99220. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99221. /**
  99222. * Fired when the menu button on this controller is modified
  99223. */
  99224. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99225. /**
  99226. * Fired when the grip button on this controller is modified
  99227. */
  99228. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99229. /**
  99230. * Fired when the thumbstick button on this controller is modified
  99231. */
  99232. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99233. /**
  99234. * Fired when the touchpad button on this controller is modified
  99235. */
  99236. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99237. /**
  99238. * Fired when the touchpad values on this controller are modified
  99239. */
  99240. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  99241. private _updateTrackpad;
  99242. /**
  99243. * Called once per frame by the engine.
  99244. */
  99245. update(): void;
  99246. /**
  99247. * Called once for each button that changed state since the last frame
  99248. * @param buttonIdx Which button index changed
  99249. * @param state New state of the button
  99250. * @param changes Which properties on the state changed since last frame
  99251. */
  99252. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99253. /**
  99254. * Moves the buttons on the controller mesh based on their current state
  99255. * @param buttonName the name of the button to move
  99256. * @param buttonValue the value of the button which determines the buttons new position
  99257. */
  99258. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  99259. /**
  99260. * Moves the axis on the controller mesh based on its current state
  99261. * @param axis the index of the axis
  99262. * @param axisValue the value of the axis which determines the meshes new position
  99263. * @hidden
  99264. */
  99265. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  99266. /**
  99267. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  99268. * @param scene scene in which to add meshes
  99269. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  99270. */
  99271. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  99272. /**
  99273. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  99274. * can be transformed by button presses and axes values, based on this._mapping.
  99275. *
  99276. * @param scene scene in which the meshes exist
  99277. * @param meshes list of meshes that make up the controller model to process
  99278. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  99279. */
  99280. private processModel;
  99281. private createMeshInfo;
  99282. /**
  99283. * Gets the ray of the controller in the direction the controller is pointing
  99284. * @param length the length the resulting ray should be
  99285. * @returns a ray in the direction the controller is pointing
  99286. */
  99287. getForwardRay(length?: number): Ray;
  99288. /**
  99289. * Disposes of the controller
  99290. */
  99291. dispose(): void;
  99292. }
  99293. }
  99294. declare module BABYLON {
  99295. /**
  99296. * Single axis scale gizmo
  99297. */
  99298. export class AxisScaleGizmo extends Gizmo {
  99299. private _coloredMaterial;
  99300. /**
  99301. * Drag behavior responsible for the gizmos dragging interactions
  99302. */
  99303. dragBehavior: PointerDragBehavior;
  99304. private _pointerObserver;
  99305. /**
  99306. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99307. */
  99308. snapDistance: number;
  99309. /**
  99310. * Event that fires each time the gizmo snaps to a new location.
  99311. * * snapDistance is the the change in distance
  99312. */
  99313. onSnapObservable: Observable<{
  99314. snapDistance: number;
  99315. }>;
  99316. /**
  99317. * If the scaling operation should be done on all axis (default: false)
  99318. */
  99319. uniformScaling: boolean;
  99320. /**
  99321. * Creates an AxisScaleGizmo
  99322. * @param gizmoLayer The utility layer the gizmo will be added to
  99323. * @param dragAxis The axis which the gizmo will be able to scale on
  99324. * @param color The color of the gizmo
  99325. */
  99326. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  99327. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99328. /**
  99329. * Disposes of the gizmo
  99330. */
  99331. dispose(): void;
  99332. /**
  99333. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  99334. * @param mesh The mesh to replace the default mesh of the gizmo
  99335. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  99336. */
  99337. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  99338. }
  99339. }
  99340. declare module BABYLON {
  99341. /**
  99342. * Bounding box gizmo
  99343. */
  99344. export class BoundingBoxGizmo extends Gizmo {
  99345. private _lineBoundingBox;
  99346. private _rotateSpheresParent;
  99347. private _scaleBoxesParent;
  99348. private _boundingDimensions;
  99349. private _renderObserver;
  99350. private _pointerObserver;
  99351. private _scaleDragSpeed;
  99352. private _tmpQuaternion;
  99353. private _tmpVector;
  99354. private _tmpRotationMatrix;
  99355. /**
  99356. * 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)
  99357. */
  99358. ignoreChildren: boolean;
  99359. /**
  99360. * 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)
  99361. */
  99362. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  99363. /**
  99364. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  99365. */
  99366. rotationSphereSize: number;
  99367. /**
  99368. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  99369. */
  99370. scaleBoxSize: number;
  99371. /**
  99372. * 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)
  99373. */
  99374. fixedDragMeshScreenSize: boolean;
  99375. /**
  99376. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  99377. */
  99378. fixedDragMeshScreenSizeDistanceFactor: number;
  99379. /**
  99380. * Fired when a rotation sphere or scale box is dragged
  99381. */
  99382. onDragStartObservable: Observable<{}>;
  99383. /**
  99384. * Fired when a scale box is dragged
  99385. */
  99386. onScaleBoxDragObservable: Observable<{}>;
  99387. /**
  99388. * Fired when a scale box drag is ended
  99389. */
  99390. onScaleBoxDragEndObservable: Observable<{}>;
  99391. /**
  99392. * Fired when a rotation sphere is dragged
  99393. */
  99394. onRotationSphereDragObservable: Observable<{}>;
  99395. /**
  99396. * Fired when a rotation sphere drag is ended
  99397. */
  99398. onRotationSphereDragEndObservable: Observable<{}>;
  99399. /**
  99400. * 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)
  99401. */
  99402. scalePivot: Nullable<Vector3>;
  99403. private _anchorMesh;
  99404. private _existingMeshScale;
  99405. private _dragMesh;
  99406. private pointerDragBehavior;
  99407. private coloredMaterial;
  99408. private hoverColoredMaterial;
  99409. /**
  99410. * Sets the color of the bounding box gizmo
  99411. * @param color the color to set
  99412. */
  99413. setColor(color: Color3): void;
  99414. /**
  99415. * Creates an BoundingBoxGizmo
  99416. * @param gizmoLayer The utility layer the gizmo will be added to
  99417. * @param color The color of the gizmo
  99418. */
  99419. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  99420. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99421. private _selectNode;
  99422. /**
  99423. * Updates the bounding box information for the Gizmo
  99424. */
  99425. updateBoundingBox(): void;
  99426. private _updateRotationSpheres;
  99427. private _updateScaleBoxes;
  99428. /**
  99429. * Enables rotation on the specified axis and disables rotation on the others
  99430. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  99431. */
  99432. setEnabledRotationAxis(axis: string): void;
  99433. /**
  99434. * Enables/disables scaling
  99435. * @param enable if scaling should be enabled
  99436. */
  99437. setEnabledScaling(enable: boolean): void;
  99438. private _updateDummy;
  99439. /**
  99440. * Enables a pointer drag behavior on the bounding box of the gizmo
  99441. */
  99442. enableDragBehavior(): void;
  99443. /**
  99444. * Disposes of the gizmo
  99445. */
  99446. dispose(): void;
  99447. /**
  99448. * 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)
  99449. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  99450. * @returns the bounding box mesh with the passed in mesh as a child
  99451. */
  99452. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  99453. /**
  99454. * CustomMeshes are not supported by this gizmo
  99455. * @param mesh The mesh to replace the default mesh of the gizmo
  99456. */
  99457. setCustomMesh(mesh: Mesh): void;
  99458. }
  99459. }
  99460. declare module BABYLON {
  99461. /**
  99462. * Single plane rotation gizmo
  99463. */
  99464. export class PlaneRotationGizmo extends Gizmo {
  99465. /**
  99466. * Drag behavior responsible for the gizmos dragging interactions
  99467. */
  99468. dragBehavior: PointerDragBehavior;
  99469. private _pointerObserver;
  99470. /**
  99471. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  99472. */
  99473. snapDistance: number;
  99474. /**
  99475. * Event that fires each time the gizmo snaps to a new location.
  99476. * * snapDistance is the the change in distance
  99477. */
  99478. onSnapObservable: Observable<{
  99479. snapDistance: number;
  99480. }>;
  99481. /**
  99482. * Creates a PlaneRotationGizmo
  99483. * @param gizmoLayer The utility layer the gizmo will be added to
  99484. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  99485. * @param color The color of the gizmo
  99486. * @param tessellation Amount of tessellation to be used when creating rotation circles
  99487. */
  99488. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  99489. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99490. /**
  99491. * Disposes of the gizmo
  99492. */
  99493. dispose(): void;
  99494. }
  99495. }
  99496. declare module BABYLON {
  99497. /**
  99498. * Gizmo that enables rotating a mesh along 3 axis
  99499. */
  99500. export class RotationGizmo extends Gizmo {
  99501. /**
  99502. * Internal gizmo used for interactions on the x axis
  99503. */
  99504. xGizmo: PlaneRotationGizmo;
  99505. /**
  99506. * Internal gizmo used for interactions on the y axis
  99507. */
  99508. yGizmo: PlaneRotationGizmo;
  99509. /**
  99510. * Internal gizmo used for interactions on the z axis
  99511. */
  99512. zGizmo: PlaneRotationGizmo;
  99513. /** Fires an event when any of it's sub gizmos are dragged */
  99514. onDragStartObservable: Observable<{}>;
  99515. /** Fires an event when any of it's sub gizmos are released from dragging */
  99516. onDragEndObservable: Observable<{}>;
  99517. attachedMesh: Nullable<AbstractMesh>;
  99518. /**
  99519. * Creates a RotationGizmo
  99520. * @param gizmoLayer The utility layer the gizmo will be added to
  99521. * @param tessellation Amount of tessellation to be used when creating rotation circles
  99522. */
  99523. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  99524. updateGizmoRotationToMatchAttachedMesh: boolean;
  99525. /**
  99526. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99527. */
  99528. snapDistance: number;
  99529. /**
  99530. * Ratio for the scale of the gizmo (Default: 1)
  99531. */
  99532. scaleRatio: number;
  99533. /**
  99534. * Disposes of the gizmo
  99535. */
  99536. dispose(): void;
  99537. /**
  99538. * CustomMeshes are not supported by this gizmo
  99539. * @param mesh The mesh to replace the default mesh of the gizmo
  99540. */
  99541. setCustomMesh(mesh: Mesh): void;
  99542. }
  99543. }
  99544. declare module BABYLON {
  99545. /**
  99546. * Gizmo that enables dragging a mesh along 3 axis
  99547. */
  99548. export class PositionGizmo extends Gizmo {
  99549. /**
  99550. * Internal gizmo used for interactions on the x axis
  99551. */
  99552. xGizmo: AxisDragGizmo;
  99553. /**
  99554. * Internal gizmo used for interactions on the y axis
  99555. */
  99556. yGizmo: AxisDragGizmo;
  99557. /**
  99558. * Internal gizmo used for interactions on the z axis
  99559. */
  99560. zGizmo: AxisDragGizmo;
  99561. /** Fires an event when any of it's sub gizmos are dragged */
  99562. onDragStartObservable: Observable<{}>;
  99563. /** Fires an event when any of it's sub gizmos are released from dragging */
  99564. onDragEndObservable: Observable<{}>;
  99565. attachedMesh: Nullable<AbstractMesh>;
  99566. /**
  99567. * Creates a PositionGizmo
  99568. * @param gizmoLayer The utility layer the gizmo will be added to
  99569. */
  99570. constructor(gizmoLayer?: UtilityLayerRenderer);
  99571. updateGizmoRotationToMatchAttachedMesh: boolean;
  99572. /**
  99573. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99574. */
  99575. snapDistance: number;
  99576. /**
  99577. * Ratio for the scale of the gizmo (Default: 1)
  99578. */
  99579. scaleRatio: number;
  99580. /**
  99581. * Disposes of the gizmo
  99582. */
  99583. dispose(): void;
  99584. /**
  99585. * CustomMeshes are not supported by this gizmo
  99586. * @param mesh The mesh to replace the default mesh of the gizmo
  99587. */
  99588. setCustomMesh(mesh: Mesh): void;
  99589. }
  99590. }
  99591. declare module BABYLON {
  99592. /**
  99593. * Class containing static functions to help procedurally build meshes
  99594. */
  99595. export class PolyhedronBuilder {
  99596. /**
  99597. * Creates a polyhedron mesh
  99598. * * 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
  99599. * * The parameter `size` (positive float, default 1) sets the polygon size
  99600. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  99601. * * 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`
  99602. * * 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
  99603. * * 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)`)
  99604. * * 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
  99605. * * 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
  99606. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99607. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99608. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99609. * @param name defines the name of the mesh
  99610. * @param options defines the options used to create the mesh
  99611. * @param scene defines the hosting scene
  99612. * @returns the polyhedron mesh
  99613. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  99614. */
  99615. static CreatePolyhedron(name: string, options: {
  99616. type?: number;
  99617. size?: number;
  99618. sizeX?: number;
  99619. sizeY?: number;
  99620. sizeZ?: number;
  99621. custom?: any;
  99622. faceUV?: Vector4[];
  99623. faceColors?: Color4[];
  99624. flat?: boolean;
  99625. updatable?: boolean;
  99626. sideOrientation?: number;
  99627. frontUVs?: Vector4;
  99628. backUVs?: Vector4;
  99629. }, scene: Scene): Mesh;
  99630. }
  99631. }
  99632. declare module BABYLON {
  99633. /**
  99634. * Gizmo that enables scaling a mesh along 3 axis
  99635. */
  99636. export class ScaleGizmo extends Gizmo {
  99637. /**
  99638. * Internal gizmo used for interactions on the x axis
  99639. */
  99640. xGizmo: AxisScaleGizmo;
  99641. /**
  99642. * Internal gizmo used for interactions on the y axis
  99643. */
  99644. yGizmo: AxisScaleGizmo;
  99645. /**
  99646. * Internal gizmo used for interactions on the z axis
  99647. */
  99648. zGizmo: AxisScaleGizmo;
  99649. /**
  99650. * Internal gizmo used to scale all axis equally
  99651. */
  99652. uniformScaleGizmo: AxisScaleGizmo;
  99653. /** Fires an event when any of it's sub gizmos are dragged */
  99654. onDragStartObservable: Observable<{}>;
  99655. /** Fires an event when any of it's sub gizmos are released from dragging */
  99656. onDragEndObservable: Observable<{}>;
  99657. attachedMesh: Nullable<AbstractMesh>;
  99658. /**
  99659. * Creates a ScaleGizmo
  99660. * @param gizmoLayer The utility layer the gizmo will be added to
  99661. */
  99662. constructor(gizmoLayer?: UtilityLayerRenderer);
  99663. updateGizmoRotationToMatchAttachedMesh: boolean;
  99664. /**
  99665. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99666. */
  99667. snapDistance: number;
  99668. /**
  99669. * Ratio for the scale of the gizmo (Default: 1)
  99670. */
  99671. scaleRatio: number;
  99672. /**
  99673. * Disposes of the gizmo
  99674. */
  99675. dispose(): void;
  99676. }
  99677. }
  99678. declare module BABYLON {
  99679. /**
  99680. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  99681. */
  99682. export class GizmoManager implements IDisposable {
  99683. private scene;
  99684. /**
  99685. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  99686. */
  99687. gizmos: {
  99688. positionGizmo: Nullable<PositionGizmo>;
  99689. rotationGizmo: Nullable<RotationGizmo>;
  99690. scaleGizmo: Nullable<ScaleGizmo>;
  99691. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  99692. };
  99693. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  99694. clearGizmoOnEmptyPointerEvent: boolean;
  99695. /** Fires an event when the manager is attached to a mesh */
  99696. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  99697. private _gizmosEnabled;
  99698. private _pointerObserver;
  99699. private _attachedMesh;
  99700. private _boundingBoxColor;
  99701. private _defaultUtilityLayer;
  99702. private _defaultKeepDepthUtilityLayer;
  99703. /**
  99704. * When bounding box gizmo is enabled, this can be used to track drag/end events
  99705. */
  99706. boundingBoxDragBehavior: SixDofDragBehavior;
  99707. /**
  99708. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  99709. */
  99710. attachableMeshes: Nullable<Array<AbstractMesh>>;
  99711. /**
  99712. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  99713. */
  99714. usePointerToAttachGizmos: boolean;
  99715. /**
  99716. * Instatiates a gizmo manager
  99717. * @param scene the scene to overlay the gizmos on top of
  99718. */
  99719. constructor(scene: Scene);
  99720. /**
  99721. * Attaches a set of gizmos to the specified mesh
  99722. * @param mesh The mesh the gizmo's should be attached to
  99723. */
  99724. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  99725. /**
  99726. * If the position gizmo is enabled
  99727. */
  99728. positionGizmoEnabled: boolean;
  99729. /**
  99730. * If the rotation gizmo is enabled
  99731. */
  99732. rotationGizmoEnabled: boolean;
  99733. /**
  99734. * If the scale gizmo is enabled
  99735. */
  99736. scaleGizmoEnabled: boolean;
  99737. /**
  99738. * If the boundingBox gizmo is enabled
  99739. */
  99740. boundingBoxGizmoEnabled: boolean;
  99741. /**
  99742. * Disposes of the gizmo manager
  99743. */
  99744. dispose(): void;
  99745. }
  99746. }
  99747. declare module BABYLON {
  99748. /**
  99749. * Gizmo that enables viewing a light
  99750. */
  99751. export class LightGizmo extends Gizmo {
  99752. private _box;
  99753. /**
  99754. * Creates a LightGizmo
  99755. * @param gizmoLayer The utility layer the gizmo will be added to
  99756. */
  99757. constructor(gizmoLayer?: UtilityLayerRenderer);
  99758. private _light;
  99759. /**
  99760. * The light that the gizmo is attached to
  99761. */
  99762. light: Nullable<Light>;
  99763. /**
  99764. * @hidden
  99765. * Updates the gizmo to match the attached mesh's position/rotation
  99766. */
  99767. protected _update(): void;
  99768. }
  99769. }
  99770. declare module BABYLON {
  99771. /** @hidden */
  99772. export var backgroundFragmentDeclaration: {
  99773. name: string;
  99774. shader: string;
  99775. };
  99776. }
  99777. declare module BABYLON {
  99778. /** @hidden */
  99779. export var backgroundUboDeclaration: {
  99780. name: string;
  99781. shader: string;
  99782. };
  99783. }
  99784. declare module BABYLON {
  99785. /** @hidden */
  99786. export var backgroundPixelShader: {
  99787. name: string;
  99788. shader: string;
  99789. };
  99790. }
  99791. declare module BABYLON {
  99792. /** @hidden */
  99793. export var backgroundVertexDeclaration: {
  99794. name: string;
  99795. shader: string;
  99796. };
  99797. }
  99798. declare module BABYLON {
  99799. /** @hidden */
  99800. export var backgroundVertexShader: {
  99801. name: string;
  99802. shader: string;
  99803. };
  99804. }
  99805. declare module BABYLON {
  99806. /**
  99807. * Background material used to create an efficient environement around your scene.
  99808. */
  99809. export class BackgroundMaterial extends PushMaterial {
  99810. /**
  99811. * Standard reflectance value at parallel view angle.
  99812. */
  99813. static StandardReflectance0: number;
  99814. /**
  99815. * Standard reflectance value at grazing angle.
  99816. */
  99817. static StandardReflectance90: number;
  99818. protected _primaryColor: Color3;
  99819. /**
  99820. * Key light Color (multiply against the environement texture)
  99821. */
  99822. primaryColor: Color3;
  99823. protected __perceptualColor: Nullable<Color3>;
  99824. /**
  99825. * Experimental Internal Use Only.
  99826. *
  99827. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  99828. * This acts as a helper to set the primary color to a more "human friendly" value.
  99829. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  99830. * output color as close as possible from the chosen value.
  99831. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  99832. * part of lighting setup.)
  99833. */
  99834. _perceptualColor: Nullable<Color3>;
  99835. protected _primaryColorShadowLevel: float;
  99836. /**
  99837. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  99838. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  99839. */
  99840. primaryColorShadowLevel: float;
  99841. protected _primaryColorHighlightLevel: float;
  99842. /**
  99843. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  99844. * The primary color is used at the level chosen to define what the white area would look.
  99845. */
  99846. primaryColorHighlightLevel: float;
  99847. protected _reflectionTexture: Nullable<BaseTexture>;
  99848. /**
  99849. * Reflection Texture used in the material.
  99850. * Should be author in a specific way for the best result (refer to the documentation).
  99851. */
  99852. reflectionTexture: Nullable<BaseTexture>;
  99853. protected _reflectionBlur: float;
  99854. /**
  99855. * Reflection Texture level of blur.
  99856. *
  99857. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  99858. * texture twice.
  99859. */
  99860. reflectionBlur: float;
  99861. protected _diffuseTexture: Nullable<BaseTexture>;
  99862. /**
  99863. * Diffuse Texture used in the material.
  99864. * Should be author in a specific way for the best result (refer to the documentation).
  99865. */
  99866. diffuseTexture: Nullable<BaseTexture>;
  99867. protected _shadowLights: Nullable<IShadowLight[]>;
  99868. /**
  99869. * Specify the list of lights casting shadow on the material.
  99870. * All scene shadow lights will be included if null.
  99871. */
  99872. shadowLights: Nullable<IShadowLight[]>;
  99873. protected _shadowLevel: float;
  99874. /**
  99875. * Helps adjusting the shadow to a softer level if required.
  99876. * 0 means black shadows and 1 means no shadows.
  99877. */
  99878. shadowLevel: float;
  99879. protected _sceneCenter: Vector3;
  99880. /**
  99881. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  99882. * It is usually zero but might be interesting to modify according to your setup.
  99883. */
  99884. sceneCenter: Vector3;
  99885. protected _opacityFresnel: boolean;
  99886. /**
  99887. * This helps specifying that the material is falling off to the sky box at grazing angle.
  99888. * This helps ensuring a nice transition when the camera goes under the ground.
  99889. */
  99890. opacityFresnel: boolean;
  99891. protected _reflectionFresnel: boolean;
  99892. /**
  99893. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  99894. * This helps adding a mirror texture on the ground.
  99895. */
  99896. reflectionFresnel: boolean;
  99897. protected _reflectionFalloffDistance: number;
  99898. /**
  99899. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  99900. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  99901. */
  99902. reflectionFalloffDistance: number;
  99903. protected _reflectionAmount: number;
  99904. /**
  99905. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  99906. */
  99907. reflectionAmount: number;
  99908. protected _reflectionReflectance0: number;
  99909. /**
  99910. * This specifies the weight of the reflection at grazing angle.
  99911. */
  99912. reflectionReflectance0: number;
  99913. protected _reflectionReflectance90: number;
  99914. /**
  99915. * This specifies the weight of the reflection at a perpendicular point of view.
  99916. */
  99917. reflectionReflectance90: number;
  99918. /**
  99919. * Sets the reflection reflectance fresnel values according to the default standard
  99920. * empirically know to work well :-)
  99921. */
  99922. reflectionStandardFresnelWeight: number;
  99923. protected _useRGBColor: boolean;
  99924. /**
  99925. * Helps to directly use the maps channels instead of their level.
  99926. */
  99927. useRGBColor: boolean;
  99928. protected _enableNoise: boolean;
  99929. /**
  99930. * This helps reducing the banding effect that could occur on the background.
  99931. */
  99932. enableNoise: boolean;
  99933. /**
  99934. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  99935. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  99936. * Recommended to be keep at 1.0 except for special cases.
  99937. */
  99938. fovMultiplier: number;
  99939. private _fovMultiplier;
  99940. /**
  99941. * Enable the FOV adjustment feature controlled by fovMultiplier.
  99942. */
  99943. useEquirectangularFOV: boolean;
  99944. private _maxSimultaneousLights;
  99945. /**
  99946. * Number of Simultaneous lights allowed on the material.
  99947. */
  99948. maxSimultaneousLights: int;
  99949. /**
  99950. * Default configuration related to image processing available in the Background Material.
  99951. */
  99952. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99953. /**
  99954. * Keep track of the image processing observer to allow dispose and replace.
  99955. */
  99956. private _imageProcessingObserver;
  99957. /**
  99958. * Attaches a new image processing configuration to the PBR Material.
  99959. * @param configuration (if null the scene configuration will be use)
  99960. */
  99961. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99962. /**
  99963. * Gets the image processing configuration used either in this material.
  99964. */
  99965. /**
  99966. * Sets the Default image processing configuration used either in the this material.
  99967. *
  99968. * If sets to null, the scene one is in use.
  99969. */
  99970. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  99971. /**
  99972. * Gets wether the color curves effect is enabled.
  99973. */
  99974. /**
  99975. * Sets wether the color curves effect is enabled.
  99976. */
  99977. cameraColorCurvesEnabled: boolean;
  99978. /**
  99979. * Gets wether the color grading effect is enabled.
  99980. */
  99981. /**
  99982. * Gets wether the color grading effect is enabled.
  99983. */
  99984. cameraColorGradingEnabled: boolean;
  99985. /**
  99986. * Gets wether tonemapping is enabled or not.
  99987. */
  99988. /**
  99989. * Sets wether tonemapping is enabled or not
  99990. */
  99991. cameraToneMappingEnabled: boolean;
  99992. /**
  99993. * The camera exposure used on this material.
  99994. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99995. * This corresponds to a photographic exposure.
  99996. */
  99997. /**
  99998. * The camera exposure used on this material.
  99999. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  100000. * This corresponds to a photographic exposure.
  100001. */
  100002. cameraExposure: float;
  100003. /**
  100004. * Gets The camera contrast used on this material.
  100005. */
  100006. /**
  100007. * Sets The camera contrast used on this material.
  100008. */
  100009. cameraContrast: float;
  100010. /**
  100011. * Gets the Color Grading 2D Lookup Texture.
  100012. */
  100013. /**
  100014. * Sets the Color Grading 2D Lookup Texture.
  100015. */
  100016. cameraColorGradingTexture: Nullable<BaseTexture>;
  100017. /**
  100018. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100019. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100020. * 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;
  100021. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100022. */
  100023. /**
  100024. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100025. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100026. * 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;
  100027. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100028. */
  100029. cameraColorCurves: Nullable<ColorCurves>;
  100030. /**
  100031. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  100032. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  100033. */
  100034. switchToBGR: boolean;
  100035. private _renderTargets;
  100036. private _reflectionControls;
  100037. private _white;
  100038. private _primaryShadowColor;
  100039. private _primaryHighlightColor;
  100040. /**
  100041. * Instantiates a Background Material in the given scene
  100042. * @param name The friendly name of the material
  100043. * @param scene The scene to add the material to
  100044. */
  100045. constructor(name: string, scene: Scene);
  100046. /**
  100047. * Gets a boolean indicating that current material needs to register RTT
  100048. */
  100049. readonly hasRenderTargetTextures: boolean;
  100050. /**
  100051. * The entire material has been created in order to prevent overdraw.
  100052. * @returns false
  100053. */
  100054. needAlphaTesting(): boolean;
  100055. /**
  100056. * The entire material has been created in order to prevent overdraw.
  100057. * @returns true if blending is enable
  100058. */
  100059. needAlphaBlending(): boolean;
  100060. /**
  100061. * Checks wether the material is ready to be rendered for a given mesh.
  100062. * @param mesh The mesh to render
  100063. * @param subMesh The submesh to check against
  100064. * @param useInstances Specify wether or not the material is used with instances
  100065. * @returns true if all the dependencies are ready (Textures, Effects...)
  100066. */
  100067. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  100068. /**
  100069. * Compute the primary color according to the chosen perceptual color.
  100070. */
  100071. private _computePrimaryColorFromPerceptualColor;
  100072. /**
  100073. * Compute the highlights and shadow colors according to their chosen levels.
  100074. */
  100075. private _computePrimaryColors;
  100076. /**
  100077. * Build the uniform buffer used in the material.
  100078. */
  100079. buildUniformLayout(): void;
  100080. /**
  100081. * Unbind the material.
  100082. */
  100083. unbind(): void;
  100084. /**
  100085. * Bind only the world matrix to the material.
  100086. * @param world The world matrix to bind.
  100087. */
  100088. bindOnlyWorldMatrix(world: Matrix): void;
  100089. /**
  100090. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  100091. * @param world The world matrix to bind.
  100092. * @param subMesh The submesh to bind for.
  100093. */
  100094. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100095. /**
  100096. * Dispose the material.
  100097. * @param forceDisposeEffect Force disposal of the associated effect.
  100098. * @param forceDisposeTextures Force disposal of the associated textures.
  100099. */
  100100. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  100101. /**
  100102. * Clones the material.
  100103. * @param name The cloned name.
  100104. * @returns The cloned material.
  100105. */
  100106. clone(name: string): BackgroundMaterial;
  100107. /**
  100108. * Serializes the current material to its JSON representation.
  100109. * @returns The JSON representation.
  100110. */
  100111. serialize(): any;
  100112. /**
  100113. * Gets the class name of the material
  100114. * @returns "BackgroundMaterial"
  100115. */
  100116. getClassName(): string;
  100117. /**
  100118. * Parse a JSON input to create back a background material.
  100119. * @param source The JSON data to parse
  100120. * @param scene The scene to create the parsed material in
  100121. * @param rootUrl The root url of the assets the material depends upon
  100122. * @returns the instantiated BackgroundMaterial.
  100123. */
  100124. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  100125. }
  100126. }
  100127. declare module BABYLON {
  100128. /**
  100129. * Represents the different options available during the creation of
  100130. * a Environment helper.
  100131. *
  100132. * This can control the default ground, skybox and image processing setup of your scene.
  100133. */
  100134. export interface IEnvironmentHelperOptions {
  100135. /**
  100136. * Specifies wether or not to create a ground.
  100137. * True by default.
  100138. */
  100139. createGround: boolean;
  100140. /**
  100141. * Specifies the ground size.
  100142. * 15 by default.
  100143. */
  100144. groundSize: number;
  100145. /**
  100146. * The texture used on the ground for the main color.
  100147. * Comes from the BabylonJS CDN by default.
  100148. *
  100149. * Remarks: Can be either a texture or a url.
  100150. */
  100151. groundTexture: string | BaseTexture;
  100152. /**
  100153. * The color mixed in the ground texture by default.
  100154. * BabylonJS clearColor by default.
  100155. */
  100156. groundColor: Color3;
  100157. /**
  100158. * Specifies the ground opacity.
  100159. * 1 by default.
  100160. */
  100161. groundOpacity: number;
  100162. /**
  100163. * Enables the ground to receive shadows.
  100164. * True by default.
  100165. */
  100166. enableGroundShadow: boolean;
  100167. /**
  100168. * Helps preventing the shadow to be fully black on the ground.
  100169. * 0.5 by default.
  100170. */
  100171. groundShadowLevel: number;
  100172. /**
  100173. * Creates a mirror texture attach to the ground.
  100174. * false by default.
  100175. */
  100176. enableGroundMirror: boolean;
  100177. /**
  100178. * Specifies the ground mirror size ratio.
  100179. * 0.3 by default as the default kernel is 64.
  100180. */
  100181. groundMirrorSizeRatio: number;
  100182. /**
  100183. * Specifies the ground mirror blur kernel size.
  100184. * 64 by default.
  100185. */
  100186. groundMirrorBlurKernel: number;
  100187. /**
  100188. * Specifies the ground mirror visibility amount.
  100189. * 1 by default
  100190. */
  100191. groundMirrorAmount: number;
  100192. /**
  100193. * Specifies the ground mirror reflectance weight.
  100194. * This uses the standard weight of the background material to setup the fresnel effect
  100195. * of the mirror.
  100196. * 1 by default.
  100197. */
  100198. groundMirrorFresnelWeight: number;
  100199. /**
  100200. * Specifies the ground mirror Falloff distance.
  100201. * This can helps reducing the size of the reflection.
  100202. * 0 by Default.
  100203. */
  100204. groundMirrorFallOffDistance: number;
  100205. /**
  100206. * Specifies the ground mirror texture type.
  100207. * Unsigned Int by Default.
  100208. */
  100209. groundMirrorTextureType: number;
  100210. /**
  100211. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  100212. * the shown objects.
  100213. */
  100214. groundYBias: number;
  100215. /**
  100216. * Specifies wether or not to create a skybox.
  100217. * True by default.
  100218. */
  100219. createSkybox: boolean;
  100220. /**
  100221. * Specifies the skybox size.
  100222. * 20 by default.
  100223. */
  100224. skyboxSize: number;
  100225. /**
  100226. * The texture used on the skybox for the main color.
  100227. * Comes from the BabylonJS CDN by default.
  100228. *
  100229. * Remarks: Can be either a texture or a url.
  100230. */
  100231. skyboxTexture: string | BaseTexture;
  100232. /**
  100233. * The color mixed in the skybox texture by default.
  100234. * BabylonJS clearColor by default.
  100235. */
  100236. skyboxColor: Color3;
  100237. /**
  100238. * The background rotation around the Y axis of the scene.
  100239. * This helps aligning the key lights of your scene with the background.
  100240. * 0 by default.
  100241. */
  100242. backgroundYRotation: number;
  100243. /**
  100244. * Compute automatically the size of the elements to best fit with the scene.
  100245. */
  100246. sizeAuto: boolean;
  100247. /**
  100248. * Default position of the rootMesh if autoSize is not true.
  100249. */
  100250. rootPosition: Vector3;
  100251. /**
  100252. * Sets up the image processing in the scene.
  100253. * true by default.
  100254. */
  100255. setupImageProcessing: boolean;
  100256. /**
  100257. * The texture used as your environment texture in the scene.
  100258. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  100259. *
  100260. * Remarks: Can be either a texture or a url.
  100261. */
  100262. environmentTexture: string | BaseTexture;
  100263. /**
  100264. * The value of the exposure to apply to the scene.
  100265. * 0.6 by default if setupImageProcessing is true.
  100266. */
  100267. cameraExposure: number;
  100268. /**
  100269. * The value of the contrast to apply to the scene.
  100270. * 1.6 by default if setupImageProcessing is true.
  100271. */
  100272. cameraContrast: number;
  100273. /**
  100274. * Specifies wether or not tonemapping should be enabled in the scene.
  100275. * true by default if setupImageProcessing is true.
  100276. */
  100277. toneMappingEnabled: boolean;
  100278. }
  100279. /**
  100280. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  100281. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  100282. * It also helps with the default setup of your imageProcessing configuration.
  100283. */
  100284. export class EnvironmentHelper {
  100285. /**
  100286. * Default ground texture URL.
  100287. */
  100288. private static _groundTextureCDNUrl;
  100289. /**
  100290. * Default skybox texture URL.
  100291. */
  100292. private static _skyboxTextureCDNUrl;
  100293. /**
  100294. * Default environment texture URL.
  100295. */
  100296. private static _environmentTextureCDNUrl;
  100297. /**
  100298. * Creates the default options for the helper.
  100299. */
  100300. private static _getDefaultOptions;
  100301. private _rootMesh;
  100302. /**
  100303. * Gets the root mesh created by the helper.
  100304. */
  100305. readonly rootMesh: Mesh;
  100306. private _skybox;
  100307. /**
  100308. * Gets the skybox created by the helper.
  100309. */
  100310. readonly skybox: Nullable<Mesh>;
  100311. private _skyboxTexture;
  100312. /**
  100313. * Gets the skybox texture created by the helper.
  100314. */
  100315. readonly skyboxTexture: Nullable<BaseTexture>;
  100316. private _skyboxMaterial;
  100317. /**
  100318. * Gets the skybox material created by the helper.
  100319. */
  100320. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  100321. private _ground;
  100322. /**
  100323. * Gets the ground mesh created by the helper.
  100324. */
  100325. readonly ground: Nullable<Mesh>;
  100326. private _groundTexture;
  100327. /**
  100328. * Gets the ground texture created by the helper.
  100329. */
  100330. readonly groundTexture: Nullable<BaseTexture>;
  100331. private _groundMirror;
  100332. /**
  100333. * Gets the ground mirror created by the helper.
  100334. */
  100335. readonly groundMirror: Nullable<MirrorTexture>;
  100336. /**
  100337. * Gets the ground mirror render list to helps pushing the meshes
  100338. * you wish in the ground reflection.
  100339. */
  100340. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  100341. private _groundMaterial;
  100342. /**
  100343. * Gets the ground material created by the helper.
  100344. */
  100345. readonly groundMaterial: Nullable<BackgroundMaterial>;
  100346. /**
  100347. * Stores the creation options.
  100348. */
  100349. private readonly _scene;
  100350. private _options;
  100351. /**
  100352. * This observable will be notified with any error during the creation of the environment,
  100353. * mainly texture creation errors.
  100354. */
  100355. onErrorObservable: Observable<{
  100356. message?: string;
  100357. exception?: any;
  100358. }>;
  100359. /**
  100360. * constructor
  100361. * @param options Defines the options we want to customize the helper
  100362. * @param scene The scene to add the material to
  100363. */
  100364. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  100365. /**
  100366. * Updates the background according to the new options
  100367. * @param options
  100368. */
  100369. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  100370. /**
  100371. * Sets the primary color of all the available elements.
  100372. * @param color the main color to affect to the ground and the background
  100373. */
  100374. setMainColor(color: Color3): void;
  100375. /**
  100376. * Setup the image processing according to the specified options.
  100377. */
  100378. private _setupImageProcessing;
  100379. /**
  100380. * Setup the environment texture according to the specified options.
  100381. */
  100382. private _setupEnvironmentTexture;
  100383. /**
  100384. * Setup the background according to the specified options.
  100385. */
  100386. private _setupBackground;
  100387. /**
  100388. * Get the scene sizes according to the setup.
  100389. */
  100390. private _getSceneSize;
  100391. /**
  100392. * Setup the ground according to the specified options.
  100393. */
  100394. private _setupGround;
  100395. /**
  100396. * Setup the ground material according to the specified options.
  100397. */
  100398. private _setupGroundMaterial;
  100399. /**
  100400. * Setup the ground diffuse texture according to the specified options.
  100401. */
  100402. private _setupGroundDiffuseTexture;
  100403. /**
  100404. * Setup the ground mirror texture according to the specified options.
  100405. */
  100406. private _setupGroundMirrorTexture;
  100407. /**
  100408. * Setup the ground to receive the mirror texture.
  100409. */
  100410. private _setupMirrorInGroundMaterial;
  100411. /**
  100412. * Setup the skybox according to the specified options.
  100413. */
  100414. private _setupSkybox;
  100415. /**
  100416. * Setup the skybox material according to the specified options.
  100417. */
  100418. private _setupSkyboxMaterial;
  100419. /**
  100420. * Setup the skybox reflection texture according to the specified options.
  100421. */
  100422. private _setupSkyboxReflectionTexture;
  100423. private _errorHandler;
  100424. /**
  100425. * Dispose all the elements created by the Helper.
  100426. */
  100427. dispose(): void;
  100428. }
  100429. }
  100430. declare module BABYLON {
  100431. /**
  100432. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  100433. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  100434. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  100435. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  100436. */
  100437. export class PhotoDome extends TransformNode {
  100438. private _useDirectMapping;
  100439. /**
  100440. * The texture being displayed on the sphere
  100441. */
  100442. protected _photoTexture: Texture;
  100443. /**
  100444. * Gets or sets the texture being displayed on the sphere
  100445. */
  100446. photoTexture: Texture;
  100447. /**
  100448. * Observable raised when an error occured while loading the 360 image
  100449. */
  100450. onLoadErrorObservable: Observable<string>;
  100451. /**
  100452. * The skybox material
  100453. */
  100454. protected _material: BackgroundMaterial;
  100455. /**
  100456. * The surface used for the skybox
  100457. */
  100458. protected _mesh: Mesh;
  100459. /**
  100460. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  100461. * Also see the options.resolution property.
  100462. */
  100463. fovMultiplier: number;
  100464. /**
  100465. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  100466. * @param name Element's name, child elements will append suffixes for their own names.
  100467. * @param urlsOfPhoto defines the url of the photo to display
  100468. * @param options defines an object containing optional or exposed sub element properties
  100469. * @param onError defines a callback called when an error occured while loading the texture
  100470. */
  100471. constructor(name: string, urlOfPhoto: string, options: {
  100472. resolution?: number;
  100473. size?: number;
  100474. useDirectMapping?: boolean;
  100475. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  100476. /**
  100477. * Releases resources associated with this node.
  100478. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  100479. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  100480. */
  100481. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  100482. }
  100483. }
  100484. declare module BABYLON {
  100485. /**
  100486. * Class used to host texture specific utilities
  100487. */
  100488. export class TextureTools {
  100489. /**
  100490. * Uses the GPU to create a copy texture rescaled at a given size
  100491. * @param texture Texture to copy from
  100492. * @param width defines the desired width
  100493. * @param height defines the desired height
  100494. * @param useBilinearMode defines if bilinear mode has to be used
  100495. * @return the generated texture
  100496. */
  100497. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  100498. /**
  100499. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  100500. * @param scene defines the hosting scene
  100501. * @returns the environment BRDF texture
  100502. */
  100503. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  100504. private static _environmentBRDFBase64Texture;
  100505. }
  100506. }
  100507. declare module BABYLON {
  100508. /**
  100509. * @hidden
  100510. */
  100511. export interface IMaterialClearCoatDefines {
  100512. CLEARCOAT: boolean;
  100513. CLEARCOAT_DEFAULTIOR: boolean;
  100514. CLEARCOAT_TEXTURE: boolean;
  100515. CLEARCOAT_TEXTUREDIRECTUV: number;
  100516. CLEARCOAT_BUMP: boolean;
  100517. CLEARCOAT_BUMPDIRECTUV: number;
  100518. CLEARCOAT_TINT: boolean;
  100519. CLEARCOAT_TINT_TEXTURE: boolean;
  100520. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  100521. /** @hidden */
  100522. _areTexturesDirty: boolean;
  100523. }
  100524. /**
  100525. * Define the code related to the clear coat parameters of the pbr material.
  100526. */
  100527. export class PBRClearCoatConfiguration {
  100528. /**
  100529. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  100530. * The default fits with a polyurethane material.
  100531. */
  100532. private static readonly _DefaultIndiceOfRefraction;
  100533. private _isEnabled;
  100534. /**
  100535. * Defines if the clear coat is enabled in the material.
  100536. */
  100537. isEnabled: boolean;
  100538. /**
  100539. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  100540. */
  100541. intensity: number;
  100542. /**
  100543. * Defines the clear coat layer roughness.
  100544. */
  100545. roughness: number;
  100546. private _indiceOfRefraction;
  100547. /**
  100548. * Defines the indice of refraction of the clear coat.
  100549. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  100550. * The default fits with a polyurethane material.
  100551. * Changing the default value is more performance intensive.
  100552. */
  100553. indiceOfRefraction: number;
  100554. private _texture;
  100555. /**
  100556. * Stores the clear coat values in a texture.
  100557. */
  100558. texture: Nullable<BaseTexture>;
  100559. private _bumpTexture;
  100560. /**
  100561. * Define the clear coat specific bump texture.
  100562. */
  100563. bumpTexture: Nullable<BaseTexture>;
  100564. private _isTintEnabled;
  100565. /**
  100566. * Defines if the clear coat tint is enabled in the material.
  100567. */
  100568. isTintEnabled: boolean;
  100569. /**
  100570. * Defines if the clear coat tint is enabled in the material.
  100571. * This is only use if tint is enabled
  100572. */
  100573. tintColor: Color3;
  100574. /**
  100575. * Defines if the distance at which the tint color should be found in the
  100576. * clear coat media.
  100577. * This is only use if tint is enabled
  100578. */
  100579. tintColorAtDistance: number;
  100580. /**
  100581. * Defines the clear coat layer thickness.
  100582. * This is only use if tint is enabled
  100583. */
  100584. tintThickness: number;
  100585. private _tintTexture;
  100586. /**
  100587. * Stores the clear tint values in a texture.
  100588. * rgb is tint
  100589. * a is a thickness factor
  100590. */
  100591. tintTexture: Nullable<BaseTexture>;
  100592. /** @hidden */
  100593. private _internalMarkAllSubMeshesAsTexturesDirty;
  100594. /** @hidden */
  100595. _markAllSubMeshesAsTexturesDirty(): void;
  100596. /**
  100597. * Instantiate a new istance of clear coat configuration.
  100598. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  100599. */
  100600. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  100601. /**
  100602. * Specifies that the submesh is ready to be used.
  100603. * @param defines the list of "defines" to update.
  100604. * @param scene defines the scene the material belongs to.
  100605. * @param engine defines the engine the material belongs to.
  100606. * @param disableBumpMap defines wether the material disables bump or not.
  100607. * @returns - boolean indicating that the submesh is ready or not.
  100608. */
  100609. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  100610. /**
  100611. * Checks to see if a texture is used in the material.
  100612. * @param defines the list of "defines" to update.
  100613. * @param scene defines the scene to the material belongs to.
  100614. */
  100615. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  100616. /**
  100617. * Binds the material data.
  100618. * @param uniformBuffer defines the Uniform buffer to fill in.
  100619. * @param scene defines the scene the material belongs to.
  100620. * @param engine defines the engine the material belongs to.
  100621. * @param disableBumpMap defines wether the material disables bump or not.
  100622. * @param isFrozen defines wether the material is frozen or not.
  100623. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  100624. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  100625. */
  100626. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  100627. /**
  100628. * Checks to see if a texture is used in the material.
  100629. * @param texture - Base texture to use.
  100630. * @returns - Boolean specifying if a texture is used in the material.
  100631. */
  100632. hasTexture(texture: BaseTexture): boolean;
  100633. /**
  100634. * Returns an array of the actively used textures.
  100635. * @param activeTextures Array of BaseTextures
  100636. */
  100637. getActiveTextures(activeTextures: BaseTexture[]): void;
  100638. /**
  100639. * Returns the animatable textures.
  100640. * @param animatables Array of animatable textures.
  100641. */
  100642. getAnimatables(animatables: IAnimatable[]): void;
  100643. /**
  100644. * Disposes the resources of the material.
  100645. * @param forceDisposeTextures - Forces the disposal of all textures.
  100646. */
  100647. dispose(forceDisposeTextures?: boolean): void;
  100648. /**
  100649. * Get the current class name of the texture useful for serialization or dynamic coding.
  100650. * @returns "PBRClearCoatConfiguration"
  100651. */
  100652. getClassName(): string;
  100653. /**
  100654. * Add fallbacks to the effect fallbacks list.
  100655. * @param defines defines the Base texture to use.
  100656. * @param fallbacks defines the current fallback list.
  100657. * @param currentRank defines the current fallback rank.
  100658. * @returns the new fallback rank.
  100659. */
  100660. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  100661. /**
  100662. * Add the required uniforms to the current list.
  100663. * @param uniforms defines the current uniform list.
  100664. */
  100665. static AddUniforms(uniforms: string[]): void;
  100666. /**
  100667. * Add the required samplers to the current list.
  100668. * @param samplers defines the current sampler list.
  100669. */
  100670. static AddSamplers(samplers: string[]): void;
  100671. /**
  100672. * Add the required uniforms to the current buffer.
  100673. * @param uniformBuffer defines the current uniform buffer.
  100674. */
  100675. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  100676. /**
  100677. * Makes a duplicate of the current configuration into another one.
  100678. * @param clearCoatConfiguration define the config where to copy the info
  100679. */
  100680. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  100681. /**
  100682. * Serializes this clear coat configuration.
  100683. * @returns - An object with the serialized config.
  100684. */
  100685. serialize(): any;
  100686. /**
  100687. * Parses a Clear Coat Configuration from a serialized object.
  100688. * @param source - Serialized object.
  100689. */
  100690. parse(source: any): void;
  100691. }
  100692. }
  100693. declare module BABYLON {
  100694. /**
  100695. * @hidden
  100696. */
  100697. export interface IMaterialAnisotropicDefines {
  100698. ANISOTROPIC: boolean;
  100699. ANISOTROPIC_TEXTURE: boolean;
  100700. ANISOTROPIC_TEXTUREDIRECTUV: number;
  100701. MAINUV1: boolean;
  100702. _areTexturesDirty: boolean;
  100703. _needUVs: boolean;
  100704. }
  100705. /**
  100706. * Define the code related to the anisotropic parameters of the pbr material.
  100707. */
  100708. export class PBRAnisotropicConfiguration {
  100709. private _isEnabled;
  100710. /**
  100711. * Defines if the anisotropy is enabled in the material.
  100712. */
  100713. isEnabled: boolean;
  100714. /**
  100715. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  100716. */
  100717. intensity: number;
  100718. /**
  100719. * Defines if the effect is along the tangents, bitangents or in between.
  100720. * By default, the effect is "strectching" the highlights along the tangents.
  100721. */
  100722. direction: Vector2;
  100723. private _texture;
  100724. /**
  100725. * Stores the anisotropy values in a texture.
  100726. * rg is direction (like normal from -1 to 1)
  100727. * b is a intensity
  100728. */
  100729. texture: Nullable<BaseTexture>;
  100730. /** @hidden */
  100731. private _internalMarkAllSubMeshesAsTexturesDirty;
  100732. /** @hidden */
  100733. _markAllSubMeshesAsTexturesDirty(): void;
  100734. /**
  100735. * Instantiate a new istance of anisotropy configuration.
  100736. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  100737. */
  100738. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  100739. /**
  100740. * Specifies that the submesh is ready to be used.
  100741. * @param defines the list of "defines" to update.
  100742. * @param scene defines the scene the material belongs to.
  100743. * @returns - boolean indicating that the submesh is ready or not.
  100744. */
  100745. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  100746. /**
  100747. * Checks to see if a texture is used in the material.
  100748. * @param defines the list of "defines" to update.
  100749. * @param mesh the mesh we are preparing the defines for.
  100750. * @param scene defines the scene the material belongs to.
  100751. */
  100752. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  100753. /**
  100754. * Binds the material data.
  100755. * @param uniformBuffer defines the Uniform buffer to fill in.
  100756. * @param scene defines the scene the material belongs to.
  100757. * @param isFrozen defines wether the material is frozen or not.
  100758. */
  100759. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  100760. /**
  100761. * Checks to see if a texture is used in the material.
  100762. * @param texture - Base texture to use.
  100763. * @returns - Boolean specifying if a texture is used in the material.
  100764. */
  100765. hasTexture(texture: BaseTexture): boolean;
  100766. /**
  100767. * Returns an array of the actively used textures.
  100768. * @param activeTextures Array of BaseTextures
  100769. */
  100770. getActiveTextures(activeTextures: BaseTexture[]): void;
  100771. /**
  100772. * Returns the animatable textures.
  100773. * @param animatables Array of animatable textures.
  100774. */
  100775. getAnimatables(animatables: IAnimatable[]): void;
  100776. /**
  100777. * Disposes the resources of the material.
  100778. * @param forceDisposeTextures - Forces the disposal of all textures.
  100779. */
  100780. dispose(forceDisposeTextures?: boolean): void;
  100781. /**
  100782. * Get the current class name of the texture useful for serialization or dynamic coding.
  100783. * @returns "PBRAnisotropicConfiguration"
  100784. */
  100785. getClassName(): string;
  100786. /**
  100787. * Add fallbacks to the effect fallbacks list.
  100788. * @param defines defines the Base texture to use.
  100789. * @param fallbacks defines the current fallback list.
  100790. * @param currentRank defines the current fallback rank.
  100791. * @returns the new fallback rank.
  100792. */
  100793. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  100794. /**
  100795. * Add the required uniforms to the current list.
  100796. * @param uniforms defines the current uniform list.
  100797. */
  100798. static AddUniforms(uniforms: string[]): void;
  100799. /**
  100800. * Add the required uniforms to the current buffer.
  100801. * @param uniformBuffer defines the current uniform buffer.
  100802. */
  100803. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  100804. /**
  100805. * Add the required samplers to the current list.
  100806. * @param samplers defines the current sampler list.
  100807. */
  100808. static AddSamplers(samplers: string[]): void;
  100809. /**
  100810. * Makes a duplicate of the current configuration into another one.
  100811. * @param anisotropicConfiguration define the config where to copy the info
  100812. */
  100813. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  100814. /**
  100815. * Serializes this anisotropy configuration.
  100816. * @returns - An object with the serialized config.
  100817. */
  100818. serialize(): any;
  100819. /**
  100820. * Parses a anisotropy Configuration from a serialized object.
  100821. * @param source - Serialized object.
  100822. */
  100823. parse(source: any): void;
  100824. }
  100825. }
  100826. declare module BABYLON {
  100827. /**
  100828. * @hidden
  100829. */
  100830. export interface IMaterialBRDFDefines {
  100831. BRDF_V_HEIGHT_CORRELATED: boolean;
  100832. MS_BRDF_ENERGY_CONSERVATION: boolean;
  100833. /** @hidden */
  100834. _areMiscDirty: boolean;
  100835. }
  100836. /**
  100837. * Define the code related to the BRDF parameters of the pbr material.
  100838. */
  100839. export class PBRBRDFConfiguration {
  100840. private _useEnergyConservation;
  100841. /**
  100842. * Defines if the material uses energy conservation.
  100843. */
  100844. useEnergyConservation: boolean;
  100845. private _useSmithVisibilityHeightCorrelated;
  100846. /**
  100847. * LEGACY Mode set to false
  100848. * Defines if the material uses height smith correlated visibility term.
  100849. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  100850. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  100851. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  100852. * Not relying on height correlated will also disable energy conservation.
  100853. */
  100854. useSmithVisibilityHeightCorrelated: boolean;
  100855. /** @hidden */
  100856. private _internalMarkAllSubMeshesAsMiscDirty;
  100857. /** @hidden */
  100858. _markAllSubMeshesAsMiscDirty(): void;
  100859. /**
  100860. * Instantiate a new istance of clear coat configuration.
  100861. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  100862. */
  100863. constructor(markAllSubMeshesAsMiscDirty: () => void);
  100864. /**
  100865. * Checks to see if a texture is used in the material.
  100866. * @param defines the list of "defines" to update.
  100867. */
  100868. prepareDefines(defines: IMaterialBRDFDefines): void;
  100869. /**
  100870. * Get the current class name of the texture useful for serialization or dynamic coding.
  100871. * @returns "PBRClearCoatConfiguration"
  100872. */
  100873. getClassName(): string;
  100874. /**
  100875. * Makes a duplicate of the current configuration into another one.
  100876. * @param brdfConfiguration define the config where to copy the info
  100877. */
  100878. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  100879. /**
  100880. * Serializes this BRDF configuration.
  100881. * @returns - An object with the serialized config.
  100882. */
  100883. serialize(): any;
  100884. /**
  100885. * Parses a BRDF Configuration from a serialized object.
  100886. * @param source - Serialized object.
  100887. */
  100888. parse(source: any): void;
  100889. }
  100890. }
  100891. declare module BABYLON {
  100892. /**
  100893. * @hidden
  100894. */
  100895. export interface IMaterialSheenDefines {
  100896. SHEEN: boolean;
  100897. SHEEN_TEXTURE: boolean;
  100898. SHEEN_TEXTUREDIRECTUV: number;
  100899. SHEEN_LINKWITHALBEDO: boolean;
  100900. /** @hidden */
  100901. _areTexturesDirty: boolean;
  100902. }
  100903. /**
  100904. * Define the code related to the Sheen parameters of the pbr material.
  100905. */
  100906. export class PBRSheenConfiguration {
  100907. private _isEnabled;
  100908. /**
  100909. * Defines if the material uses sheen.
  100910. */
  100911. isEnabled: boolean;
  100912. private _linkSheenWithAlbedo;
  100913. /**
  100914. * Defines if the sheen is linked to the sheen color.
  100915. */
  100916. linkSheenWithAlbedo: boolean;
  100917. /**
  100918. * Defines the sheen intensity.
  100919. */
  100920. intensity: number;
  100921. /**
  100922. * Defines the sheen color.
  100923. */
  100924. color: Color3;
  100925. private _texture;
  100926. /**
  100927. * Stores the sheen tint values in a texture.
  100928. * rgb is tint
  100929. * a is a intensity
  100930. */
  100931. texture: Nullable<BaseTexture>;
  100932. /** @hidden */
  100933. private _internalMarkAllSubMeshesAsTexturesDirty;
  100934. /** @hidden */
  100935. _markAllSubMeshesAsTexturesDirty(): void;
  100936. /**
  100937. * Instantiate a new istance of clear coat configuration.
  100938. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  100939. */
  100940. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  100941. /**
  100942. * Specifies that the submesh is ready to be used.
  100943. * @param defines the list of "defines" to update.
  100944. * @param scene defines the scene the material belongs to.
  100945. * @returns - boolean indicating that the submesh is ready or not.
  100946. */
  100947. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  100948. /**
  100949. * Checks to see if a texture is used in the material.
  100950. * @param defines the list of "defines" to update.
  100951. * @param scene defines the scene the material belongs to.
  100952. */
  100953. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  100954. /**
  100955. * Binds the material data.
  100956. * @param uniformBuffer defines the Uniform buffer to fill in.
  100957. * @param scene defines the scene the material belongs to.
  100958. * @param isFrozen defines wether the material is frozen or not.
  100959. */
  100960. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  100961. /**
  100962. * Checks to see if a texture is used in the material.
  100963. * @param texture - Base texture to use.
  100964. * @returns - Boolean specifying if a texture is used in the material.
  100965. */
  100966. hasTexture(texture: BaseTexture): boolean;
  100967. /**
  100968. * Returns an array of the actively used textures.
  100969. * @param activeTextures Array of BaseTextures
  100970. */
  100971. getActiveTextures(activeTextures: BaseTexture[]): void;
  100972. /**
  100973. * Returns the animatable textures.
  100974. * @param animatables Array of animatable textures.
  100975. */
  100976. getAnimatables(animatables: IAnimatable[]): void;
  100977. /**
  100978. * Disposes the resources of the material.
  100979. * @param forceDisposeTextures - Forces the disposal of all textures.
  100980. */
  100981. dispose(forceDisposeTextures?: boolean): void;
  100982. /**
  100983. * Get the current class name of the texture useful for serialization or dynamic coding.
  100984. * @returns "PBRSheenConfiguration"
  100985. */
  100986. getClassName(): string;
  100987. /**
  100988. * Add fallbacks to the effect fallbacks list.
  100989. * @param defines defines the Base texture to use.
  100990. * @param fallbacks defines the current fallback list.
  100991. * @param currentRank defines the current fallback rank.
  100992. * @returns the new fallback rank.
  100993. */
  100994. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  100995. /**
  100996. * Add the required uniforms to the current list.
  100997. * @param uniforms defines the current uniform list.
  100998. */
  100999. static AddUniforms(uniforms: string[]): void;
  101000. /**
  101001. * Add the required uniforms to the current buffer.
  101002. * @param uniformBuffer defines the current uniform buffer.
  101003. */
  101004. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  101005. /**
  101006. * Add the required samplers to the current list.
  101007. * @param samplers defines the current sampler list.
  101008. */
  101009. static AddSamplers(samplers: string[]): void;
  101010. /**
  101011. * Makes a duplicate of the current configuration into another one.
  101012. * @param sheenConfiguration define the config where to copy the info
  101013. */
  101014. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  101015. /**
  101016. * Serializes this BRDF configuration.
  101017. * @returns - An object with the serialized config.
  101018. */
  101019. serialize(): any;
  101020. /**
  101021. * Parses a Sheen Configuration from a serialized object.
  101022. * @param source - Serialized object.
  101023. */
  101024. parse(source: any): void;
  101025. }
  101026. }
  101027. declare module BABYLON {
  101028. /** @hidden */
  101029. export var pbrFragmentDeclaration: {
  101030. name: string;
  101031. shader: string;
  101032. };
  101033. }
  101034. declare module BABYLON {
  101035. /** @hidden */
  101036. export var pbrUboDeclaration: {
  101037. name: string;
  101038. shader: string;
  101039. };
  101040. }
  101041. declare module BABYLON {
  101042. /** @hidden */
  101043. export var pbrFunctions: {
  101044. name: string;
  101045. shader: string;
  101046. };
  101047. }
  101048. declare module BABYLON {
  101049. /** @hidden */
  101050. export var harmonicsFunctions: {
  101051. name: string;
  101052. shader: string;
  101053. };
  101054. }
  101055. declare module BABYLON {
  101056. /** @hidden */
  101057. export var pbrPreLightingFunctions: {
  101058. name: string;
  101059. shader: string;
  101060. };
  101061. }
  101062. declare module BABYLON {
  101063. /** @hidden */
  101064. export var pbrFalloffLightingFunctions: {
  101065. name: string;
  101066. shader: string;
  101067. };
  101068. }
  101069. declare module BABYLON {
  101070. /** @hidden */
  101071. export var pbrLightingFunctions: {
  101072. name: string;
  101073. shader: string;
  101074. };
  101075. }
  101076. declare module BABYLON {
  101077. /** @hidden */
  101078. export var pbrDebug: {
  101079. name: string;
  101080. shader: string;
  101081. };
  101082. }
  101083. declare module BABYLON {
  101084. /** @hidden */
  101085. export var pbrPixelShader: {
  101086. name: string;
  101087. shader: string;
  101088. };
  101089. }
  101090. declare module BABYLON {
  101091. /** @hidden */
  101092. export var pbrVertexDeclaration: {
  101093. name: string;
  101094. shader: string;
  101095. };
  101096. }
  101097. declare module BABYLON {
  101098. /** @hidden */
  101099. export var pbrVertexShader: {
  101100. name: string;
  101101. shader: string;
  101102. };
  101103. }
  101104. declare module BABYLON {
  101105. /**
  101106. * The Physically based material base class of BJS.
  101107. *
  101108. * This offers the main features of a standard PBR material.
  101109. * For more information, please refer to the documentation :
  101110. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  101111. */
  101112. export abstract class PBRBaseMaterial extends PushMaterial {
  101113. /**
  101114. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  101115. */
  101116. static readonly PBRMATERIAL_OPAQUE: number;
  101117. /**
  101118. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  101119. */
  101120. static readonly PBRMATERIAL_ALPHATEST: number;
  101121. /**
  101122. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101123. */
  101124. static readonly PBRMATERIAL_ALPHABLEND: number;
  101125. /**
  101126. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101127. * They are also discarded below the alpha cutoff threshold to improve performances.
  101128. */
  101129. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  101130. /**
  101131. * Defines the default value of how much AO map is occluding the analytical lights
  101132. * (point spot...).
  101133. */
  101134. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  101135. /**
  101136. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  101137. */
  101138. static readonly LIGHTFALLOFF_PHYSICAL: number;
  101139. /**
  101140. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  101141. * to enhance interoperability with other engines.
  101142. */
  101143. static readonly LIGHTFALLOFF_GLTF: number;
  101144. /**
  101145. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  101146. * to enhance interoperability with other materials.
  101147. */
  101148. static readonly LIGHTFALLOFF_STANDARD: number;
  101149. /**
  101150. * Intensity of the direct lights e.g. the four lights available in your scene.
  101151. * This impacts both the direct diffuse and specular highlights.
  101152. */
  101153. protected _directIntensity: number;
  101154. /**
  101155. * Intensity of the emissive part of the material.
  101156. * This helps controlling the emissive effect without modifying the emissive color.
  101157. */
  101158. protected _emissiveIntensity: number;
  101159. /**
  101160. * Intensity of the environment e.g. how much the environment will light the object
  101161. * either through harmonics for rough material or through the refelction for shiny ones.
  101162. */
  101163. protected _environmentIntensity: number;
  101164. /**
  101165. * This is a special control allowing the reduction of the specular highlights coming from the
  101166. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  101167. */
  101168. protected _specularIntensity: number;
  101169. /**
  101170. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  101171. */
  101172. private _lightingInfos;
  101173. /**
  101174. * Debug Control allowing disabling the bump map on this material.
  101175. */
  101176. protected _disableBumpMap: boolean;
  101177. /**
  101178. * AKA Diffuse Texture in standard nomenclature.
  101179. */
  101180. protected _albedoTexture: BaseTexture;
  101181. /**
  101182. * AKA Occlusion Texture in other nomenclature.
  101183. */
  101184. protected _ambientTexture: BaseTexture;
  101185. /**
  101186. * AKA Occlusion Texture Intensity in other nomenclature.
  101187. */
  101188. protected _ambientTextureStrength: number;
  101189. /**
  101190. * Defines how much the AO map is occluding the analytical lights (point spot...).
  101191. * 1 means it completely occludes it
  101192. * 0 mean it has no impact
  101193. */
  101194. protected _ambientTextureImpactOnAnalyticalLights: number;
  101195. /**
  101196. * Stores the alpha values in a texture.
  101197. */
  101198. protected _opacityTexture: BaseTexture;
  101199. /**
  101200. * Stores the reflection values in a texture.
  101201. */
  101202. protected _reflectionTexture: BaseTexture;
  101203. /**
  101204. * Stores the refraction values in a texture.
  101205. */
  101206. protected _refractionTexture: BaseTexture;
  101207. /**
  101208. * Stores the emissive values in a texture.
  101209. */
  101210. protected _emissiveTexture: BaseTexture;
  101211. /**
  101212. * AKA Specular texture in other nomenclature.
  101213. */
  101214. protected _reflectivityTexture: BaseTexture;
  101215. /**
  101216. * Used to switch from specular/glossiness to metallic/roughness workflow.
  101217. */
  101218. protected _metallicTexture: BaseTexture;
  101219. /**
  101220. * Specifies the metallic scalar of the metallic/roughness workflow.
  101221. * Can also be used to scale the metalness values of the metallic texture.
  101222. */
  101223. protected _metallic: Nullable<number>;
  101224. /**
  101225. * Specifies the roughness scalar of the metallic/roughness workflow.
  101226. * Can also be used to scale the roughness values of the metallic texture.
  101227. */
  101228. protected _roughness: Nullable<number>;
  101229. /**
  101230. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  101231. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  101232. */
  101233. protected _microSurfaceTexture: BaseTexture;
  101234. /**
  101235. * Stores surface normal data used to displace a mesh in a texture.
  101236. */
  101237. protected _bumpTexture: BaseTexture;
  101238. /**
  101239. * Stores the pre-calculated light information of a mesh in a texture.
  101240. */
  101241. protected _lightmapTexture: BaseTexture;
  101242. /**
  101243. * The color of a material in ambient lighting.
  101244. */
  101245. protected _ambientColor: Color3;
  101246. /**
  101247. * AKA Diffuse Color in other nomenclature.
  101248. */
  101249. protected _albedoColor: Color3;
  101250. /**
  101251. * AKA Specular Color in other nomenclature.
  101252. */
  101253. protected _reflectivityColor: Color3;
  101254. /**
  101255. * The color applied when light is reflected from a material.
  101256. */
  101257. protected _reflectionColor: Color3;
  101258. /**
  101259. * The color applied when light is emitted from a material.
  101260. */
  101261. protected _emissiveColor: Color3;
  101262. /**
  101263. * AKA Glossiness in other nomenclature.
  101264. */
  101265. protected _microSurface: number;
  101266. /**
  101267. * source material index of refraction (IOR)' / 'destination material IOR.
  101268. */
  101269. protected _indexOfRefraction: number;
  101270. /**
  101271. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  101272. */
  101273. protected _invertRefractionY: boolean;
  101274. /**
  101275. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  101276. * Materials half opaque for instance using refraction could benefit from this control.
  101277. */
  101278. protected _linkRefractionWithTransparency: boolean;
  101279. /**
  101280. * Specifies that the material will use the light map as a show map.
  101281. */
  101282. protected _useLightmapAsShadowmap: boolean;
  101283. /**
  101284. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  101285. * makes the reflect vector face the model (under horizon).
  101286. */
  101287. protected _useHorizonOcclusion: boolean;
  101288. /**
  101289. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  101290. * too much the area relying on ambient texture to define their ambient occlusion.
  101291. */
  101292. protected _useRadianceOcclusion: boolean;
  101293. /**
  101294. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  101295. */
  101296. protected _useAlphaFromAlbedoTexture: boolean;
  101297. /**
  101298. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  101299. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  101300. */
  101301. protected _useSpecularOverAlpha: boolean;
  101302. /**
  101303. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  101304. */
  101305. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  101306. /**
  101307. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  101308. */
  101309. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  101310. /**
  101311. * Specifies if the metallic texture contains the roughness information in its green channel.
  101312. */
  101313. protected _useRoughnessFromMetallicTextureGreen: boolean;
  101314. /**
  101315. * Specifies if the metallic texture contains the metallness information in its blue channel.
  101316. */
  101317. protected _useMetallnessFromMetallicTextureBlue: boolean;
  101318. /**
  101319. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  101320. */
  101321. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  101322. /**
  101323. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  101324. */
  101325. protected _useAmbientInGrayScale: boolean;
  101326. /**
  101327. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  101328. * The material will try to infer what glossiness each pixel should be.
  101329. */
  101330. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  101331. /**
  101332. * Defines the falloff type used in this material.
  101333. * It by default is Physical.
  101334. */
  101335. protected _lightFalloff: number;
  101336. /**
  101337. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  101338. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  101339. */
  101340. protected _useRadianceOverAlpha: boolean;
  101341. /**
  101342. * Allows using an object space normal map (instead of tangent space).
  101343. */
  101344. protected _useObjectSpaceNormalMap: boolean;
  101345. /**
  101346. * Allows using the bump map in parallax mode.
  101347. */
  101348. protected _useParallax: boolean;
  101349. /**
  101350. * Allows using the bump map in parallax occlusion mode.
  101351. */
  101352. protected _useParallaxOcclusion: boolean;
  101353. /**
  101354. * Controls the scale bias of the parallax mode.
  101355. */
  101356. protected _parallaxScaleBias: number;
  101357. /**
  101358. * If sets to true, disables all the lights affecting the material.
  101359. */
  101360. protected _disableLighting: boolean;
  101361. /**
  101362. * Number of Simultaneous lights allowed on the material.
  101363. */
  101364. protected _maxSimultaneousLights: number;
  101365. /**
  101366. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  101367. */
  101368. protected _invertNormalMapX: boolean;
  101369. /**
  101370. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  101371. */
  101372. protected _invertNormalMapY: boolean;
  101373. /**
  101374. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  101375. */
  101376. protected _twoSidedLighting: boolean;
  101377. /**
  101378. * Defines the alpha limits in alpha test mode.
  101379. */
  101380. protected _alphaCutOff: number;
  101381. /**
  101382. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  101383. */
  101384. protected _forceAlphaTest: boolean;
  101385. /**
  101386. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  101387. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  101388. */
  101389. protected _useAlphaFresnel: boolean;
  101390. /**
  101391. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  101392. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  101393. */
  101394. protected _useLinearAlphaFresnel: boolean;
  101395. /**
  101396. * The transparency mode of the material.
  101397. */
  101398. protected _transparencyMode: Nullable<number>;
  101399. /**
  101400. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  101401. * from cos thetav and roughness:
  101402. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  101403. */
  101404. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  101405. /**
  101406. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  101407. */
  101408. protected _forceIrradianceInFragment: boolean;
  101409. /**
  101410. * Force normal to face away from face.
  101411. */
  101412. protected _forceNormalForward: boolean;
  101413. /**
  101414. * Enables specular anti aliasing in the PBR shader.
  101415. * It will both interacts on the Geometry for analytical and IBL lighting.
  101416. * It also prefilter the roughness map based on the bump values.
  101417. */
  101418. protected _enableSpecularAntiAliasing: boolean;
  101419. /**
  101420. * Default configuration related to image processing available in the PBR Material.
  101421. */
  101422. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101423. /**
  101424. * Keep track of the image processing observer to allow dispose and replace.
  101425. */
  101426. private _imageProcessingObserver;
  101427. /**
  101428. * Attaches a new image processing configuration to the PBR Material.
  101429. * @param configuration
  101430. */
  101431. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  101432. /**
  101433. * Stores the available render targets.
  101434. */
  101435. private _renderTargets;
  101436. /**
  101437. * Sets the global ambient color for the material used in lighting calculations.
  101438. */
  101439. private _globalAmbientColor;
  101440. /**
  101441. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  101442. */
  101443. private _useLogarithmicDepth;
  101444. /**
  101445. * If set to true, no lighting calculations will be applied.
  101446. */
  101447. private _unlit;
  101448. private _debugMode;
  101449. /**
  101450. * @hidden
  101451. * This is reserved for the inspector.
  101452. * Defines the material debug mode.
  101453. * It helps seeing only some components of the material while troubleshooting.
  101454. */
  101455. debugMode: number;
  101456. /**
  101457. * @hidden
  101458. * This is reserved for the inspector.
  101459. * Specify from where on screen the debug mode should start.
  101460. * The value goes from -1 (full screen) to 1 (not visible)
  101461. * It helps with side by side comparison against the final render
  101462. * This defaults to -1
  101463. */
  101464. private debugLimit;
  101465. /**
  101466. * @hidden
  101467. * This is reserved for the inspector.
  101468. * As the default viewing range might not be enough (if the ambient is really small for instance)
  101469. * You can use the factor to better multiply the final value.
  101470. */
  101471. private debugFactor;
  101472. /**
  101473. * Defines the clear coat layer parameters for the material.
  101474. */
  101475. readonly clearCoat: PBRClearCoatConfiguration;
  101476. /**
  101477. * Defines the anisotropic parameters for the material.
  101478. */
  101479. readonly anisotropy: PBRAnisotropicConfiguration;
  101480. /**
  101481. * Defines the BRDF parameters for the material.
  101482. */
  101483. readonly brdf: PBRBRDFConfiguration;
  101484. /**
  101485. * Defines the Sheen parameters for the material.
  101486. */
  101487. readonly sheen: PBRSheenConfiguration;
  101488. /**
  101489. * Instantiates a new PBRMaterial instance.
  101490. *
  101491. * @param name The material name
  101492. * @param scene The scene the material will be use in.
  101493. */
  101494. constructor(name: string, scene: Scene);
  101495. /**
  101496. * Gets a boolean indicating that current material needs to register RTT
  101497. */
  101498. readonly hasRenderTargetTextures: boolean;
  101499. /**
  101500. * Gets the name of the material class.
  101501. */
  101502. getClassName(): string;
  101503. /**
  101504. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  101505. */
  101506. /**
  101507. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  101508. */
  101509. useLogarithmicDepth: boolean;
  101510. /**
  101511. * Gets the current transparency mode.
  101512. */
  101513. /**
  101514. * Sets the transparency mode of the material.
  101515. *
  101516. * | Value | Type | Description |
  101517. * | ----- | ----------------------------------- | ----------- |
  101518. * | 0 | OPAQUE | |
  101519. * | 1 | ALPHATEST | |
  101520. * | 2 | ALPHABLEND | |
  101521. * | 3 | ALPHATESTANDBLEND | |
  101522. *
  101523. */
  101524. transparencyMode: Nullable<number>;
  101525. /**
  101526. * Returns true if alpha blending should be disabled.
  101527. */
  101528. private readonly _disableAlphaBlending;
  101529. /**
  101530. * Specifies whether or not this material should be rendered in alpha blend mode.
  101531. */
  101532. needAlphaBlending(): boolean;
  101533. /**
  101534. * Specifies if the mesh will require alpha blending.
  101535. * @param mesh - BJS mesh.
  101536. */
  101537. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  101538. /**
  101539. * Specifies whether or not this material should be rendered in alpha test mode.
  101540. */
  101541. needAlphaTesting(): boolean;
  101542. /**
  101543. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  101544. */
  101545. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  101546. /**
  101547. * Gets the texture used for the alpha test.
  101548. */
  101549. getAlphaTestTexture(): BaseTexture;
  101550. /**
  101551. * Specifies that the submesh is ready to be used.
  101552. * @param mesh - BJS mesh.
  101553. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  101554. * @param useInstances - Specifies that instances should be used.
  101555. * @returns - boolean indicating that the submesh is ready or not.
  101556. */
  101557. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101558. /**
  101559. * Specifies if the material uses metallic roughness workflow.
  101560. * @returns boolean specifiying if the material uses metallic roughness workflow.
  101561. */
  101562. isMetallicWorkflow(): boolean;
  101563. private _prepareEffect;
  101564. private _prepareDefines;
  101565. /**
  101566. * Force shader compilation
  101567. */
  101568. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  101569. clipPlane: boolean;
  101570. }>): void;
  101571. /**
  101572. * Initializes the uniform buffer layout for the shader.
  101573. */
  101574. buildUniformLayout(): void;
  101575. /**
  101576. * Unbinds the textures.
  101577. */
  101578. unbind(): void;
  101579. /**
  101580. * Binds the submesh data.
  101581. * @param world - The world matrix.
  101582. * @param mesh - The BJS mesh.
  101583. * @param subMesh - A submesh of the BJS mesh.
  101584. */
  101585. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101586. /**
  101587. * Returns the animatable textures.
  101588. * @returns - Array of animatable textures.
  101589. */
  101590. getAnimatables(): IAnimatable[];
  101591. /**
  101592. * Returns the texture used for reflections.
  101593. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  101594. */
  101595. private _getReflectionTexture;
  101596. /**
  101597. * Returns the texture used for refraction or null if none is used.
  101598. * @returns - Refection texture if present. If no refraction texture and refraction
  101599. * is linked with transparency, returns environment texture. Otherwise, returns null.
  101600. */
  101601. private _getRefractionTexture;
  101602. /**
  101603. * Returns an array of the actively used textures.
  101604. * @returns - Array of BaseTextures
  101605. */
  101606. getActiveTextures(): BaseTexture[];
  101607. /**
  101608. * Checks to see if a texture is used in the material.
  101609. * @param texture - Base texture to use.
  101610. * @returns - Boolean specifying if a texture is used in the material.
  101611. */
  101612. hasTexture(texture: BaseTexture): boolean;
  101613. /**
  101614. * Disposes the resources of the material.
  101615. * @param forceDisposeEffect - Forces the disposal of effects.
  101616. * @param forceDisposeTextures - Forces the disposal of all textures.
  101617. */
  101618. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  101619. }
  101620. }
  101621. declare module BABYLON {
  101622. /**
  101623. * The Physically based material of BJS.
  101624. *
  101625. * This offers the main features of a standard PBR material.
  101626. * For more information, please refer to the documentation :
  101627. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  101628. */
  101629. export class PBRMaterial extends PBRBaseMaterial {
  101630. /**
  101631. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  101632. */
  101633. static readonly PBRMATERIAL_OPAQUE: number;
  101634. /**
  101635. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  101636. */
  101637. static readonly PBRMATERIAL_ALPHATEST: number;
  101638. /**
  101639. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101640. */
  101641. static readonly PBRMATERIAL_ALPHABLEND: number;
  101642. /**
  101643. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101644. * They are also discarded below the alpha cutoff threshold to improve performances.
  101645. */
  101646. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  101647. /**
  101648. * Defines the default value of how much AO map is occluding the analytical lights
  101649. * (point spot...).
  101650. */
  101651. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  101652. /**
  101653. * Intensity of the direct lights e.g. the four lights available in your scene.
  101654. * This impacts both the direct diffuse and specular highlights.
  101655. */
  101656. directIntensity: number;
  101657. /**
  101658. * Intensity of the emissive part of the material.
  101659. * This helps controlling the emissive effect without modifying the emissive color.
  101660. */
  101661. emissiveIntensity: number;
  101662. /**
  101663. * Intensity of the environment e.g. how much the environment will light the object
  101664. * either through harmonics for rough material or through the refelction for shiny ones.
  101665. */
  101666. environmentIntensity: number;
  101667. /**
  101668. * This is a special control allowing the reduction of the specular highlights coming from the
  101669. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  101670. */
  101671. specularIntensity: number;
  101672. /**
  101673. * Debug Control allowing disabling the bump map on this material.
  101674. */
  101675. disableBumpMap: boolean;
  101676. /**
  101677. * AKA Diffuse Texture in standard nomenclature.
  101678. */
  101679. albedoTexture: BaseTexture;
  101680. /**
  101681. * AKA Occlusion Texture in other nomenclature.
  101682. */
  101683. ambientTexture: BaseTexture;
  101684. /**
  101685. * AKA Occlusion Texture Intensity in other nomenclature.
  101686. */
  101687. ambientTextureStrength: number;
  101688. /**
  101689. * Defines how much the AO map is occluding the analytical lights (point spot...).
  101690. * 1 means it completely occludes it
  101691. * 0 mean it has no impact
  101692. */
  101693. ambientTextureImpactOnAnalyticalLights: number;
  101694. /**
  101695. * Stores the alpha values in a texture.
  101696. */
  101697. opacityTexture: BaseTexture;
  101698. /**
  101699. * Stores the reflection values in a texture.
  101700. */
  101701. reflectionTexture: Nullable<BaseTexture>;
  101702. /**
  101703. * Stores the emissive values in a texture.
  101704. */
  101705. emissiveTexture: BaseTexture;
  101706. /**
  101707. * AKA Specular texture in other nomenclature.
  101708. */
  101709. reflectivityTexture: BaseTexture;
  101710. /**
  101711. * Used to switch from specular/glossiness to metallic/roughness workflow.
  101712. */
  101713. metallicTexture: BaseTexture;
  101714. /**
  101715. * Specifies the metallic scalar of the metallic/roughness workflow.
  101716. * Can also be used to scale the metalness values of the metallic texture.
  101717. */
  101718. metallic: Nullable<number>;
  101719. /**
  101720. * Specifies the roughness scalar of the metallic/roughness workflow.
  101721. * Can also be used to scale the roughness values of the metallic texture.
  101722. */
  101723. roughness: Nullable<number>;
  101724. /**
  101725. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  101726. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  101727. */
  101728. microSurfaceTexture: BaseTexture;
  101729. /**
  101730. * Stores surface normal data used to displace a mesh in a texture.
  101731. */
  101732. bumpTexture: BaseTexture;
  101733. /**
  101734. * Stores the pre-calculated light information of a mesh in a texture.
  101735. */
  101736. lightmapTexture: BaseTexture;
  101737. /**
  101738. * Stores the refracted light information in a texture.
  101739. */
  101740. refractionTexture: BaseTexture;
  101741. /**
  101742. * The color of a material in ambient lighting.
  101743. */
  101744. ambientColor: Color3;
  101745. /**
  101746. * AKA Diffuse Color in other nomenclature.
  101747. */
  101748. albedoColor: Color3;
  101749. /**
  101750. * AKA Specular Color in other nomenclature.
  101751. */
  101752. reflectivityColor: Color3;
  101753. /**
  101754. * The color reflected from the material.
  101755. */
  101756. reflectionColor: Color3;
  101757. /**
  101758. * The color emitted from the material.
  101759. */
  101760. emissiveColor: Color3;
  101761. /**
  101762. * AKA Glossiness in other nomenclature.
  101763. */
  101764. microSurface: number;
  101765. /**
  101766. * source material index of refraction (IOR)' / 'destination material IOR.
  101767. */
  101768. indexOfRefraction: number;
  101769. /**
  101770. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  101771. */
  101772. invertRefractionY: boolean;
  101773. /**
  101774. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  101775. * Materials half opaque for instance using refraction could benefit from this control.
  101776. */
  101777. linkRefractionWithTransparency: boolean;
  101778. /**
  101779. * If true, the light map contains occlusion information instead of lighting info.
  101780. */
  101781. useLightmapAsShadowmap: boolean;
  101782. /**
  101783. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  101784. */
  101785. useAlphaFromAlbedoTexture: boolean;
  101786. /**
  101787. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  101788. */
  101789. forceAlphaTest: boolean;
  101790. /**
  101791. * Defines the alpha limits in alpha test mode.
  101792. */
  101793. alphaCutOff: number;
  101794. /**
  101795. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  101796. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  101797. */
  101798. useSpecularOverAlpha: boolean;
  101799. /**
  101800. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  101801. */
  101802. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  101803. /**
  101804. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  101805. */
  101806. useRoughnessFromMetallicTextureAlpha: boolean;
  101807. /**
  101808. * Specifies if the metallic texture contains the roughness information in its green channel.
  101809. */
  101810. useRoughnessFromMetallicTextureGreen: boolean;
  101811. /**
  101812. * Specifies if the metallic texture contains the metallness information in its blue channel.
  101813. */
  101814. useMetallnessFromMetallicTextureBlue: boolean;
  101815. /**
  101816. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  101817. */
  101818. useAmbientOcclusionFromMetallicTextureRed: boolean;
  101819. /**
  101820. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  101821. */
  101822. useAmbientInGrayScale: boolean;
  101823. /**
  101824. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  101825. * The material will try to infer what glossiness each pixel should be.
  101826. */
  101827. useAutoMicroSurfaceFromReflectivityMap: boolean;
  101828. /**
  101829. * BJS is using an harcoded light falloff based on a manually sets up range.
  101830. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  101831. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  101832. */
  101833. /**
  101834. * BJS is using an harcoded light falloff based on a manually sets up range.
  101835. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  101836. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  101837. */
  101838. usePhysicalLightFalloff: boolean;
  101839. /**
  101840. * In order to support the falloff compatibility with gltf, a special mode has been added
  101841. * to reproduce the gltf light falloff.
  101842. */
  101843. /**
  101844. * In order to support the falloff compatibility with gltf, a special mode has been added
  101845. * to reproduce the gltf light falloff.
  101846. */
  101847. useGLTFLightFalloff: boolean;
  101848. /**
  101849. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  101850. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  101851. */
  101852. useRadianceOverAlpha: boolean;
  101853. /**
  101854. * Allows using an object space normal map (instead of tangent space).
  101855. */
  101856. useObjectSpaceNormalMap: boolean;
  101857. /**
  101858. * Allows using the bump map in parallax mode.
  101859. */
  101860. useParallax: boolean;
  101861. /**
  101862. * Allows using the bump map in parallax occlusion mode.
  101863. */
  101864. useParallaxOcclusion: boolean;
  101865. /**
  101866. * Controls the scale bias of the parallax mode.
  101867. */
  101868. parallaxScaleBias: number;
  101869. /**
  101870. * If sets to true, disables all the lights affecting the material.
  101871. */
  101872. disableLighting: boolean;
  101873. /**
  101874. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  101875. */
  101876. forceIrradianceInFragment: boolean;
  101877. /**
  101878. * Number of Simultaneous lights allowed on the material.
  101879. */
  101880. maxSimultaneousLights: number;
  101881. /**
  101882. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  101883. */
  101884. invertNormalMapX: boolean;
  101885. /**
  101886. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  101887. */
  101888. invertNormalMapY: boolean;
  101889. /**
  101890. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  101891. */
  101892. twoSidedLighting: boolean;
  101893. /**
  101894. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  101895. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  101896. */
  101897. useAlphaFresnel: boolean;
  101898. /**
  101899. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  101900. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  101901. */
  101902. useLinearAlphaFresnel: boolean;
  101903. /**
  101904. * Let user defines the brdf lookup texture used for IBL.
  101905. * A default 8bit version is embedded but you could point at :
  101906. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  101907. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  101908. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  101909. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  101910. */
  101911. environmentBRDFTexture: Nullable<BaseTexture>;
  101912. /**
  101913. * Force normal to face away from face.
  101914. */
  101915. forceNormalForward: boolean;
  101916. /**
  101917. * Enables specular anti aliasing in the PBR shader.
  101918. * It will both interacts on the Geometry for analytical and IBL lighting.
  101919. * It also prefilter the roughness map based on the bump values.
  101920. */
  101921. enableSpecularAntiAliasing: boolean;
  101922. /**
  101923. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  101924. * makes the reflect vector face the model (under horizon).
  101925. */
  101926. useHorizonOcclusion: boolean;
  101927. /**
  101928. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  101929. * too much the area relying on ambient texture to define their ambient occlusion.
  101930. */
  101931. useRadianceOcclusion: boolean;
  101932. /**
  101933. * If set to true, no lighting calculations will be applied.
  101934. */
  101935. unlit: boolean;
  101936. /**
  101937. * Gets the image processing configuration used either in this material.
  101938. */
  101939. /**
  101940. * Sets the Default image processing configuration used either in the this material.
  101941. *
  101942. * If sets to null, the scene one is in use.
  101943. */
  101944. imageProcessingConfiguration: ImageProcessingConfiguration;
  101945. /**
  101946. * Gets wether the color curves effect is enabled.
  101947. */
  101948. /**
  101949. * Sets wether the color curves effect is enabled.
  101950. */
  101951. cameraColorCurvesEnabled: boolean;
  101952. /**
  101953. * Gets wether the color grading effect is enabled.
  101954. */
  101955. /**
  101956. * Gets wether the color grading effect is enabled.
  101957. */
  101958. cameraColorGradingEnabled: boolean;
  101959. /**
  101960. * Gets wether tonemapping is enabled or not.
  101961. */
  101962. /**
  101963. * Sets wether tonemapping is enabled or not
  101964. */
  101965. cameraToneMappingEnabled: boolean;
  101966. /**
  101967. * The camera exposure used on this material.
  101968. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101969. * This corresponds to a photographic exposure.
  101970. */
  101971. /**
  101972. * The camera exposure used on this material.
  101973. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101974. * This corresponds to a photographic exposure.
  101975. */
  101976. cameraExposure: number;
  101977. /**
  101978. * Gets The camera contrast used on this material.
  101979. */
  101980. /**
  101981. * Sets The camera contrast used on this material.
  101982. */
  101983. cameraContrast: number;
  101984. /**
  101985. * Gets the Color Grading 2D Lookup Texture.
  101986. */
  101987. /**
  101988. * Sets the Color Grading 2D Lookup Texture.
  101989. */
  101990. cameraColorGradingTexture: Nullable<BaseTexture>;
  101991. /**
  101992. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101993. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101994. * 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;
  101995. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101996. */
  101997. /**
  101998. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101999. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102000. * 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;
  102001. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102002. */
  102003. cameraColorCurves: Nullable<ColorCurves>;
  102004. /**
  102005. * Instantiates a new PBRMaterial instance.
  102006. *
  102007. * @param name The material name
  102008. * @param scene The scene the material will be use in.
  102009. */
  102010. constructor(name: string, scene: Scene);
  102011. /**
  102012. * Returns the name of this material class.
  102013. */
  102014. getClassName(): string;
  102015. /**
  102016. * Makes a duplicate of the current material.
  102017. * @param name - name to use for the new material.
  102018. */
  102019. clone(name: string): PBRMaterial;
  102020. /**
  102021. * Serializes this PBR Material.
  102022. * @returns - An object with the serialized material.
  102023. */
  102024. serialize(): any;
  102025. /**
  102026. * Parses a PBR Material from a serialized object.
  102027. * @param source - Serialized object.
  102028. * @param scene - BJS scene instance.
  102029. * @param rootUrl - url for the scene object
  102030. * @returns - PBRMaterial
  102031. */
  102032. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  102033. }
  102034. }
  102035. declare module BABYLON {
  102036. /**
  102037. * Direct draw surface info
  102038. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  102039. */
  102040. export interface DDSInfo {
  102041. /**
  102042. * Width of the texture
  102043. */
  102044. width: number;
  102045. /**
  102046. * Width of the texture
  102047. */
  102048. height: number;
  102049. /**
  102050. * Number of Mipmaps for the texture
  102051. * @see https://en.wikipedia.org/wiki/Mipmap
  102052. */
  102053. mipmapCount: number;
  102054. /**
  102055. * If the textures format is a known fourCC format
  102056. * @see https://www.fourcc.org/
  102057. */
  102058. isFourCC: boolean;
  102059. /**
  102060. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  102061. */
  102062. isRGB: boolean;
  102063. /**
  102064. * If the texture is a lumincance format
  102065. */
  102066. isLuminance: boolean;
  102067. /**
  102068. * If this is a cube texture
  102069. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  102070. */
  102071. isCube: boolean;
  102072. /**
  102073. * If the texture is a compressed format eg. FOURCC_DXT1
  102074. */
  102075. isCompressed: boolean;
  102076. /**
  102077. * The dxgiFormat of the texture
  102078. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  102079. */
  102080. dxgiFormat: number;
  102081. /**
  102082. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  102083. */
  102084. textureType: number;
  102085. /**
  102086. * Sphericle polynomial created for the dds texture
  102087. */
  102088. sphericalPolynomial?: SphericalPolynomial;
  102089. }
  102090. /**
  102091. * Class used to provide DDS decompression tools
  102092. */
  102093. export class DDSTools {
  102094. /**
  102095. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  102096. */
  102097. static StoreLODInAlphaChannel: boolean;
  102098. /**
  102099. * Gets DDS information from an array buffer
  102100. * @param arrayBuffer defines the array buffer to read data from
  102101. * @returns the DDS information
  102102. */
  102103. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  102104. private static _FloatView;
  102105. private static _Int32View;
  102106. private static _ToHalfFloat;
  102107. private static _FromHalfFloat;
  102108. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  102109. private static _GetHalfFloatRGBAArrayBuffer;
  102110. private static _GetFloatRGBAArrayBuffer;
  102111. private static _GetFloatAsUIntRGBAArrayBuffer;
  102112. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  102113. private static _GetRGBAArrayBuffer;
  102114. private static _ExtractLongWordOrder;
  102115. private static _GetRGBArrayBuffer;
  102116. private static _GetLuminanceArrayBuffer;
  102117. /**
  102118. * Uploads DDS Levels to a Babylon Texture
  102119. * @hidden
  102120. */
  102121. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  102122. }
  102123. interface Engine {
  102124. /**
  102125. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  102126. * @param rootUrl defines the url where the file to load is located
  102127. * @param scene defines the current scene
  102128. * @param lodScale defines scale to apply to the mip map selection
  102129. * @param lodOffset defines offset to apply to the mip map selection
  102130. * @param onLoad defines an optional callback raised when the texture is loaded
  102131. * @param onError defines an optional callback raised if there is an issue to load the texture
  102132. * @param format defines the format of the data
  102133. * @param forcedExtension defines the extension to use to pick the right loader
  102134. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  102135. * @returns the cube texture as an InternalTexture
  102136. */
  102137. 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;
  102138. }
  102139. }
  102140. declare module BABYLON {
  102141. /**
  102142. * Implementation of the DDS Texture Loader.
  102143. * @hidden
  102144. */
  102145. export class _DDSTextureLoader implements IInternalTextureLoader {
  102146. /**
  102147. * Defines wether the loader supports cascade loading the different faces.
  102148. */
  102149. readonly supportCascades: boolean;
  102150. /**
  102151. * This returns if the loader support the current file information.
  102152. * @param extension defines the file extension of the file being loaded
  102153. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102154. * @param fallback defines the fallback internal texture if any
  102155. * @param isBase64 defines whether the texture is encoded as a base64
  102156. * @param isBuffer defines whether the texture data are stored as a buffer
  102157. * @returns true if the loader can load the specified file
  102158. */
  102159. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102160. /**
  102161. * Transform the url before loading if required.
  102162. * @param rootUrl the url of the texture
  102163. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102164. * @returns the transformed texture
  102165. */
  102166. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102167. /**
  102168. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102169. * @param rootUrl the url of the texture
  102170. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102171. * @returns the fallback texture
  102172. */
  102173. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102174. /**
  102175. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102176. * @param data contains the texture data
  102177. * @param texture defines the BabylonJS internal texture
  102178. * @param createPolynomials will be true if polynomials have been requested
  102179. * @param onLoad defines the callback to trigger once the texture is ready
  102180. * @param onError defines the callback to trigger in case of error
  102181. */
  102182. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102183. /**
  102184. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102185. * @param data contains the texture data
  102186. * @param texture defines the BabylonJS internal texture
  102187. * @param callback defines the method to call once ready to upload
  102188. */
  102189. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  102190. }
  102191. }
  102192. declare module BABYLON {
  102193. /** @hidden */
  102194. export var rgbdEncodePixelShader: {
  102195. name: string;
  102196. shader: string;
  102197. };
  102198. }
  102199. declare module BABYLON {
  102200. /** @hidden */
  102201. export var rgbdDecodePixelShader: {
  102202. name: string;
  102203. shader: string;
  102204. };
  102205. }
  102206. declare module BABYLON {
  102207. /**
  102208. * Raw texture data and descriptor sufficient for WebGL texture upload
  102209. */
  102210. export interface EnvironmentTextureInfo {
  102211. /**
  102212. * Version of the environment map
  102213. */
  102214. version: number;
  102215. /**
  102216. * Width of image
  102217. */
  102218. width: number;
  102219. /**
  102220. * Irradiance information stored in the file.
  102221. */
  102222. irradiance: any;
  102223. /**
  102224. * Specular information stored in the file.
  102225. */
  102226. specular: any;
  102227. }
  102228. /**
  102229. * Sets of helpers addressing the serialization and deserialization of environment texture
  102230. * stored in a BabylonJS env file.
  102231. * Those files are usually stored as .env files.
  102232. */
  102233. export class EnvironmentTextureTools {
  102234. /**
  102235. * Magic number identifying the env file.
  102236. */
  102237. private static _MagicBytes;
  102238. /**
  102239. * Gets the environment info from an env file.
  102240. * @param data The array buffer containing the .env bytes.
  102241. * @returns the environment file info (the json header) if successfully parsed.
  102242. */
  102243. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  102244. /**
  102245. * Creates an environment texture from a loaded cube texture.
  102246. * @param texture defines the cube texture to convert in env file
  102247. * @return a promise containing the environment data if succesfull.
  102248. */
  102249. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  102250. /**
  102251. * Creates a JSON representation of the spherical data.
  102252. * @param texture defines the texture containing the polynomials
  102253. * @return the JSON representation of the spherical info
  102254. */
  102255. private static _CreateEnvTextureIrradiance;
  102256. /**
  102257. * Uploads the texture info contained in the env file to the GPU.
  102258. * @param texture defines the internal texture to upload to
  102259. * @param arrayBuffer defines the buffer cotaining the data to load
  102260. * @param info defines the texture info retrieved through the GetEnvInfo method
  102261. * @returns a promise
  102262. */
  102263. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  102264. /**
  102265. * Uploads the levels of image data to the GPU.
  102266. * @param texture defines the internal texture to upload to
  102267. * @param imageData defines the array buffer views of image data [mipmap][face]
  102268. * @returns a promise
  102269. */
  102270. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  102271. /**
  102272. * Uploads spherical polynomials information to the texture.
  102273. * @param texture defines the texture we are trying to upload the information to
  102274. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  102275. */
  102276. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  102277. /** @hidden */
  102278. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  102279. }
  102280. }
  102281. declare module BABYLON {
  102282. /**
  102283. * Implementation of the ENV Texture Loader.
  102284. * @hidden
  102285. */
  102286. export class _ENVTextureLoader implements IInternalTextureLoader {
  102287. /**
  102288. * Defines wether the loader supports cascade loading the different faces.
  102289. */
  102290. readonly supportCascades: boolean;
  102291. /**
  102292. * This returns if the loader support the current file information.
  102293. * @param extension defines the file extension of the file being loaded
  102294. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102295. * @param fallback defines the fallback internal texture if any
  102296. * @param isBase64 defines whether the texture is encoded as a base64
  102297. * @param isBuffer defines whether the texture data are stored as a buffer
  102298. * @returns true if the loader can load the specified file
  102299. */
  102300. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102301. /**
  102302. * Transform the url before loading if required.
  102303. * @param rootUrl the url of the texture
  102304. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102305. * @returns the transformed texture
  102306. */
  102307. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102308. /**
  102309. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102310. * @param rootUrl the url of the texture
  102311. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102312. * @returns the fallback texture
  102313. */
  102314. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102315. /**
  102316. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102317. * @param data contains the texture data
  102318. * @param texture defines the BabylonJS internal texture
  102319. * @param createPolynomials will be true if polynomials have been requested
  102320. * @param onLoad defines the callback to trigger once the texture is ready
  102321. * @param onError defines the callback to trigger in case of error
  102322. */
  102323. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102324. /**
  102325. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102326. * @param data contains the texture data
  102327. * @param texture defines the BabylonJS internal texture
  102328. * @param callback defines the method to call once ready to upload
  102329. */
  102330. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  102331. }
  102332. }
  102333. declare module BABYLON {
  102334. /**
  102335. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  102336. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  102337. */
  102338. export class KhronosTextureContainer {
  102339. /** contents of the KTX container file */
  102340. arrayBuffer: any;
  102341. private static HEADER_LEN;
  102342. private static COMPRESSED_2D;
  102343. private static COMPRESSED_3D;
  102344. private static TEX_2D;
  102345. private static TEX_3D;
  102346. /**
  102347. * Gets the openGL type
  102348. */
  102349. glType: number;
  102350. /**
  102351. * Gets the openGL type size
  102352. */
  102353. glTypeSize: number;
  102354. /**
  102355. * Gets the openGL format
  102356. */
  102357. glFormat: number;
  102358. /**
  102359. * Gets the openGL internal format
  102360. */
  102361. glInternalFormat: number;
  102362. /**
  102363. * Gets the base internal format
  102364. */
  102365. glBaseInternalFormat: number;
  102366. /**
  102367. * Gets image width in pixel
  102368. */
  102369. pixelWidth: number;
  102370. /**
  102371. * Gets image height in pixel
  102372. */
  102373. pixelHeight: number;
  102374. /**
  102375. * Gets image depth in pixels
  102376. */
  102377. pixelDepth: number;
  102378. /**
  102379. * Gets the number of array elements
  102380. */
  102381. numberOfArrayElements: number;
  102382. /**
  102383. * Gets the number of faces
  102384. */
  102385. numberOfFaces: number;
  102386. /**
  102387. * Gets the number of mipmap levels
  102388. */
  102389. numberOfMipmapLevels: number;
  102390. /**
  102391. * Gets the bytes of key value data
  102392. */
  102393. bytesOfKeyValueData: number;
  102394. /**
  102395. * Gets the load type
  102396. */
  102397. loadType: number;
  102398. /**
  102399. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  102400. */
  102401. isInvalid: boolean;
  102402. /**
  102403. * Creates a new KhronosTextureContainer
  102404. * @param arrayBuffer contents of the KTX container file
  102405. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  102406. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  102407. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  102408. */
  102409. constructor(
  102410. /** contents of the KTX container file */
  102411. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  102412. /**
  102413. * Uploads KTX content to a Babylon Texture.
  102414. * It is assumed that the texture has already been created & is currently bound
  102415. * @hidden
  102416. */
  102417. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  102418. private _upload2DCompressedLevels;
  102419. }
  102420. }
  102421. declare module BABYLON {
  102422. /**
  102423. * Implementation of the KTX Texture Loader.
  102424. * @hidden
  102425. */
  102426. export class _KTXTextureLoader implements IInternalTextureLoader {
  102427. /**
  102428. * Defines wether the loader supports cascade loading the different faces.
  102429. */
  102430. readonly supportCascades: boolean;
  102431. /**
  102432. * This returns if the loader support the current file information.
  102433. * @param extension defines the file extension of the file being loaded
  102434. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102435. * @param fallback defines the fallback internal texture if any
  102436. * @param isBase64 defines whether the texture is encoded as a base64
  102437. * @param isBuffer defines whether the texture data are stored as a buffer
  102438. * @returns true if the loader can load the specified file
  102439. */
  102440. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102441. /**
  102442. * Transform the url before loading if required.
  102443. * @param rootUrl the url of the texture
  102444. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102445. * @returns the transformed texture
  102446. */
  102447. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102448. /**
  102449. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102450. * @param rootUrl the url of the texture
  102451. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102452. * @returns the fallback texture
  102453. */
  102454. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102455. /**
  102456. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102457. * @param data contains the texture data
  102458. * @param texture defines the BabylonJS internal texture
  102459. * @param createPolynomials will be true if polynomials have been requested
  102460. * @param onLoad defines the callback to trigger once the texture is ready
  102461. * @param onError defines the callback to trigger in case of error
  102462. */
  102463. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102464. /**
  102465. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102466. * @param data contains the texture data
  102467. * @param texture defines the BabylonJS internal texture
  102468. * @param callback defines the method to call once ready to upload
  102469. */
  102470. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  102471. }
  102472. }
  102473. declare module BABYLON {
  102474. /** @hidden */
  102475. export var _forceSceneHelpersToBundle: boolean;
  102476. interface Scene {
  102477. /**
  102478. * Creates a default light for the scene.
  102479. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  102480. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  102481. */
  102482. createDefaultLight(replace?: boolean): void;
  102483. /**
  102484. * Creates a default camera for the scene.
  102485. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  102486. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  102487. * @param replace has default false, when true replaces the active camera in the scene
  102488. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  102489. */
  102490. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  102491. /**
  102492. * Creates a default camera and a default light.
  102493. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  102494. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  102495. * @param replace has the default false, when true replaces the active camera/light in the scene
  102496. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  102497. */
  102498. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  102499. /**
  102500. * Creates a new sky box
  102501. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  102502. * @param environmentTexture defines the texture to use as environment texture
  102503. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  102504. * @param scale defines the overall scale of the skybox
  102505. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  102506. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  102507. * @returns a new mesh holding the sky box
  102508. */
  102509. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  102510. /**
  102511. * Creates a new environment
  102512. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  102513. * @param options defines the options you can use to configure the environment
  102514. * @returns the new EnvironmentHelper
  102515. */
  102516. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  102517. /**
  102518. * Creates a new VREXperienceHelper
  102519. * @see http://doc.babylonjs.com/how_to/webvr_helper
  102520. * @param webVROptions defines the options used to create the new VREXperienceHelper
  102521. * @returns a new VREXperienceHelper
  102522. */
  102523. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  102524. /**
  102525. * Creates a new XREXperienceHelper
  102526. * @see http://doc.babylonjs.com/how_to/webxr
  102527. * @returns a promise for a new XREXperienceHelper
  102528. */
  102529. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  102530. }
  102531. }
  102532. declare module BABYLON {
  102533. /**
  102534. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  102535. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  102536. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  102537. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  102538. */
  102539. export class VideoDome extends TransformNode {
  102540. /**
  102541. * Define the video source as a Monoscopic panoramic 360 video.
  102542. */
  102543. static readonly MODE_MONOSCOPIC: number;
  102544. /**
  102545. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  102546. */
  102547. static readonly MODE_TOPBOTTOM: number;
  102548. /**
  102549. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  102550. */
  102551. static readonly MODE_SIDEBYSIDE: number;
  102552. private _useDirectMapping;
  102553. /**
  102554. * The video texture being displayed on the sphere
  102555. */
  102556. protected _videoTexture: VideoTexture;
  102557. /**
  102558. * Gets the video texture being displayed on the sphere
  102559. */
  102560. readonly videoTexture: VideoTexture;
  102561. /**
  102562. * The skybox material
  102563. */
  102564. protected _material: BackgroundMaterial;
  102565. /**
  102566. * The surface used for the skybox
  102567. */
  102568. protected _mesh: Mesh;
  102569. /**
  102570. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  102571. * Also see the options.resolution property.
  102572. */
  102573. fovMultiplier: number;
  102574. private _videoMode;
  102575. /**
  102576. * Gets or set the current video mode for the video. It can be:
  102577. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  102578. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  102579. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  102580. */
  102581. videoMode: number;
  102582. /**
  102583. * Oberserver used in Stereoscopic VR Mode.
  102584. */
  102585. private _onBeforeCameraRenderObserver;
  102586. /**
  102587. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  102588. * @param name Element's name, child elements will append suffixes for their own names.
  102589. * @param urlsOrVideo defines the url(s) or the video element to use
  102590. * @param options An object containing optional or exposed sub element properties
  102591. */
  102592. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  102593. resolution?: number;
  102594. clickToPlay?: boolean;
  102595. autoPlay?: boolean;
  102596. loop?: boolean;
  102597. size?: number;
  102598. poster?: string;
  102599. useDirectMapping?: boolean;
  102600. }, scene: Scene);
  102601. private _changeVideoMode;
  102602. /**
  102603. * Releases resources associated with this node.
  102604. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  102605. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  102606. */
  102607. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  102608. }
  102609. }
  102610. declare module BABYLON {
  102611. /**
  102612. * This class can be used to get instrumentation data from a Babylon engine
  102613. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  102614. */
  102615. export class EngineInstrumentation implements IDisposable {
  102616. /**
  102617. * Define the instrumented engine.
  102618. */
  102619. engine: Engine;
  102620. private _captureGPUFrameTime;
  102621. private _gpuFrameTimeToken;
  102622. private _gpuFrameTime;
  102623. private _captureShaderCompilationTime;
  102624. private _shaderCompilationTime;
  102625. private _onBeginFrameObserver;
  102626. private _onEndFrameObserver;
  102627. private _onBeforeShaderCompilationObserver;
  102628. private _onAfterShaderCompilationObserver;
  102629. /**
  102630. * Gets the perf counter used for GPU frame time
  102631. */
  102632. readonly gpuFrameTimeCounter: PerfCounter;
  102633. /**
  102634. * Gets the GPU frame time capture status
  102635. */
  102636. /**
  102637. * Enable or disable the GPU frame time capture
  102638. */
  102639. captureGPUFrameTime: boolean;
  102640. /**
  102641. * Gets the perf counter used for shader compilation time
  102642. */
  102643. readonly shaderCompilationTimeCounter: PerfCounter;
  102644. /**
  102645. * Gets the shader compilation time capture status
  102646. */
  102647. /**
  102648. * Enable or disable the shader compilation time capture
  102649. */
  102650. captureShaderCompilationTime: boolean;
  102651. /**
  102652. * Instantiates a new engine instrumentation.
  102653. * This class can be used to get instrumentation data from a Babylon engine
  102654. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  102655. * @param engine Defines the engine to instrument
  102656. */
  102657. constructor(
  102658. /**
  102659. * Define the instrumented engine.
  102660. */
  102661. engine: Engine);
  102662. /**
  102663. * Dispose and release associated resources.
  102664. */
  102665. dispose(): void;
  102666. }
  102667. }
  102668. declare module BABYLON {
  102669. /**
  102670. * This class can be used to get instrumentation data from a Babylon engine
  102671. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  102672. */
  102673. export class SceneInstrumentation implements IDisposable {
  102674. /**
  102675. * Defines the scene to instrument
  102676. */
  102677. scene: Scene;
  102678. private _captureActiveMeshesEvaluationTime;
  102679. private _activeMeshesEvaluationTime;
  102680. private _captureRenderTargetsRenderTime;
  102681. private _renderTargetsRenderTime;
  102682. private _captureFrameTime;
  102683. private _frameTime;
  102684. private _captureRenderTime;
  102685. private _renderTime;
  102686. private _captureInterFrameTime;
  102687. private _interFrameTime;
  102688. private _captureParticlesRenderTime;
  102689. private _particlesRenderTime;
  102690. private _captureSpritesRenderTime;
  102691. private _spritesRenderTime;
  102692. private _capturePhysicsTime;
  102693. private _physicsTime;
  102694. private _captureAnimationsTime;
  102695. private _animationsTime;
  102696. private _captureCameraRenderTime;
  102697. private _cameraRenderTime;
  102698. private _onBeforeActiveMeshesEvaluationObserver;
  102699. private _onAfterActiveMeshesEvaluationObserver;
  102700. private _onBeforeRenderTargetsRenderObserver;
  102701. private _onAfterRenderTargetsRenderObserver;
  102702. private _onAfterRenderObserver;
  102703. private _onBeforeDrawPhaseObserver;
  102704. private _onAfterDrawPhaseObserver;
  102705. private _onBeforeAnimationsObserver;
  102706. private _onBeforeParticlesRenderingObserver;
  102707. private _onAfterParticlesRenderingObserver;
  102708. private _onBeforeSpritesRenderingObserver;
  102709. private _onAfterSpritesRenderingObserver;
  102710. private _onBeforePhysicsObserver;
  102711. private _onAfterPhysicsObserver;
  102712. private _onAfterAnimationsObserver;
  102713. private _onBeforeCameraRenderObserver;
  102714. private _onAfterCameraRenderObserver;
  102715. /**
  102716. * Gets the perf counter used for active meshes evaluation time
  102717. */
  102718. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  102719. /**
  102720. * Gets the active meshes evaluation time capture status
  102721. */
  102722. /**
  102723. * Enable or disable the active meshes evaluation time capture
  102724. */
  102725. captureActiveMeshesEvaluationTime: boolean;
  102726. /**
  102727. * Gets the perf counter used for render targets render time
  102728. */
  102729. readonly renderTargetsRenderTimeCounter: PerfCounter;
  102730. /**
  102731. * Gets the render targets render time capture status
  102732. */
  102733. /**
  102734. * Enable or disable the render targets render time capture
  102735. */
  102736. captureRenderTargetsRenderTime: boolean;
  102737. /**
  102738. * Gets the perf counter used for particles render time
  102739. */
  102740. readonly particlesRenderTimeCounter: PerfCounter;
  102741. /**
  102742. * Gets the particles render time capture status
  102743. */
  102744. /**
  102745. * Enable or disable the particles render time capture
  102746. */
  102747. captureParticlesRenderTime: boolean;
  102748. /**
  102749. * Gets the perf counter used for sprites render time
  102750. */
  102751. readonly spritesRenderTimeCounter: PerfCounter;
  102752. /**
  102753. * Gets the sprites render time capture status
  102754. */
  102755. /**
  102756. * Enable or disable the sprites render time capture
  102757. */
  102758. captureSpritesRenderTime: boolean;
  102759. /**
  102760. * Gets the perf counter used for physics time
  102761. */
  102762. readonly physicsTimeCounter: PerfCounter;
  102763. /**
  102764. * Gets the physics time capture status
  102765. */
  102766. /**
  102767. * Enable or disable the physics time capture
  102768. */
  102769. capturePhysicsTime: boolean;
  102770. /**
  102771. * Gets the perf counter used for animations time
  102772. */
  102773. readonly animationsTimeCounter: PerfCounter;
  102774. /**
  102775. * Gets the animations time capture status
  102776. */
  102777. /**
  102778. * Enable or disable the animations time capture
  102779. */
  102780. captureAnimationsTime: boolean;
  102781. /**
  102782. * Gets the perf counter used for frame time capture
  102783. */
  102784. readonly frameTimeCounter: PerfCounter;
  102785. /**
  102786. * Gets the frame time capture status
  102787. */
  102788. /**
  102789. * Enable or disable the frame time capture
  102790. */
  102791. captureFrameTime: boolean;
  102792. /**
  102793. * Gets the perf counter used for inter-frames time capture
  102794. */
  102795. readonly interFrameTimeCounter: PerfCounter;
  102796. /**
  102797. * Gets the inter-frames time capture status
  102798. */
  102799. /**
  102800. * Enable or disable the inter-frames time capture
  102801. */
  102802. captureInterFrameTime: boolean;
  102803. /**
  102804. * Gets the perf counter used for render time capture
  102805. */
  102806. readonly renderTimeCounter: PerfCounter;
  102807. /**
  102808. * Gets the render time capture status
  102809. */
  102810. /**
  102811. * Enable or disable the render time capture
  102812. */
  102813. captureRenderTime: boolean;
  102814. /**
  102815. * Gets the perf counter used for camera render time capture
  102816. */
  102817. readonly cameraRenderTimeCounter: PerfCounter;
  102818. /**
  102819. * Gets the camera render time capture status
  102820. */
  102821. /**
  102822. * Enable or disable the camera render time capture
  102823. */
  102824. captureCameraRenderTime: boolean;
  102825. /**
  102826. * Gets the perf counter used for draw calls
  102827. */
  102828. readonly drawCallsCounter: PerfCounter;
  102829. /**
  102830. * Gets the perf counter used for texture collisions
  102831. */
  102832. readonly textureCollisionsCounter: PerfCounter;
  102833. /**
  102834. * Instantiates a new scene instrumentation.
  102835. * This class can be used to get instrumentation data from a Babylon engine
  102836. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  102837. * @param scene Defines the scene to instrument
  102838. */
  102839. constructor(
  102840. /**
  102841. * Defines the scene to instrument
  102842. */
  102843. scene: Scene);
  102844. /**
  102845. * Dispose and release associated resources.
  102846. */
  102847. dispose(): void;
  102848. }
  102849. }
  102850. declare module BABYLON {
  102851. /** @hidden */
  102852. export var glowMapGenerationPixelShader: {
  102853. name: string;
  102854. shader: string;
  102855. };
  102856. }
  102857. declare module BABYLON {
  102858. /** @hidden */
  102859. export var glowMapGenerationVertexShader: {
  102860. name: string;
  102861. shader: string;
  102862. };
  102863. }
  102864. declare module BABYLON {
  102865. /**
  102866. * Effect layer options. This helps customizing the behaviour
  102867. * of the effect layer.
  102868. */
  102869. export interface IEffectLayerOptions {
  102870. /**
  102871. * Multiplication factor apply to the canvas size to compute the render target size
  102872. * used to generated the objects (the smaller the faster).
  102873. */
  102874. mainTextureRatio: number;
  102875. /**
  102876. * Enforces a fixed size texture to ensure effect stability across devices.
  102877. */
  102878. mainTextureFixedSize?: number;
  102879. /**
  102880. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  102881. */
  102882. alphaBlendingMode: number;
  102883. /**
  102884. * The camera attached to the layer.
  102885. */
  102886. camera: Nullable<Camera>;
  102887. /**
  102888. * The rendering group to draw the layer in.
  102889. */
  102890. renderingGroupId: number;
  102891. }
  102892. /**
  102893. * The effect layer Helps adding post process effect blended with the main pass.
  102894. *
  102895. * This can be for instance use to generate glow or higlight effects on the scene.
  102896. *
  102897. * The effect layer class can not be used directly and is intented to inherited from to be
  102898. * customized per effects.
  102899. */
  102900. export abstract class EffectLayer {
  102901. private _vertexBuffers;
  102902. private _indexBuffer;
  102903. private _cachedDefines;
  102904. private _effectLayerMapGenerationEffect;
  102905. private _effectLayerOptions;
  102906. private _mergeEffect;
  102907. protected _scene: Scene;
  102908. protected _engine: Engine;
  102909. protected _maxSize: number;
  102910. protected _mainTextureDesiredSize: ISize;
  102911. protected _mainTexture: RenderTargetTexture;
  102912. protected _shouldRender: boolean;
  102913. protected _postProcesses: PostProcess[];
  102914. protected _textures: BaseTexture[];
  102915. protected _emissiveTextureAndColor: {
  102916. texture: Nullable<BaseTexture>;
  102917. color: Color4;
  102918. };
  102919. /**
  102920. * The name of the layer
  102921. */
  102922. name: string;
  102923. /**
  102924. * The clear color of the texture used to generate the glow map.
  102925. */
  102926. neutralColor: Color4;
  102927. /**
  102928. * Specifies wether the highlight layer is enabled or not.
  102929. */
  102930. isEnabled: boolean;
  102931. /**
  102932. * Gets the camera attached to the layer.
  102933. */
  102934. readonly camera: Nullable<Camera>;
  102935. /**
  102936. * Gets the rendering group id the layer should render in.
  102937. */
  102938. readonly renderingGroupId: number;
  102939. /**
  102940. * An event triggered when the effect layer has been disposed.
  102941. */
  102942. onDisposeObservable: Observable<EffectLayer>;
  102943. /**
  102944. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  102945. */
  102946. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  102947. /**
  102948. * An event triggered when the generated texture is being merged in the scene.
  102949. */
  102950. onBeforeComposeObservable: Observable<EffectLayer>;
  102951. /**
  102952. * An event triggered when the generated texture has been merged in the scene.
  102953. */
  102954. onAfterComposeObservable: Observable<EffectLayer>;
  102955. /**
  102956. * An event triggered when the efffect layer changes its size.
  102957. */
  102958. onSizeChangedObservable: Observable<EffectLayer>;
  102959. /** @hidden */
  102960. static _SceneComponentInitialization: (scene: Scene) => void;
  102961. /**
  102962. * Instantiates a new effect Layer and references it in the scene.
  102963. * @param name The name of the layer
  102964. * @param scene The scene to use the layer in
  102965. */
  102966. constructor(
  102967. /** The Friendly of the effect in the scene */
  102968. name: string, scene: Scene);
  102969. /**
  102970. * Get the effect name of the layer.
  102971. * @return The effect name
  102972. */
  102973. abstract getEffectName(): string;
  102974. /**
  102975. * Checks for the readiness of the element composing the layer.
  102976. * @param subMesh the mesh to check for
  102977. * @param useInstances specify wether or not to use instances to render the mesh
  102978. * @return true if ready otherwise, false
  102979. */
  102980. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  102981. /**
  102982. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  102983. * @returns true if the effect requires stencil during the main canvas render pass.
  102984. */
  102985. abstract needStencil(): boolean;
  102986. /**
  102987. * Create the merge effect. This is the shader use to blit the information back
  102988. * to the main canvas at the end of the scene rendering.
  102989. * @returns The effect containing the shader used to merge the effect on the main canvas
  102990. */
  102991. protected abstract _createMergeEffect(): Effect;
  102992. /**
  102993. * Creates the render target textures and post processes used in the effect layer.
  102994. */
  102995. protected abstract _createTextureAndPostProcesses(): void;
  102996. /**
  102997. * Implementation specific of rendering the generating effect on the main canvas.
  102998. * @param effect The effect used to render through
  102999. */
  103000. protected abstract _internalRender(effect: Effect): void;
  103001. /**
  103002. * Sets the required values for both the emissive texture and and the main color.
  103003. */
  103004. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  103005. /**
  103006. * Free any resources and references associated to a mesh.
  103007. * Internal use
  103008. * @param mesh The mesh to free.
  103009. */
  103010. abstract _disposeMesh(mesh: Mesh): void;
  103011. /**
  103012. * Serializes this layer (Glow or Highlight for example)
  103013. * @returns a serialized layer object
  103014. */
  103015. abstract serialize?(): any;
  103016. /**
  103017. * Initializes the effect layer with the required options.
  103018. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  103019. */
  103020. protected _init(options: Partial<IEffectLayerOptions>): void;
  103021. /**
  103022. * Generates the index buffer of the full screen quad blending to the main canvas.
  103023. */
  103024. private _generateIndexBuffer;
  103025. /**
  103026. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  103027. */
  103028. private _genrateVertexBuffer;
  103029. /**
  103030. * Sets the main texture desired size which is the closest power of two
  103031. * of the engine canvas size.
  103032. */
  103033. private _setMainTextureSize;
  103034. /**
  103035. * Creates the main texture for the effect layer.
  103036. */
  103037. protected _createMainTexture(): void;
  103038. /**
  103039. * Adds specific effects defines.
  103040. * @param defines The defines to add specifics to.
  103041. */
  103042. protected _addCustomEffectDefines(defines: string[]): void;
  103043. /**
  103044. * Checks for the readiness of the element composing the layer.
  103045. * @param subMesh the mesh to check for
  103046. * @param useInstances specify wether or not to use instances to render the mesh
  103047. * @param emissiveTexture the associated emissive texture used to generate the glow
  103048. * @return true if ready otherwise, false
  103049. */
  103050. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  103051. /**
  103052. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  103053. */
  103054. render(): void;
  103055. /**
  103056. * Determine if a given mesh will be used in the current effect.
  103057. * @param mesh mesh to test
  103058. * @returns true if the mesh will be used
  103059. */
  103060. hasMesh(mesh: AbstractMesh): boolean;
  103061. /**
  103062. * Returns true if the layer contains information to display, otherwise false.
  103063. * @returns true if the glow layer should be rendered
  103064. */
  103065. shouldRender(): boolean;
  103066. /**
  103067. * Returns true if the mesh should render, otherwise false.
  103068. * @param mesh The mesh to render
  103069. * @returns true if it should render otherwise false
  103070. */
  103071. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  103072. /**
  103073. * Returns true if the mesh can be rendered, otherwise false.
  103074. * @param mesh The mesh to render
  103075. * @param material The material used on the mesh
  103076. * @returns true if it can be rendered otherwise false
  103077. */
  103078. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  103079. /**
  103080. * Returns true if the mesh should render, otherwise false.
  103081. * @param mesh The mesh to render
  103082. * @returns true if it should render otherwise false
  103083. */
  103084. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  103085. /**
  103086. * Renders the submesh passed in parameter to the generation map.
  103087. */
  103088. protected _renderSubMesh(subMesh: SubMesh): void;
  103089. /**
  103090. * Rebuild the required buffers.
  103091. * @hidden Internal use only.
  103092. */
  103093. _rebuild(): void;
  103094. /**
  103095. * Dispose only the render target textures and post process.
  103096. */
  103097. private _disposeTextureAndPostProcesses;
  103098. /**
  103099. * Dispose the highlight layer and free resources.
  103100. */
  103101. dispose(): void;
  103102. /**
  103103. * Gets the class name of the effect layer
  103104. * @returns the string with the class name of the effect layer
  103105. */
  103106. getClassName(): string;
  103107. /**
  103108. * Creates an effect layer from parsed effect layer data
  103109. * @param parsedEffectLayer defines effect layer data
  103110. * @param scene defines the current scene
  103111. * @param rootUrl defines the root URL containing the effect layer information
  103112. * @returns a parsed effect Layer
  103113. */
  103114. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  103115. }
  103116. }
  103117. declare module BABYLON {
  103118. interface AbstractScene {
  103119. /**
  103120. * The list of effect layers (highlights/glow) added to the scene
  103121. * @see http://doc.babylonjs.com/how_to/highlight_layer
  103122. * @see http://doc.babylonjs.com/how_to/glow_layer
  103123. */
  103124. effectLayers: Array<EffectLayer>;
  103125. /**
  103126. * Removes the given effect layer from this scene.
  103127. * @param toRemove defines the effect layer to remove
  103128. * @returns the index of the removed effect layer
  103129. */
  103130. removeEffectLayer(toRemove: EffectLayer): number;
  103131. /**
  103132. * Adds the given effect layer to this scene
  103133. * @param newEffectLayer defines the effect layer to add
  103134. */
  103135. addEffectLayer(newEffectLayer: EffectLayer): void;
  103136. }
  103137. /**
  103138. * Defines the layer scene component responsible to manage any effect layers
  103139. * in a given scene.
  103140. */
  103141. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  103142. /**
  103143. * The component name helpfull to identify the component in the list of scene components.
  103144. */
  103145. readonly name: string;
  103146. /**
  103147. * The scene the component belongs to.
  103148. */
  103149. scene: Scene;
  103150. private _engine;
  103151. private _renderEffects;
  103152. private _needStencil;
  103153. private _previousStencilState;
  103154. /**
  103155. * Creates a new instance of the component for the given scene
  103156. * @param scene Defines the scene to register the component in
  103157. */
  103158. constructor(scene: Scene);
  103159. /**
  103160. * Registers the component in a given scene
  103161. */
  103162. register(): void;
  103163. /**
  103164. * Rebuilds the elements related to this component in case of
  103165. * context lost for instance.
  103166. */
  103167. rebuild(): void;
  103168. /**
  103169. * Serializes the component data to the specified json object
  103170. * @param serializationObject The object to serialize to
  103171. */
  103172. serialize(serializationObject: any): void;
  103173. /**
  103174. * Adds all the element from the container to the scene
  103175. * @param container the container holding the elements
  103176. */
  103177. addFromContainer(container: AbstractScene): void;
  103178. /**
  103179. * Removes all the elements in the container from the scene
  103180. * @param container contains the elements to remove
  103181. */
  103182. removeFromContainer(container: AbstractScene): void;
  103183. /**
  103184. * Disposes the component and the associated ressources.
  103185. */
  103186. dispose(): void;
  103187. private _isReadyForMesh;
  103188. private _renderMainTexture;
  103189. private _setStencil;
  103190. private _setStencilBack;
  103191. private _draw;
  103192. private _drawCamera;
  103193. private _drawRenderingGroup;
  103194. }
  103195. }
  103196. declare module BABYLON {
  103197. /** @hidden */
  103198. export var glowMapMergePixelShader: {
  103199. name: string;
  103200. shader: string;
  103201. };
  103202. }
  103203. declare module BABYLON {
  103204. /** @hidden */
  103205. export var glowMapMergeVertexShader: {
  103206. name: string;
  103207. shader: string;
  103208. };
  103209. }
  103210. declare module BABYLON {
  103211. interface AbstractScene {
  103212. /**
  103213. * Return a the first highlight layer of the scene with a given name.
  103214. * @param name The name of the highlight layer to look for.
  103215. * @return The highlight layer if found otherwise null.
  103216. */
  103217. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  103218. }
  103219. /**
  103220. * Glow layer options. This helps customizing the behaviour
  103221. * of the glow layer.
  103222. */
  103223. export interface IGlowLayerOptions {
  103224. /**
  103225. * Multiplication factor apply to the canvas size to compute the render target size
  103226. * used to generated the glowing objects (the smaller the faster).
  103227. */
  103228. mainTextureRatio: number;
  103229. /**
  103230. * Enforces a fixed size texture to ensure resize independant blur.
  103231. */
  103232. mainTextureFixedSize?: number;
  103233. /**
  103234. * How big is the kernel of the blur texture.
  103235. */
  103236. blurKernelSize: number;
  103237. /**
  103238. * The camera attached to the layer.
  103239. */
  103240. camera: Nullable<Camera>;
  103241. /**
  103242. * Enable MSAA by chosing the number of samples.
  103243. */
  103244. mainTextureSamples?: number;
  103245. /**
  103246. * The rendering group to draw the layer in.
  103247. */
  103248. renderingGroupId: number;
  103249. }
  103250. /**
  103251. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  103252. *
  103253. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  103254. * glowy meshes to your scene.
  103255. *
  103256. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  103257. */
  103258. export class GlowLayer extends EffectLayer {
  103259. /**
  103260. * Effect Name of the layer.
  103261. */
  103262. static readonly EffectName: string;
  103263. /**
  103264. * The default blur kernel size used for the glow.
  103265. */
  103266. static DefaultBlurKernelSize: number;
  103267. /**
  103268. * The default texture size ratio used for the glow.
  103269. */
  103270. static DefaultTextureRatio: number;
  103271. /**
  103272. * Sets the kernel size of the blur.
  103273. */
  103274. /**
  103275. * Gets the kernel size of the blur.
  103276. */
  103277. blurKernelSize: number;
  103278. /**
  103279. * Sets the glow intensity.
  103280. */
  103281. /**
  103282. * Gets the glow intensity.
  103283. */
  103284. intensity: number;
  103285. private _options;
  103286. private _intensity;
  103287. private _horizontalBlurPostprocess1;
  103288. private _verticalBlurPostprocess1;
  103289. private _horizontalBlurPostprocess2;
  103290. private _verticalBlurPostprocess2;
  103291. private _blurTexture1;
  103292. private _blurTexture2;
  103293. private _postProcesses1;
  103294. private _postProcesses2;
  103295. private _includedOnlyMeshes;
  103296. private _excludedMeshes;
  103297. /**
  103298. * Callback used to let the user override the color selection on a per mesh basis
  103299. */
  103300. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  103301. /**
  103302. * Callback used to let the user override the texture selection on a per mesh basis
  103303. */
  103304. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  103305. /**
  103306. * Instantiates a new glow Layer and references it to the scene.
  103307. * @param name The name of the layer
  103308. * @param scene The scene to use the layer in
  103309. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  103310. */
  103311. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  103312. /**
  103313. * Get the effect name of the layer.
  103314. * @return The effect name
  103315. */
  103316. getEffectName(): string;
  103317. /**
  103318. * Create the merge effect. This is the shader use to blit the information back
  103319. * to the main canvas at the end of the scene rendering.
  103320. */
  103321. protected _createMergeEffect(): Effect;
  103322. /**
  103323. * Creates the render target textures and post processes used in the glow layer.
  103324. */
  103325. protected _createTextureAndPostProcesses(): void;
  103326. /**
  103327. * Checks for the readiness of the element composing the layer.
  103328. * @param subMesh the mesh to check for
  103329. * @param useInstances specify wether or not to use instances to render the mesh
  103330. * @param emissiveTexture the associated emissive texture used to generate the glow
  103331. * @return true if ready otherwise, false
  103332. */
  103333. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  103334. /**
  103335. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  103336. */
  103337. needStencil(): boolean;
  103338. /**
  103339. * Returns true if the mesh can be rendered, otherwise false.
  103340. * @param mesh The mesh to render
  103341. * @param material The material used on the mesh
  103342. * @returns true if it can be rendered otherwise false
  103343. */
  103344. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  103345. /**
  103346. * Implementation specific of rendering the generating effect on the main canvas.
  103347. * @param effect The effect used to render through
  103348. */
  103349. protected _internalRender(effect: Effect): void;
  103350. /**
  103351. * Sets the required values for both the emissive texture and and the main color.
  103352. */
  103353. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  103354. /**
  103355. * Returns true if the mesh should render, otherwise false.
  103356. * @param mesh The mesh to render
  103357. * @returns true if it should render otherwise false
  103358. */
  103359. protected _shouldRenderMesh(mesh: Mesh): boolean;
  103360. /**
  103361. * Adds specific effects defines.
  103362. * @param defines The defines to add specifics to.
  103363. */
  103364. protected _addCustomEffectDefines(defines: string[]): void;
  103365. /**
  103366. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  103367. * @param mesh The mesh to exclude from the glow layer
  103368. */
  103369. addExcludedMesh(mesh: Mesh): void;
  103370. /**
  103371. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  103372. * @param mesh The mesh to remove
  103373. */
  103374. removeExcludedMesh(mesh: Mesh): void;
  103375. /**
  103376. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  103377. * @param mesh The mesh to include in the glow layer
  103378. */
  103379. addIncludedOnlyMesh(mesh: Mesh): void;
  103380. /**
  103381. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  103382. * @param mesh The mesh to remove
  103383. */
  103384. removeIncludedOnlyMesh(mesh: Mesh): void;
  103385. /**
  103386. * Determine if a given mesh will be used in the glow layer
  103387. * @param mesh The mesh to test
  103388. * @returns true if the mesh will be highlighted by the current glow layer
  103389. */
  103390. hasMesh(mesh: AbstractMesh): boolean;
  103391. /**
  103392. * Free any resources and references associated to a mesh.
  103393. * Internal use
  103394. * @param mesh The mesh to free.
  103395. * @hidden
  103396. */
  103397. _disposeMesh(mesh: Mesh): void;
  103398. /**
  103399. * Gets the class name of the effect layer
  103400. * @returns the string with the class name of the effect layer
  103401. */
  103402. getClassName(): string;
  103403. /**
  103404. * Serializes this glow layer
  103405. * @returns a serialized glow layer object
  103406. */
  103407. serialize(): any;
  103408. /**
  103409. * Creates a Glow Layer from parsed glow layer data
  103410. * @param parsedGlowLayer defines glow layer data
  103411. * @param scene defines the current scene
  103412. * @param rootUrl defines the root URL containing the glow layer information
  103413. * @returns a parsed Glow Layer
  103414. */
  103415. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  103416. }
  103417. }
  103418. declare module BABYLON {
  103419. /** @hidden */
  103420. export var glowBlurPostProcessPixelShader: {
  103421. name: string;
  103422. shader: string;
  103423. };
  103424. }
  103425. declare module BABYLON {
  103426. interface AbstractScene {
  103427. /**
  103428. * Return a the first highlight layer of the scene with a given name.
  103429. * @param name The name of the highlight layer to look for.
  103430. * @return The highlight layer if found otherwise null.
  103431. */
  103432. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  103433. }
  103434. /**
  103435. * Highlight layer options. This helps customizing the behaviour
  103436. * of the highlight layer.
  103437. */
  103438. export interface IHighlightLayerOptions {
  103439. /**
  103440. * Multiplication factor apply to the canvas size to compute the render target size
  103441. * used to generated the glowing objects (the smaller the faster).
  103442. */
  103443. mainTextureRatio: number;
  103444. /**
  103445. * Enforces a fixed size texture to ensure resize independant blur.
  103446. */
  103447. mainTextureFixedSize?: number;
  103448. /**
  103449. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  103450. * of the picture to blur (the smaller the faster).
  103451. */
  103452. blurTextureSizeRatio: number;
  103453. /**
  103454. * How big in texel of the blur texture is the vertical blur.
  103455. */
  103456. blurVerticalSize: number;
  103457. /**
  103458. * How big in texel of the blur texture is the horizontal blur.
  103459. */
  103460. blurHorizontalSize: number;
  103461. /**
  103462. * Alpha blending mode used to apply the blur. Default is combine.
  103463. */
  103464. alphaBlendingMode: number;
  103465. /**
  103466. * The camera attached to the layer.
  103467. */
  103468. camera: Nullable<Camera>;
  103469. /**
  103470. * Should we display highlight as a solid stroke?
  103471. */
  103472. isStroke?: boolean;
  103473. /**
  103474. * The rendering group to draw the layer in.
  103475. */
  103476. renderingGroupId: number;
  103477. }
  103478. /**
  103479. * The highlight layer Helps adding a glow effect around a mesh.
  103480. *
  103481. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  103482. * glowy meshes to your scene.
  103483. *
  103484. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  103485. */
  103486. export class HighlightLayer extends EffectLayer {
  103487. name: string;
  103488. /**
  103489. * Effect Name of the highlight layer.
  103490. */
  103491. static readonly EffectName: string;
  103492. /**
  103493. * The neutral color used during the preparation of the glow effect.
  103494. * This is black by default as the blend operation is a blend operation.
  103495. */
  103496. static NeutralColor: Color4;
  103497. /**
  103498. * Stencil value used for glowing meshes.
  103499. */
  103500. static GlowingMeshStencilReference: number;
  103501. /**
  103502. * Stencil value used for the other meshes in the scene.
  103503. */
  103504. static NormalMeshStencilReference: number;
  103505. /**
  103506. * Specifies whether or not the inner glow is ACTIVE in the layer.
  103507. */
  103508. innerGlow: boolean;
  103509. /**
  103510. * Specifies whether or not the outer glow is ACTIVE in the layer.
  103511. */
  103512. outerGlow: boolean;
  103513. /**
  103514. * Specifies the horizontal size of the blur.
  103515. */
  103516. /**
  103517. * Gets the horizontal size of the blur.
  103518. */
  103519. blurHorizontalSize: number;
  103520. /**
  103521. * Specifies the vertical size of the blur.
  103522. */
  103523. /**
  103524. * Gets the vertical size of the blur.
  103525. */
  103526. blurVerticalSize: number;
  103527. /**
  103528. * An event triggered when the highlight layer is being blurred.
  103529. */
  103530. onBeforeBlurObservable: Observable<HighlightLayer>;
  103531. /**
  103532. * An event triggered when the highlight layer has been blurred.
  103533. */
  103534. onAfterBlurObservable: Observable<HighlightLayer>;
  103535. private _instanceGlowingMeshStencilReference;
  103536. private _options;
  103537. private _downSamplePostprocess;
  103538. private _horizontalBlurPostprocess;
  103539. private _verticalBlurPostprocess;
  103540. private _blurTexture;
  103541. private _meshes;
  103542. private _excludedMeshes;
  103543. /**
  103544. * Instantiates a new highlight Layer and references it to the scene..
  103545. * @param name The name of the layer
  103546. * @param scene The scene to use the layer in
  103547. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  103548. */
  103549. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  103550. /**
  103551. * Get the effect name of the layer.
  103552. * @return The effect name
  103553. */
  103554. getEffectName(): string;
  103555. /**
  103556. * Create the merge effect. This is the shader use to blit the information back
  103557. * to the main canvas at the end of the scene rendering.
  103558. */
  103559. protected _createMergeEffect(): Effect;
  103560. /**
  103561. * Creates the render target textures and post processes used in the highlight layer.
  103562. */
  103563. protected _createTextureAndPostProcesses(): void;
  103564. /**
  103565. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  103566. */
  103567. needStencil(): boolean;
  103568. /**
  103569. * Checks for the readiness of the element composing the layer.
  103570. * @param subMesh the mesh to check for
  103571. * @param useInstances specify wether or not to use instances to render the mesh
  103572. * @param emissiveTexture the associated emissive texture used to generate the glow
  103573. * @return true if ready otherwise, false
  103574. */
  103575. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  103576. /**
  103577. * Implementation specific of rendering the generating effect on the main canvas.
  103578. * @param effect The effect used to render through
  103579. */
  103580. protected _internalRender(effect: Effect): void;
  103581. /**
  103582. * Returns true if the layer contains information to display, otherwise false.
  103583. */
  103584. shouldRender(): boolean;
  103585. /**
  103586. * Returns true if the mesh should render, otherwise false.
  103587. * @param mesh The mesh to render
  103588. * @returns true if it should render otherwise false
  103589. */
  103590. protected _shouldRenderMesh(mesh: Mesh): boolean;
  103591. /**
  103592. * Sets the required values for both the emissive texture and and the main color.
  103593. */
  103594. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  103595. /**
  103596. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  103597. * @param mesh The mesh to exclude from the highlight layer
  103598. */
  103599. addExcludedMesh(mesh: Mesh): void;
  103600. /**
  103601. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  103602. * @param mesh The mesh to highlight
  103603. */
  103604. removeExcludedMesh(mesh: Mesh): void;
  103605. /**
  103606. * Determine if a given mesh will be highlighted by the current HighlightLayer
  103607. * @param mesh mesh to test
  103608. * @returns true if the mesh will be highlighted by the current HighlightLayer
  103609. */
  103610. hasMesh(mesh: AbstractMesh): boolean;
  103611. /**
  103612. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  103613. * @param mesh The mesh to highlight
  103614. * @param color The color of the highlight
  103615. * @param glowEmissiveOnly Extract the glow from the emissive texture
  103616. */
  103617. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  103618. /**
  103619. * Remove a mesh from the highlight layer in order to make it stop glowing.
  103620. * @param mesh The mesh to highlight
  103621. */
  103622. removeMesh(mesh: Mesh): void;
  103623. /**
  103624. * Force the stencil to the normal expected value for none glowing parts
  103625. */
  103626. private _defaultStencilReference;
  103627. /**
  103628. * Free any resources and references associated to a mesh.
  103629. * Internal use
  103630. * @param mesh The mesh to free.
  103631. * @hidden
  103632. */
  103633. _disposeMesh(mesh: Mesh): void;
  103634. /**
  103635. * Dispose the highlight layer and free resources.
  103636. */
  103637. dispose(): void;
  103638. /**
  103639. * Gets the class name of the effect layer
  103640. * @returns the string with the class name of the effect layer
  103641. */
  103642. getClassName(): string;
  103643. /**
  103644. * Serializes this Highlight layer
  103645. * @returns a serialized Highlight layer object
  103646. */
  103647. serialize(): any;
  103648. /**
  103649. * Creates a Highlight layer from parsed Highlight layer data
  103650. * @param parsedHightlightLayer defines the Highlight layer data
  103651. * @param scene defines the current scene
  103652. * @param rootUrl defines the root URL containing the Highlight layer information
  103653. * @returns a parsed Highlight layer
  103654. */
  103655. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  103656. }
  103657. }
  103658. declare module BABYLON {
  103659. /** @hidden */
  103660. export var lensFlarePixelShader: {
  103661. name: string;
  103662. shader: string;
  103663. };
  103664. }
  103665. declare module BABYLON {
  103666. /** @hidden */
  103667. export var lensFlareVertexShader: {
  103668. name: string;
  103669. shader: string;
  103670. };
  103671. }
  103672. declare module BABYLON {
  103673. /**
  103674. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  103675. * It is usually composed of several `lensFlare`.
  103676. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103677. */
  103678. export class LensFlareSystem {
  103679. /**
  103680. * Define the name of the lens flare system
  103681. */
  103682. name: string;
  103683. /**
  103684. * List of lens flares used in this system.
  103685. */
  103686. lensFlares: LensFlare[];
  103687. /**
  103688. * Define a limit from the border the lens flare can be visible.
  103689. */
  103690. borderLimit: number;
  103691. /**
  103692. * Define a viewport border we do not want to see the lens flare in.
  103693. */
  103694. viewportBorder: number;
  103695. /**
  103696. * Define a predicate which could limit the list of meshes able to occlude the effect.
  103697. */
  103698. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  103699. /**
  103700. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  103701. */
  103702. layerMask: number;
  103703. /**
  103704. * Define the id of the lens flare system in the scene.
  103705. * (equal to name by default)
  103706. */
  103707. id: string;
  103708. private _scene;
  103709. private _emitter;
  103710. private _vertexBuffers;
  103711. private _indexBuffer;
  103712. private _effect;
  103713. private _positionX;
  103714. private _positionY;
  103715. private _isEnabled;
  103716. /** @hidden */
  103717. static _SceneComponentInitialization: (scene: Scene) => void;
  103718. /**
  103719. * Instantiates a lens flare system.
  103720. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  103721. * It is usually composed of several `lensFlare`.
  103722. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103723. * @param name Define the name of the lens flare system in the scene
  103724. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  103725. * @param scene Define the scene the lens flare system belongs to
  103726. */
  103727. constructor(
  103728. /**
  103729. * Define the name of the lens flare system
  103730. */
  103731. name: string, emitter: any, scene: Scene);
  103732. /**
  103733. * Define if the lens flare system is enabled.
  103734. */
  103735. isEnabled: boolean;
  103736. /**
  103737. * Get the scene the effects belongs to.
  103738. * @returns the scene holding the lens flare system
  103739. */
  103740. getScene(): Scene;
  103741. /**
  103742. * Get the emitter of the lens flare system.
  103743. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  103744. * @returns the emitter of the lens flare system
  103745. */
  103746. getEmitter(): any;
  103747. /**
  103748. * Set the emitter of the lens flare system.
  103749. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  103750. * @param newEmitter Define the new emitter of the system
  103751. */
  103752. setEmitter(newEmitter: any): void;
  103753. /**
  103754. * Get the lens flare system emitter position.
  103755. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  103756. * @returns the position
  103757. */
  103758. getEmitterPosition(): Vector3;
  103759. /**
  103760. * @hidden
  103761. */
  103762. computeEffectivePosition(globalViewport: Viewport): boolean;
  103763. /** @hidden */
  103764. _isVisible(): boolean;
  103765. /**
  103766. * @hidden
  103767. */
  103768. render(): boolean;
  103769. /**
  103770. * Dispose and release the lens flare with its associated resources.
  103771. */
  103772. dispose(): void;
  103773. /**
  103774. * Parse a lens flare system from a JSON repressentation
  103775. * @param parsedLensFlareSystem Define the JSON to parse
  103776. * @param scene Define the scene the parsed system should be instantiated in
  103777. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  103778. * @returns the parsed system
  103779. */
  103780. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  103781. /**
  103782. * Serialize the current Lens Flare System into a JSON representation.
  103783. * @returns the serialized JSON
  103784. */
  103785. serialize(): any;
  103786. }
  103787. }
  103788. declare module BABYLON {
  103789. /**
  103790. * This represents one of the lens effect in a `lensFlareSystem`.
  103791. * It controls one of the indiviual texture used in the effect.
  103792. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103793. */
  103794. export class LensFlare {
  103795. /**
  103796. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  103797. */
  103798. size: number;
  103799. /**
  103800. * 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.
  103801. */
  103802. position: number;
  103803. /**
  103804. * Define the lens color.
  103805. */
  103806. color: Color3;
  103807. /**
  103808. * Define the lens texture.
  103809. */
  103810. texture: Nullable<Texture>;
  103811. /**
  103812. * Define the alpha mode to render this particular lens.
  103813. */
  103814. alphaMode: number;
  103815. private _system;
  103816. /**
  103817. * Creates a new Lens Flare.
  103818. * This represents one of the lens effect in a `lensFlareSystem`.
  103819. * It controls one of the indiviual texture used in the effect.
  103820. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103821. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  103822. * @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.
  103823. * @param color Define the lens color
  103824. * @param imgUrl Define the lens texture url
  103825. * @param system Define the `lensFlareSystem` this flare is part of
  103826. * @returns The newly created Lens Flare
  103827. */
  103828. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  103829. /**
  103830. * Instantiates a new Lens Flare.
  103831. * This represents one of the lens effect in a `lensFlareSystem`.
  103832. * It controls one of the indiviual texture used in the effect.
  103833. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103834. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  103835. * @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.
  103836. * @param color Define the lens color
  103837. * @param imgUrl Define the lens texture url
  103838. * @param system Define the `lensFlareSystem` this flare is part of
  103839. */
  103840. constructor(
  103841. /**
  103842. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  103843. */
  103844. size: number,
  103845. /**
  103846. * 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.
  103847. */
  103848. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  103849. /**
  103850. * Dispose and release the lens flare with its associated resources.
  103851. */
  103852. dispose(): void;
  103853. }
  103854. }
  103855. declare module BABYLON {
  103856. interface AbstractScene {
  103857. /**
  103858. * The list of lens flare system added to the scene
  103859. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103860. */
  103861. lensFlareSystems: Array<LensFlareSystem>;
  103862. /**
  103863. * Removes the given lens flare system from this scene.
  103864. * @param toRemove The lens flare system to remove
  103865. * @returns The index of the removed lens flare system
  103866. */
  103867. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  103868. /**
  103869. * Adds the given lens flare system to this scene
  103870. * @param newLensFlareSystem The lens flare system to add
  103871. */
  103872. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  103873. /**
  103874. * Gets a lens flare system using its name
  103875. * @param name defines the name to look for
  103876. * @returns the lens flare system or null if not found
  103877. */
  103878. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  103879. /**
  103880. * Gets a lens flare system using its id
  103881. * @param id defines the id to look for
  103882. * @returns the lens flare system or null if not found
  103883. */
  103884. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  103885. }
  103886. /**
  103887. * Defines the lens flare scene component responsible to manage any lens flares
  103888. * in a given scene.
  103889. */
  103890. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  103891. /**
  103892. * The component name helpfull to identify the component in the list of scene components.
  103893. */
  103894. readonly name: string;
  103895. /**
  103896. * The scene the component belongs to.
  103897. */
  103898. scene: Scene;
  103899. /**
  103900. * Creates a new instance of the component for the given scene
  103901. * @param scene Defines the scene to register the component in
  103902. */
  103903. constructor(scene: Scene);
  103904. /**
  103905. * Registers the component in a given scene
  103906. */
  103907. register(): void;
  103908. /**
  103909. * Rebuilds the elements related to this component in case of
  103910. * context lost for instance.
  103911. */
  103912. rebuild(): void;
  103913. /**
  103914. * Adds all the element from the container to the scene
  103915. * @param container the container holding the elements
  103916. */
  103917. addFromContainer(container: AbstractScene): void;
  103918. /**
  103919. * Removes all the elements in the container from the scene
  103920. * @param container contains the elements to remove
  103921. */
  103922. removeFromContainer(container: AbstractScene): void;
  103923. /**
  103924. * Serializes the component data to the specified json object
  103925. * @param serializationObject The object to serialize to
  103926. */
  103927. serialize(serializationObject: any): void;
  103928. /**
  103929. * Disposes the component and the associated ressources.
  103930. */
  103931. dispose(): void;
  103932. private _draw;
  103933. }
  103934. }
  103935. declare module BABYLON {
  103936. /**
  103937. * Defines the shadow generator component responsible to manage any shadow generators
  103938. * in a given scene.
  103939. */
  103940. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  103941. /**
  103942. * The component name helpfull to identify the component in the list of scene components.
  103943. */
  103944. readonly name: string;
  103945. /**
  103946. * The scene the component belongs to.
  103947. */
  103948. scene: Scene;
  103949. /**
  103950. * Creates a new instance of the component for the given scene
  103951. * @param scene Defines the scene to register the component in
  103952. */
  103953. constructor(scene: Scene);
  103954. /**
  103955. * Registers the component in a given scene
  103956. */
  103957. register(): void;
  103958. /**
  103959. * Rebuilds the elements related to this component in case of
  103960. * context lost for instance.
  103961. */
  103962. rebuild(): void;
  103963. /**
  103964. * Serializes the component data to the specified json object
  103965. * @param serializationObject The object to serialize to
  103966. */
  103967. serialize(serializationObject: any): void;
  103968. /**
  103969. * Adds all the element from the container to the scene
  103970. * @param container the container holding the elements
  103971. */
  103972. addFromContainer(container: AbstractScene): void;
  103973. /**
  103974. * Removes all the elements in the container from the scene
  103975. * @param container contains the elements to remove
  103976. */
  103977. removeFromContainer(container: AbstractScene): void;
  103978. /**
  103979. * Rebuilds the elements related to this component in case of
  103980. * context lost for instance.
  103981. */
  103982. dispose(): void;
  103983. private _gatherRenderTargets;
  103984. }
  103985. }
  103986. declare module BABYLON {
  103987. /**
  103988. * A directional light is defined by a direction (what a surprise!).
  103989. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  103990. * 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.
  103991. * Documentation: https://doc.babylonjs.com/babylon101/lights
  103992. */
  103993. export class DirectionalLight extends ShadowLight {
  103994. private _shadowFrustumSize;
  103995. /**
  103996. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  103997. */
  103998. /**
  103999. * Specifies a fix frustum size for the shadow generation.
  104000. */
  104001. shadowFrustumSize: number;
  104002. private _shadowOrthoScale;
  104003. /**
  104004. * Gets the shadow projection scale against the optimal computed one.
  104005. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  104006. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  104007. */
  104008. /**
  104009. * Sets the shadow projection scale against the optimal computed one.
  104010. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  104011. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  104012. */
  104013. shadowOrthoScale: number;
  104014. /**
  104015. * Automatically compute the projection matrix to best fit (including all the casters)
  104016. * on each frame.
  104017. */
  104018. autoUpdateExtends: boolean;
  104019. private _orthoLeft;
  104020. private _orthoRight;
  104021. private _orthoTop;
  104022. private _orthoBottom;
  104023. /**
  104024. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  104025. * The directional light is emitted from everywhere in the given direction.
  104026. * It can cast shadows.
  104027. * Documentation : https://doc.babylonjs.com/babylon101/lights
  104028. * @param name The friendly name of the light
  104029. * @param direction The direction of the light
  104030. * @param scene The scene the light belongs to
  104031. */
  104032. constructor(name: string, direction: Vector3, scene: Scene);
  104033. /**
  104034. * Returns the string "DirectionalLight".
  104035. * @return The class name
  104036. */
  104037. getClassName(): string;
  104038. /**
  104039. * Returns the integer 1.
  104040. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  104041. */
  104042. getTypeID(): number;
  104043. /**
  104044. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  104045. * Returns the DirectionalLight Shadow projection matrix.
  104046. */
  104047. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  104048. /**
  104049. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  104050. * Returns the DirectionalLight Shadow projection matrix.
  104051. */
  104052. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  104053. /**
  104054. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  104055. * Returns the DirectionalLight Shadow projection matrix.
  104056. */
  104057. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  104058. protected _buildUniformLayout(): void;
  104059. /**
  104060. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  104061. * @param effect The effect to update
  104062. * @param lightIndex The index of the light in the effect to update
  104063. * @returns The directional light
  104064. */
  104065. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  104066. /**
  104067. * Gets the minZ used for shadow according to both the scene and the light.
  104068. *
  104069. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  104070. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  104071. * @param activeCamera The camera we are returning the min for
  104072. * @returns the depth min z
  104073. */
  104074. getDepthMinZ(activeCamera: Camera): number;
  104075. /**
  104076. * Gets the maxZ used for shadow according to both the scene and the light.
  104077. *
  104078. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  104079. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  104080. * @param activeCamera The camera we are returning the max for
  104081. * @returns the depth max z
  104082. */
  104083. getDepthMaxZ(activeCamera: Camera): number;
  104084. /**
  104085. * Prepares the list of defines specific to the light type.
  104086. * @param defines the list of defines
  104087. * @param lightIndex defines the index of the light for the effect
  104088. */
  104089. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  104090. }
  104091. }
  104092. declare module BABYLON {
  104093. /**
  104094. * A point light is a light defined by an unique point in world space.
  104095. * The light is emitted in every direction from this point.
  104096. * A good example of a point light is a standard light bulb.
  104097. * Documentation: https://doc.babylonjs.com/babylon101/lights
  104098. */
  104099. export class PointLight extends ShadowLight {
  104100. private _shadowAngle;
  104101. /**
  104102. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  104103. * This specifies what angle the shadow will use to be created.
  104104. *
  104105. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  104106. */
  104107. /**
  104108. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  104109. * This specifies what angle the shadow will use to be created.
  104110. *
  104111. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  104112. */
  104113. shadowAngle: number;
  104114. /**
  104115. * Gets the direction if it has been set.
  104116. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  104117. */
  104118. /**
  104119. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  104120. */
  104121. direction: Vector3;
  104122. /**
  104123. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  104124. * A PointLight emits the light in every direction.
  104125. * It can cast shadows.
  104126. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  104127. * ```javascript
  104128. * var pointLight = new PointLight("pl", camera.position, scene);
  104129. * ```
  104130. * Documentation : https://doc.babylonjs.com/babylon101/lights
  104131. * @param name The light friendly name
  104132. * @param position The position of the point light in the scene
  104133. * @param scene The scene the lights belongs to
  104134. */
  104135. constructor(name: string, position: Vector3, scene: Scene);
  104136. /**
  104137. * Returns the string "PointLight"
  104138. * @returns the class name
  104139. */
  104140. getClassName(): string;
  104141. /**
  104142. * Returns the integer 0.
  104143. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  104144. */
  104145. getTypeID(): number;
  104146. /**
  104147. * Specifies wether or not the shadowmap should be a cube texture.
  104148. * @returns true if the shadowmap needs to be a cube texture.
  104149. */
  104150. needCube(): boolean;
  104151. /**
  104152. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  104153. * @param faceIndex The index of the face we are computed the direction to generate shadow
  104154. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  104155. */
  104156. getShadowDirection(faceIndex?: number): Vector3;
  104157. /**
  104158. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  104159. * - fov = PI / 2
  104160. * - aspect ratio : 1.0
  104161. * - z-near and far equal to the active camera minZ and maxZ.
  104162. * Returns the PointLight.
  104163. */
  104164. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  104165. protected _buildUniformLayout(): void;
  104166. /**
  104167. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  104168. * @param effect The effect to update
  104169. * @param lightIndex The index of the light in the effect to update
  104170. * @returns The point light
  104171. */
  104172. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  104173. /**
  104174. * Prepares the list of defines specific to the light type.
  104175. * @param defines the list of defines
  104176. * @param lightIndex defines the index of the light for the effect
  104177. */
  104178. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  104179. }
  104180. }
  104181. declare module BABYLON {
  104182. /**
  104183. * A spot light is defined by a position, a direction, an angle, and an exponent.
  104184. * These values define a cone of light starting from the position, emitting toward the direction.
  104185. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  104186. * and the exponent defines the speed of the decay of the light with distance (reach).
  104187. * Documentation: https://doc.babylonjs.com/babylon101/lights
  104188. */
  104189. export class SpotLight extends ShadowLight {
  104190. private _angle;
  104191. private _innerAngle;
  104192. private _cosHalfAngle;
  104193. private _lightAngleScale;
  104194. private _lightAngleOffset;
  104195. /**
  104196. * Gets the cone angle of the spot light in Radians.
  104197. */
  104198. /**
  104199. * Sets the cone angle of the spot light in Radians.
  104200. */
  104201. angle: number;
  104202. /**
  104203. * Only used in gltf falloff mode, this defines the angle where
  104204. * the directional falloff will start before cutting at angle which could be seen
  104205. * as outer angle.
  104206. */
  104207. /**
  104208. * Only used in gltf falloff mode, this defines the angle where
  104209. * the directional falloff will start before cutting at angle which could be seen
  104210. * as outer angle.
  104211. */
  104212. innerAngle: number;
  104213. private _shadowAngleScale;
  104214. /**
  104215. * Allows scaling the angle of the light for shadow generation only.
  104216. */
  104217. /**
  104218. * Allows scaling the angle of the light for shadow generation only.
  104219. */
  104220. shadowAngleScale: number;
  104221. /**
  104222. * The light decay speed with the distance from the emission spot.
  104223. */
  104224. exponent: number;
  104225. private _projectionTextureMatrix;
  104226. /**
  104227. * Allows reading the projecton texture
  104228. */
  104229. readonly projectionTextureMatrix: Matrix;
  104230. protected _projectionTextureLightNear: number;
  104231. /**
  104232. * Gets the near clip of the Spotlight for texture projection.
  104233. */
  104234. /**
  104235. * Sets the near clip of the Spotlight for texture projection.
  104236. */
  104237. projectionTextureLightNear: number;
  104238. protected _projectionTextureLightFar: number;
  104239. /**
  104240. * Gets the far clip of the Spotlight for texture projection.
  104241. */
  104242. /**
  104243. * Sets the far clip of the Spotlight for texture projection.
  104244. */
  104245. projectionTextureLightFar: number;
  104246. protected _projectionTextureUpDirection: Vector3;
  104247. /**
  104248. * Gets the Up vector of the Spotlight for texture projection.
  104249. */
  104250. /**
  104251. * Sets the Up vector of the Spotlight for texture projection.
  104252. */
  104253. projectionTextureUpDirection: Vector3;
  104254. private _projectionTexture;
  104255. /**
  104256. * Gets the projection texture of the light.
  104257. */
  104258. /**
  104259. * Sets the projection texture of the light.
  104260. */
  104261. projectionTexture: Nullable<BaseTexture>;
  104262. private _projectionTextureViewLightDirty;
  104263. private _projectionTextureProjectionLightDirty;
  104264. private _projectionTextureDirty;
  104265. private _projectionTextureViewTargetVector;
  104266. private _projectionTextureViewLightMatrix;
  104267. private _projectionTextureProjectionLightMatrix;
  104268. private _projectionTextureScalingMatrix;
  104269. /**
  104270. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  104271. * It can cast shadows.
  104272. * Documentation : https://doc.babylonjs.com/babylon101/lights
  104273. * @param name The light friendly name
  104274. * @param position The position of the spot light in the scene
  104275. * @param direction The direction of the light in the scene
  104276. * @param angle The cone angle of the light in Radians
  104277. * @param exponent The light decay speed with the distance from the emission spot
  104278. * @param scene The scene the lights belongs to
  104279. */
  104280. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  104281. /**
  104282. * Returns the string "SpotLight".
  104283. * @returns the class name
  104284. */
  104285. getClassName(): string;
  104286. /**
  104287. * Returns the integer 2.
  104288. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  104289. */
  104290. getTypeID(): number;
  104291. /**
  104292. * Overrides the direction setter to recompute the projection texture view light Matrix.
  104293. */
  104294. protected _setDirection(value: Vector3): void;
  104295. /**
  104296. * Overrides the position setter to recompute the projection texture view light Matrix.
  104297. */
  104298. protected _setPosition(value: Vector3): void;
  104299. /**
  104300. * 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.
  104301. * Returns the SpotLight.
  104302. */
  104303. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  104304. protected _computeProjectionTextureViewLightMatrix(): void;
  104305. protected _computeProjectionTextureProjectionLightMatrix(): void;
  104306. /**
  104307. * Main function for light texture projection matrix computing.
  104308. */
  104309. protected _computeProjectionTextureMatrix(): void;
  104310. protected _buildUniformLayout(): void;
  104311. private _computeAngleValues;
  104312. /**
  104313. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  104314. * @param effect The effect to update
  104315. * @param lightIndex The index of the light in the effect to update
  104316. * @returns The spot light
  104317. */
  104318. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  104319. /**
  104320. * Disposes the light and the associated resources.
  104321. */
  104322. dispose(): void;
  104323. /**
  104324. * Prepares the list of defines specific to the light type.
  104325. * @param defines the list of defines
  104326. * @param lightIndex defines the index of the light for the effect
  104327. */
  104328. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  104329. }
  104330. }
  104331. declare module BABYLON {
  104332. /**
  104333. * Header information of HDR texture files.
  104334. */
  104335. export interface HDRInfo {
  104336. /**
  104337. * The height of the texture in pixels.
  104338. */
  104339. height: number;
  104340. /**
  104341. * The width of the texture in pixels.
  104342. */
  104343. width: number;
  104344. /**
  104345. * The index of the beginning of the data in the binary file.
  104346. */
  104347. dataPosition: number;
  104348. }
  104349. /**
  104350. * This groups tools to convert HDR texture to native colors array.
  104351. */
  104352. export class HDRTools {
  104353. private static Ldexp;
  104354. private static Rgbe2float;
  104355. private static readStringLine;
  104356. /**
  104357. * Reads header information from an RGBE texture stored in a native array.
  104358. * More information on this format are available here:
  104359. * https://en.wikipedia.org/wiki/RGBE_image_format
  104360. *
  104361. * @param uint8array The binary file stored in native array.
  104362. * @return The header information.
  104363. */
  104364. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  104365. /**
  104366. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  104367. * This RGBE texture needs to store the information as a panorama.
  104368. *
  104369. * More information on this format are available here:
  104370. * https://en.wikipedia.org/wiki/RGBE_image_format
  104371. *
  104372. * @param buffer The binary file stored in an array buffer.
  104373. * @param size The expected size of the extracted cubemap.
  104374. * @return The Cube Map information.
  104375. */
  104376. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  104377. /**
  104378. * Returns the pixels data extracted from an RGBE texture.
  104379. * This pixels will be stored left to right up to down in the R G B order in one array.
  104380. *
  104381. * More information on this format are available here:
  104382. * https://en.wikipedia.org/wiki/RGBE_image_format
  104383. *
  104384. * @param uint8array The binary file stored in an array buffer.
  104385. * @param hdrInfo The header information of the file.
  104386. * @return The pixels data in RGB right to left up to down order.
  104387. */
  104388. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  104389. private static RGBE_ReadPixels_RLE;
  104390. }
  104391. }
  104392. declare module BABYLON {
  104393. /**
  104394. * This represents a texture coming from an HDR input.
  104395. *
  104396. * The only supported format is currently panorama picture stored in RGBE format.
  104397. * Example of such files can be found on HDRLib: http://hdrlib.com/
  104398. */
  104399. export class HDRCubeTexture extends BaseTexture {
  104400. private static _facesMapping;
  104401. private _generateHarmonics;
  104402. private _noMipmap;
  104403. private _textureMatrix;
  104404. private _size;
  104405. private _onLoad;
  104406. private _onError;
  104407. /**
  104408. * The texture URL.
  104409. */
  104410. url: string;
  104411. /**
  104412. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  104413. */
  104414. coordinatesMode: number;
  104415. protected _isBlocking: boolean;
  104416. /**
  104417. * Sets wether or not the texture is blocking during loading.
  104418. */
  104419. /**
  104420. * Gets wether or not the texture is blocking during loading.
  104421. */
  104422. isBlocking: boolean;
  104423. protected _rotationY: number;
  104424. /**
  104425. * Sets texture matrix rotation angle around Y axis in radians.
  104426. */
  104427. /**
  104428. * Gets texture matrix rotation angle around Y axis radians.
  104429. */
  104430. rotationY: number;
  104431. /**
  104432. * Gets or sets the center of the bounding box associated with the cube texture
  104433. * It must define where the camera used to render the texture was set
  104434. */
  104435. boundingBoxPosition: Vector3;
  104436. private _boundingBoxSize;
  104437. /**
  104438. * Gets or sets the size of the bounding box associated with the cube texture
  104439. * When defined, the cubemap will switch to local mode
  104440. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  104441. * @example https://www.babylonjs-playground.com/#RNASML
  104442. */
  104443. boundingBoxSize: Vector3;
  104444. /**
  104445. * Instantiates an HDRTexture from the following parameters.
  104446. *
  104447. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  104448. * @param scene The scene the texture will be used in
  104449. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  104450. * @param noMipmap Forces to not generate the mipmap if true
  104451. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  104452. * @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)
  104453. * @param reserved Reserved flag for internal use.
  104454. */
  104455. 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>);
  104456. /**
  104457. * Get the current class name of the texture useful for serialization or dynamic coding.
  104458. * @returns "HDRCubeTexture"
  104459. */
  104460. getClassName(): string;
  104461. /**
  104462. * Occurs when the file is raw .hdr file.
  104463. */
  104464. private loadTexture;
  104465. clone(): HDRCubeTexture;
  104466. delayLoad(): void;
  104467. /**
  104468. * Get the texture reflection matrix used to rotate/transform the reflection.
  104469. * @returns the reflection matrix
  104470. */
  104471. getReflectionTextureMatrix(): Matrix;
  104472. /**
  104473. * Set the texture reflection matrix used to rotate/transform the reflection.
  104474. * @param value Define the reflection matrix to set
  104475. */
  104476. setReflectionTextureMatrix(value: Matrix): void;
  104477. /**
  104478. * Parses a JSON representation of an HDR Texture in order to create the texture
  104479. * @param parsedTexture Define the JSON representation
  104480. * @param scene Define the scene the texture should be created in
  104481. * @param rootUrl Define the root url in case we need to load relative dependencies
  104482. * @returns the newly created texture after parsing
  104483. */
  104484. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  104485. serialize(): any;
  104486. }
  104487. }
  104488. declare module BABYLON {
  104489. /**
  104490. * Class used to control physics engine
  104491. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  104492. */
  104493. export class PhysicsEngine implements IPhysicsEngine {
  104494. private _physicsPlugin;
  104495. /**
  104496. * Global value used to control the smallest number supported by the simulation
  104497. */
  104498. static Epsilon: number;
  104499. private _impostors;
  104500. private _joints;
  104501. /**
  104502. * Gets the gravity vector used by the simulation
  104503. */
  104504. gravity: Vector3;
  104505. /**
  104506. * Factory used to create the default physics plugin.
  104507. * @returns The default physics plugin
  104508. */
  104509. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  104510. /**
  104511. * Creates a new Physics Engine
  104512. * @param gravity defines the gravity vector used by the simulation
  104513. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  104514. */
  104515. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  104516. /**
  104517. * Sets the gravity vector used by the simulation
  104518. * @param gravity defines the gravity vector to use
  104519. */
  104520. setGravity(gravity: Vector3): void;
  104521. /**
  104522. * Set the time step of the physics engine.
  104523. * Default is 1/60.
  104524. * To slow it down, enter 1/600 for example.
  104525. * To speed it up, 1/30
  104526. * @param newTimeStep defines the new timestep to apply to this world.
  104527. */
  104528. setTimeStep(newTimeStep?: number): void;
  104529. /**
  104530. * Get the time step of the physics engine.
  104531. * @returns the current time step
  104532. */
  104533. getTimeStep(): number;
  104534. /**
  104535. * Release all resources
  104536. */
  104537. dispose(): void;
  104538. /**
  104539. * Gets the name of the current physics plugin
  104540. * @returns the name of the plugin
  104541. */
  104542. getPhysicsPluginName(): string;
  104543. /**
  104544. * Adding a new impostor for the impostor tracking.
  104545. * This will be done by the impostor itself.
  104546. * @param impostor the impostor to add
  104547. */
  104548. addImpostor(impostor: PhysicsImpostor): void;
  104549. /**
  104550. * Remove an impostor from the engine.
  104551. * This impostor and its mesh will not longer be updated by the physics engine.
  104552. * @param impostor the impostor to remove
  104553. */
  104554. removeImpostor(impostor: PhysicsImpostor): void;
  104555. /**
  104556. * Add a joint to the physics engine
  104557. * @param mainImpostor defines the main impostor to which the joint is added.
  104558. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  104559. * @param joint defines the joint that will connect both impostors.
  104560. */
  104561. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  104562. /**
  104563. * Removes a joint from the simulation
  104564. * @param mainImpostor defines the impostor used with the joint
  104565. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  104566. * @param joint defines the joint to remove
  104567. */
  104568. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  104569. /**
  104570. * Called by the scene. No need to call it.
  104571. * @param delta defines the timespam between frames
  104572. */
  104573. _step(delta: number): void;
  104574. /**
  104575. * Gets the current plugin used to run the simulation
  104576. * @returns current plugin
  104577. */
  104578. getPhysicsPlugin(): IPhysicsEnginePlugin;
  104579. /**
  104580. * Gets the list of physic impostors
  104581. * @returns an array of PhysicsImpostor
  104582. */
  104583. getImpostors(): Array<PhysicsImpostor>;
  104584. /**
  104585. * Gets the impostor for a physics enabled object
  104586. * @param object defines the object impersonated by the impostor
  104587. * @returns the PhysicsImpostor or null if not found
  104588. */
  104589. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  104590. /**
  104591. * Gets the impostor for a physics body object
  104592. * @param body defines physics body used by the impostor
  104593. * @returns the PhysicsImpostor or null if not found
  104594. */
  104595. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  104596. }
  104597. }
  104598. declare module BABYLON {
  104599. /** @hidden */
  104600. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  104601. private _useDeltaForWorldStep;
  104602. world: any;
  104603. name: string;
  104604. private _physicsMaterials;
  104605. private _fixedTimeStep;
  104606. BJSCANNON: any;
  104607. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  104608. setGravity(gravity: Vector3): void;
  104609. setTimeStep(timeStep: number): void;
  104610. getTimeStep(): number;
  104611. executeStep(delta: number): void;
  104612. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104613. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104614. generatePhysicsBody(impostor: PhysicsImpostor): void;
  104615. private _processChildMeshes;
  104616. removePhysicsBody(impostor: PhysicsImpostor): void;
  104617. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  104618. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  104619. private _addMaterial;
  104620. private _checkWithEpsilon;
  104621. private _createShape;
  104622. private _createHeightmap;
  104623. private _minus90X;
  104624. private _plus90X;
  104625. private _tmpPosition;
  104626. private _tmpDeltaPosition;
  104627. private _tmpUnityRotation;
  104628. private _updatePhysicsBodyTransformation;
  104629. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  104630. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  104631. isSupported(): boolean;
  104632. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  104633. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  104634. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104635. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104636. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  104637. getBodyMass(impostor: PhysicsImpostor): number;
  104638. getBodyFriction(impostor: PhysicsImpostor): number;
  104639. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  104640. getBodyRestitution(impostor: PhysicsImpostor): number;
  104641. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  104642. sleepBody(impostor: PhysicsImpostor): void;
  104643. wakeUpBody(impostor: PhysicsImpostor): void;
  104644. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  104645. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  104646. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  104647. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  104648. getRadius(impostor: PhysicsImpostor): number;
  104649. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  104650. dispose(): void;
  104651. private _extendNamespace;
  104652. }
  104653. }
  104654. declare module BABYLON {
  104655. /** @hidden */
  104656. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  104657. world: any;
  104658. name: string;
  104659. BJSOIMO: any;
  104660. constructor(iterations?: number, oimoInjection?: any);
  104661. setGravity(gravity: Vector3): void;
  104662. setTimeStep(timeStep: number): void;
  104663. getTimeStep(): number;
  104664. private _tmpImpostorsArray;
  104665. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  104666. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104667. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104668. generatePhysicsBody(impostor: PhysicsImpostor): void;
  104669. private _tmpPositionVector;
  104670. removePhysicsBody(impostor: PhysicsImpostor): void;
  104671. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  104672. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  104673. isSupported(): boolean;
  104674. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  104675. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  104676. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  104677. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  104678. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104679. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104680. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  104681. getBodyMass(impostor: PhysicsImpostor): number;
  104682. getBodyFriction(impostor: PhysicsImpostor): number;
  104683. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  104684. getBodyRestitution(impostor: PhysicsImpostor): number;
  104685. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  104686. sleepBody(impostor: PhysicsImpostor): void;
  104687. wakeUpBody(impostor: PhysicsImpostor): void;
  104688. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  104689. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  104690. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  104691. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  104692. getRadius(impostor: PhysicsImpostor): number;
  104693. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  104694. dispose(): void;
  104695. }
  104696. }
  104697. declare module BABYLON {
  104698. interface AbstractScene {
  104699. /**
  104700. * The list of reflection probes added to the scene
  104701. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  104702. */
  104703. reflectionProbes: Array<ReflectionProbe>;
  104704. /**
  104705. * Removes the given reflection probe from this scene.
  104706. * @param toRemove The reflection probe to remove
  104707. * @returns The index of the removed reflection probe
  104708. */
  104709. removeReflectionProbe(toRemove: ReflectionProbe): number;
  104710. /**
  104711. * Adds the given reflection probe to this scene.
  104712. * @param newReflectionProbe The reflection probe to add
  104713. */
  104714. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  104715. }
  104716. /**
  104717. * Class used to generate realtime reflection / refraction cube textures
  104718. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  104719. */
  104720. export class ReflectionProbe {
  104721. /** defines the name of the probe */
  104722. name: string;
  104723. private _scene;
  104724. private _renderTargetTexture;
  104725. private _projectionMatrix;
  104726. private _viewMatrix;
  104727. private _target;
  104728. private _add;
  104729. private _attachedMesh;
  104730. private _invertYAxis;
  104731. /** Gets or sets probe position (center of the cube map) */
  104732. position: Vector3;
  104733. /**
  104734. * Creates a new reflection probe
  104735. * @param name defines the name of the probe
  104736. * @param size defines the texture resolution (for each face)
  104737. * @param scene defines the hosting scene
  104738. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  104739. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  104740. */
  104741. constructor(
  104742. /** defines the name of the probe */
  104743. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  104744. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  104745. samples: number;
  104746. /** Gets or sets the refresh rate to use (on every frame by default) */
  104747. refreshRate: number;
  104748. /**
  104749. * Gets the hosting scene
  104750. * @returns a Scene
  104751. */
  104752. getScene(): Scene;
  104753. /** Gets the internal CubeTexture used to render to */
  104754. readonly cubeTexture: RenderTargetTexture;
  104755. /** Gets the list of meshes to render */
  104756. readonly renderList: Nullable<AbstractMesh[]>;
  104757. /**
  104758. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  104759. * @param mesh defines the mesh to attach to
  104760. */
  104761. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  104762. /**
  104763. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  104764. * @param renderingGroupId The rendering group id corresponding to its index
  104765. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  104766. */
  104767. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  104768. /**
  104769. * Clean all associated resources
  104770. */
  104771. dispose(): void;
  104772. /**
  104773. * Converts the reflection probe information to a readable string for debug purpose.
  104774. * @param fullDetails Supports for multiple levels of logging within scene loading
  104775. * @returns the human readable reflection probe info
  104776. */
  104777. toString(fullDetails?: boolean): string;
  104778. /**
  104779. * Get the class name of the relfection probe.
  104780. * @returns "ReflectionProbe"
  104781. */
  104782. getClassName(): string;
  104783. /**
  104784. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  104785. * @returns The JSON representation of the texture
  104786. */
  104787. serialize(): any;
  104788. /**
  104789. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  104790. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  104791. * @param scene Define the scene the parsed reflection probe should be instantiated in
  104792. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  104793. * @returns The parsed reflection probe if successful
  104794. */
  104795. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  104796. }
  104797. }
  104798. declare module BABYLON {
  104799. /** @hidden */
  104800. export var _BabylonLoaderRegistered: boolean;
  104801. }
  104802. declare module BABYLON {
  104803. /**
  104804. * The Physically based simple base material of BJS.
  104805. *
  104806. * This enables better naming and convention enforcements on top of the pbrMaterial.
  104807. * It is used as the base class for both the specGloss and metalRough conventions.
  104808. */
  104809. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  104810. /**
  104811. * Number of Simultaneous lights allowed on the material.
  104812. */
  104813. maxSimultaneousLights: number;
  104814. /**
  104815. * If sets to true, disables all the lights affecting the material.
  104816. */
  104817. disableLighting: boolean;
  104818. /**
  104819. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  104820. */
  104821. environmentTexture: BaseTexture;
  104822. /**
  104823. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  104824. */
  104825. invertNormalMapX: boolean;
  104826. /**
  104827. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  104828. */
  104829. invertNormalMapY: boolean;
  104830. /**
  104831. * Normal map used in the model.
  104832. */
  104833. normalTexture: BaseTexture;
  104834. /**
  104835. * Emissivie color used to self-illuminate the model.
  104836. */
  104837. emissiveColor: Color3;
  104838. /**
  104839. * Emissivie texture used to self-illuminate the model.
  104840. */
  104841. emissiveTexture: BaseTexture;
  104842. /**
  104843. * Occlusion Channel Strenght.
  104844. */
  104845. occlusionStrength: number;
  104846. /**
  104847. * Occlusion Texture of the material (adding extra occlusion effects).
  104848. */
  104849. occlusionTexture: BaseTexture;
  104850. /**
  104851. * Defines the alpha limits in alpha test mode.
  104852. */
  104853. alphaCutOff: number;
  104854. /**
  104855. * Gets the current double sided mode.
  104856. */
  104857. /**
  104858. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104859. */
  104860. doubleSided: boolean;
  104861. /**
  104862. * Stores the pre-calculated light information of a mesh in a texture.
  104863. */
  104864. lightmapTexture: BaseTexture;
  104865. /**
  104866. * If true, the light map contains occlusion information instead of lighting info.
  104867. */
  104868. useLightmapAsShadowmap: boolean;
  104869. /**
  104870. * Instantiates a new PBRMaterial instance.
  104871. *
  104872. * @param name The material name
  104873. * @param scene The scene the material will be use in.
  104874. */
  104875. constructor(name: string, scene: Scene);
  104876. getClassName(): string;
  104877. }
  104878. }
  104879. declare module BABYLON {
  104880. /**
  104881. * The PBR material of BJS following the metal roughness convention.
  104882. *
  104883. * This fits to the PBR convention in the GLTF definition:
  104884. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  104885. */
  104886. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  104887. /**
  104888. * The base color has two different interpretations depending on the value of metalness.
  104889. * When the material is a metal, the base color is the specific measured reflectance value
  104890. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  104891. * of the material.
  104892. */
  104893. baseColor: Color3;
  104894. /**
  104895. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  104896. * well as opacity information in the alpha channel.
  104897. */
  104898. baseTexture: BaseTexture;
  104899. /**
  104900. * Specifies the metallic scalar value of the material.
  104901. * Can also be used to scale the metalness values of the metallic texture.
  104902. */
  104903. metallic: number;
  104904. /**
  104905. * Specifies the roughness scalar value of the material.
  104906. * Can also be used to scale the roughness values of the metallic texture.
  104907. */
  104908. roughness: number;
  104909. /**
  104910. * Texture containing both the metallic value in the B channel and the
  104911. * roughness value in the G channel to keep better precision.
  104912. */
  104913. metallicRoughnessTexture: BaseTexture;
  104914. /**
  104915. * Instantiates a new PBRMetalRoughnessMaterial instance.
  104916. *
  104917. * @param name The material name
  104918. * @param scene The scene the material will be use in.
  104919. */
  104920. constructor(name: string, scene: Scene);
  104921. /**
  104922. * Return the currrent class name of the material.
  104923. */
  104924. getClassName(): string;
  104925. /**
  104926. * Makes a duplicate of the current material.
  104927. * @param name - name to use for the new material.
  104928. */
  104929. clone(name: string): PBRMetallicRoughnessMaterial;
  104930. /**
  104931. * Serialize the material to a parsable JSON object.
  104932. */
  104933. serialize(): any;
  104934. /**
  104935. * Parses a JSON object correponding to the serialize function.
  104936. */
  104937. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  104938. }
  104939. }
  104940. declare module BABYLON {
  104941. /**
  104942. * The PBR material of BJS following the specular glossiness convention.
  104943. *
  104944. * This fits to the PBR convention in the GLTF definition:
  104945. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  104946. */
  104947. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  104948. /**
  104949. * Specifies the diffuse color of the material.
  104950. */
  104951. diffuseColor: Color3;
  104952. /**
  104953. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  104954. * channel.
  104955. */
  104956. diffuseTexture: BaseTexture;
  104957. /**
  104958. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  104959. */
  104960. specularColor: Color3;
  104961. /**
  104962. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  104963. */
  104964. glossiness: number;
  104965. /**
  104966. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  104967. */
  104968. specularGlossinessTexture: BaseTexture;
  104969. /**
  104970. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  104971. *
  104972. * @param name The material name
  104973. * @param scene The scene the material will be use in.
  104974. */
  104975. constructor(name: string, scene: Scene);
  104976. /**
  104977. * Return the currrent class name of the material.
  104978. */
  104979. getClassName(): string;
  104980. /**
  104981. * Makes a duplicate of the current material.
  104982. * @param name - name to use for the new material.
  104983. */
  104984. clone(name: string): PBRSpecularGlossinessMaterial;
  104985. /**
  104986. * Serialize the material to a parsable JSON object.
  104987. */
  104988. serialize(): any;
  104989. /**
  104990. * Parses a JSON object correponding to the serialize function.
  104991. */
  104992. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  104993. }
  104994. }
  104995. declare module BABYLON {
  104996. /**
  104997. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  104998. * It can help converting any input color in a desired output one. This can then be used to create effects
  104999. * from sepia, black and white to sixties or futuristic rendering...
  105000. *
  105001. * The only supported format is currently 3dl.
  105002. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  105003. */
  105004. export class ColorGradingTexture extends BaseTexture {
  105005. /**
  105006. * The current texture matrix. (will always be identity in color grading texture)
  105007. */
  105008. private _textureMatrix;
  105009. /**
  105010. * The texture URL.
  105011. */
  105012. url: string;
  105013. /**
  105014. * Empty line regex stored for GC.
  105015. */
  105016. private static _noneEmptyLineRegex;
  105017. private _engine;
  105018. /**
  105019. * Instantiates a ColorGradingTexture from the following parameters.
  105020. *
  105021. * @param url The location of the color gradind data (currently only supporting 3dl)
  105022. * @param scene The scene the texture will be used in
  105023. */
  105024. constructor(url: string, scene: Scene);
  105025. /**
  105026. * Returns the texture matrix used in most of the material.
  105027. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  105028. */
  105029. getTextureMatrix(): Matrix;
  105030. /**
  105031. * Occurs when the file being loaded is a .3dl LUT file.
  105032. */
  105033. private load3dlTexture;
  105034. /**
  105035. * Starts the loading process of the texture.
  105036. */
  105037. private loadTexture;
  105038. /**
  105039. * Clones the color gradind texture.
  105040. */
  105041. clone(): ColorGradingTexture;
  105042. /**
  105043. * Called during delayed load for textures.
  105044. */
  105045. delayLoad(): void;
  105046. /**
  105047. * Parses a color grading texture serialized by Babylon.
  105048. * @param parsedTexture The texture information being parsedTexture
  105049. * @param scene The scene to load the texture in
  105050. * @param rootUrl The root url of the data assets to load
  105051. * @return A color gradind texture
  105052. */
  105053. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  105054. /**
  105055. * Serializes the LUT texture to json format.
  105056. */
  105057. serialize(): any;
  105058. }
  105059. }
  105060. declare module BABYLON {
  105061. /**
  105062. * Based on jsTGALoader - Javascript loader for TGA file
  105063. * By Vincent Thibault
  105064. * @see http://blog.robrowser.com/javascript-tga-loader.html
  105065. */
  105066. export class TGATools {
  105067. private static _TYPE_INDEXED;
  105068. private static _TYPE_RGB;
  105069. private static _TYPE_GREY;
  105070. private static _TYPE_RLE_INDEXED;
  105071. private static _TYPE_RLE_RGB;
  105072. private static _TYPE_RLE_GREY;
  105073. private static _ORIGIN_MASK;
  105074. private static _ORIGIN_SHIFT;
  105075. private static _ORIGIN_BL;
  105076. private static _ORIGIN_BR;
  105077. private static _ORIGIN_UL;
  105078. private static _ORIGIN_UR;
  105079. /**
  105080. * Gets the header of a TGA file
  105081. * @param data defines the TGA data
  105082. * @returns the header
  105083. */
  105084. static GetTGAHeader(data: Uint8Array): any;
  105085. /**
  105086. * Uploads TGA content to a Babylon Texture
  105087. * @hidden
  105088. */
  105089. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  105090. /** @hidden */
  105091. 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;
  105092. /** @hidden */
  105093. 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;
  105094. /** @hidden */
  105095. 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;
  105096. /** @hidden */
  105097. 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;
  105098. /** @hidden */
  105099. 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;
  105100. /** @hidden */
  105101. 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;
  105102. }
  105103. }
  105104. declare module BABYLON {
  105105. /**
  105106. * Implementation of the TGA Texture Loader.
  105107. * @hidden
  105108. */
  105109. export class _TGATextureLoader implements IInternalTextureLoader {
  105110. /**
  105111. * Defines wether the loader supports cascade loading the different faces.
  105112. */
  105113. readonly supportCascades: boolean;
  105114. /**
  105115. * This returns if the loader support the current file information.
  105116. * @param extension defines the file extension of the file being loaded
  105117. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105118. * @param fallback defines the fallback internal texture if any
  105119. * @param isBase64 defines whether the texture is encoded as a base64
  105120. * @param isBuffer defines whether the texture data are stored as a buffer
  105121. * @returns true if the loader can load the specified file
  105122. */
  105123. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  105124. /**
  105125. * Transform the url before loading if required.
  105126. * @param rootUrl the url of the texture
  105127. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105128. * @returns the transformed texture
  105129. */
  105130. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  105131. /**
  105132. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  105133. * @param rootUrl the url of the texture
  105134. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105135. * @returns the fallback texture
  105136. */
  105137. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  105138. /**
  105139. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  105140. * @param data contains the texture data
  105141. * @param texture defines the BabylonJS internal texture
  105142. * @param createPolynomials will be true if polynomials have been requested
  105143. * @param onLoad defines the callback to trigger once the texture is ready
  105144. * @param onError defines the callback to trigger in case of error
  105145. */
  105146. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  105147. /**
  105148. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  105149. * @param data contains the texture data
  105150. * @param texture defines the BabylonJS internal texture
  105151. * @param callback defines the method to call once ready to upload
  105152. */
  105153. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  105154. }
  105155. }
  105156. declare module BABYLON {
  105157. /**
  105158. * 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.
  105159. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  105160. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  105161. */
  105162. export class CustomProceduralTexture extends ProceduralTexture {
  105163. private _animate;
  105164. private _time;
  105165. private _config;
  105166. private _texturePath;
  105167. /**
  105168. * Instantiates a new Custom Procedural Texture.
  105169. * 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.
  105170. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  105171. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  105172. * @param name Define the name of the texture
  105173. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  105174. * @param size Define the size of the texture to create
  105175. * @param scene Define the scene the texture belongs to
  105176. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  105177. * @param generateMipMaps Define if the texture should creates mip maps or not
  105178. */
  105179. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  105180. private _loadJson;
  105181. /**
  105182. * Is the texture ready to be used ? (rendered at least once)
  105183. * @returns true if ready, otherwise, false.
  105184. */
  105185. isReady(): boolean;
  105186. /**
  105187. * Render the texture to its associated render target.
  105188. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  105189. */
  105190. render(useCameraPostProcess?: boolean): void;
  105191. /**
  105192. * Update the list of dependant textures samplers in the shader.
  105193. */
  105194. updateTextures(): void;
  105195. /**
  105196. * Update the uniform values of the procedural texture in the shader.
  105197. */
  105198. updateShaderUniforms(): void;
  105199. /**
  105200. * Define if the texture animates or not.
  105201. */
  105202. animate: boolean;
  105203. }
  105204. }
  105205. declare module BABYLON {
  105206. /** @hidden */
  105207. export var noisePixelShader: {
  105208. name: string;
  105209. shader: string;
  105210. };
  105211. }
  105212. declare module BABYLON {
  105213. /**
  105214. * Class used to generate noise procedural textures
  105215. */
  105216. export class NoiseProceduralTexture extends ProceduralTexture {
  105217. private _time;
  105218. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  105219. brightness: number;
  105220. /** Defines the number of octaves to process */
  105221. octaves: number;
  105222. /** Defines the level of persistence (0.8 by default) */
  105223. persistence: number;
  105224. /** Gets or sets animation speed factor (default is 1) */
  105225. animationSpeedFactor: number;
  105226. /**
  105227. * Creates a new NoiseProceduralTexture
  105228. * @param name defines the name fo the texture
  105229. * @param size defines the size of the texture (default is 256)
  105230. * @param scene defines the hosting scene
  105231. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  105232. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  105233. */
  105234. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  105235. private _updateShaderUniforms;
  105236. protected _getDefines(): string;
  105237. /** Generate the current state of the procedural texture */
  105238. render(useCameraPostProcess?: boolean): void;
  105239. /**
  105240. * Serializes this noise procedural texture
  105241. * @returns a serialized noise procedural texture object
  105242. */
  105243. serialize(): any;
  105244. /**
  105245. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  105246. * @param parsedTexture defines parsed texture data
  105247. * @param scene defines the current scene
  105248. * @param rootUrl defines the root URL containing noise procedural texture information
  105249. * @returns a parsed NoiseProceduralTexture
  105250. */
  105251. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  105252. }
  105253. }
  105254. declare module BABYLON {
  105255. /**
  105256. * Raw cube texture where the raw buffers are passed in
  105257. */
  105258. export class RawCubeTexture extends CubeTexture {
  105259. /**
  105260. * Creates a cube texture where the raw buffers are passed in.
  105261. * @param scene defines the scene the texture is attached to
  105262. * @param data defines the array of data to use to create each face
  105263. * @param size defines the size of the textures
  105264. * @param format defines the format of the data
  105265. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  105266. * @param generateMipMaps defines if the engine should generate the mip levels
  105267. * @param invertY defines if data must be stored with Y axis inverted
  105268. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105269. * @param compression defines the compression used (null by default)
  105270. */
  105271. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  105272. /**
  105273. * Updates the raw cube texture.
  105274. * @param data defines the data to store
  105275. * @param format defines the data format
  105276. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  105277. * @param invertY defines if data must be stored with Y axis inverted
  105278. * @param compression defines the compression used (null by default)
  105279. * @param level defines which level of the texture to update
  105280. */
  105281. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  105282. /**
  105283. * Updates a raw cube texture with RGBD encoded data.
  105284. * @param data defines the array of data [mipmap][face] to use to create each face
  105285. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  105286. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  105287. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  105288. * @returns a promsie that resolves when the operation is complete
  105289. */
  105290. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  105291. /**
  105292. * Clones the raw cube texture.
  105293. * @return a new cube texture
  105294. */
  105295. clone(): CubeTexture;
  105296. /** @hidden */
  105297. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  105298. }
  105299. }
  105300. declare module BABYLON {
  105301. /**
  105302. * Class used to store 3D textures containing user data
  105303. */
  105304. export class RawTexture3D extends Texture {
  105305. /** Gets or sets the texture format to use */
  105306. format: number;
  105307. private _engine;
  105308. /**
  105309. * Create a new RawTexture3D
  105310. * @param data defines the data of the texture
  105311. * @param width defines the width of the texture
  105312. * @param height defines the height of the texture
  105313. * @param depth defines the depth of the texture
  105314. * @param format defines the texture format to use
  105315. * @param scene defines the hosting scene
  105316. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  105317. * @param invertY defines if texture must be stored with Y axis inverted
  105318. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  105319. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  105320. */
  105321. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  105322. /** Gets or sets the texture format to use */
  105323. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  105324. /**
  105325. * Update the texture with new data
  105326. * @param data defines the data to store in the texture
  105327. */
  105328. update(data: ArrayBufferView): void;
  105329. }
  105330. }
  105331. declare module BABYLON {
  105332. /**
  105333. * Creates a refraction texture used by refraction channel of the standard material.
  105334. * It is like a mirror but to see through a material.
  105335. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  105336. */
  105337. export class RefractionTexture extends RenderTargetTexture {
  105338. /**
  105339. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  105340. * 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.
  105341. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  105342. */
  105343. refractionPlane: Plane;
  105344. /**
  105345. * Define how deep under the surface we should see.
  105346. */
  105347. depth: number;
  105348. /**
  105349. * Creates a refraction texture used by refraction channel of the standard material.
  105350. * It is like a mirror but to see through a material.
  105351. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  105352. * @param name Define the texture name
  105353. * @param size Define the size of the underlying texture
  105354. * @param scene Define the scene the refraction belongs to
  105355. * @param generateMipMaps Define if we need to generate mips level for the refraction
  105356. */
  105357. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  105358. /**
  105359. * Clone the refraction texture.
  105360. * @returns the cloned texture
  105361. */
  105362. clone(): RefractionTexture;
  105363. /**
  105364. * Serialize the texture to a JSON representation you could use in Parse later on
  105365. * @returns the serialized JSON representation
  105366. */
  105367. serialize(): any;
  105368. }
  105369. }
  105370. declare module BABYLON {
  105371. /**
  105372. * Configuration for Draco compression
  105373. */
  105374. export interface IDracoCompressionConfiguration {
  105375. /**
  105376. * Configuration for the decoder.
  105377. */
  105378. decoder?: {
  105379. /**
  105380. * The url to the WebAssembly module.
  105381. */
  105382. wasmUrl?: string;
  105383. /**
  105384. * The url to the WebAssembly binary.
  105385. */
  105386. wasmBinaryUrl?: string;
  105387. /**
  105388. * The url to the fallback JavaScript module.
  105389. */
  105390. fallbackUrl?: string;
  105391. };
  105392. }
  105393. /**
  105394. * Draco compression (https://google.github.io/draco/)
  105395. *
  105396. * This class wraps the Draco module.
  105397. *
  105398. * **Encoder**
  105399. *
  105400. * The encoder is not currently implemented.
  105401. *
  105402. * **Decoder**
  105403. *
  105404. * 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.
  105405. *
  105406. * To update the configuration, use the following code:
  105407. * ```javascript
  105408. * DracoCompression.Configuration = {
  105409. * decoder: {
  105410. * wasmUrl: "<url to the WebAssembly library>",
  105411. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  105412. * fallbackUrl: "<url to the fallback JavaScript library>",
  105413. * }
  105414. * };
  105415. * ```
  105416. *
  105417. * 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.
  105418. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  105419. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  105420. *
  105421. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  105422. * ```javascript
  105423. * var dracoCompression = new DracoCompression();
  105424. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  105425. * [VertexBuffer.PositionKind]: 0
  105426. * });
  105427. * ```
  105428. *
  105429. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  105430. */
  105431. export class DracoCompression implements IDisposable {
  105432. private static _DecoderModulePromise;
  105433. /**
  105434. * The configuration. Defaults to the following urls:
  105435. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  105436. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  105437. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  105438. */
  105439. static Configuration: IDracoCompressionConfiguration;
  105440. /**
  105441. * Returns true if the decoder is available.
  105442. */
  105443. static readonly DecoderAvailable: boolean;
  105444. /**
  105445. * Constructor
  105446. */
  105447. constructor();
  105448. /**
  105449. * Stop all async operations and release resources.
  105450. */
  105451. dispose(): void;
  105452. /**
  105453. * Decode Draco compressed mesh data to vertex data.
  105454. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  105455. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  105456. * @returns A promise that resolves with the decoded vertex data
  105457. */
  105458. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  105459. [kind: string]: number;
  105460. }): Promise<VertexData>;
  105461. private static _GetDecoderModule;
  105462. private static _LoadScriptAsync;
  105463. private static _LoadFileAsync;
  105464. }
  105465. }
  105466. declare module BABYLON {
  105467. /**
  105468. * Class for building Constructive Solid Geometry
  105469. */
  105470. export class CSG {
  105471. private polygons;
  105472. /**
  105473. * The world matrix
  105474. */
  105475. matrix: Matrix;
  105476. /**
  105477. * Stores the position
  105478. */
  105479. position: Vector3;
  105480. /**
  105481. * Stores the rotation
  105482. */
  105483. rotation: Vector3;
  105484. /**
  105485. * Stores the rotation quaternion
  105486. */
  105487. rotationQuaternion: Nullable<Quaternion>;
  105488. /**
  105489. * Stores the scaling vector
  105490. */
  105491. scaling: Vector3;
  105492. /**
  105493. * Convert the Mesh to CSG
  105494. * @param mesh The Mesh to convert to CSG
  105495. * @returns A new CSG from the Mesh
  105496. */
  105497. static FromMesh(mesh: Mesh): CSG;
  105498. /**
  105499. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  105500. * @param polygons Polygons used to construct a CSG solid
  105501. */
  105502. private static FromPolygons;
  105503. /**
  105504. * Clones, or makes a deep copy, of the CSG
  105505. * @returns A new CSG
  105506. */
  105507. clone(): CSG;
  105508. /**
  105509. * Unions this CSG with another CSG
  105510. * @param csg The CSG to union against this CSG
  105511. * @returns The unioned CSG
  105512. */
  105513. union(csg: CSG): CSG;
  105514. /**
  105515. * Unions this CSG with another CSG in place
  105516. * @param csg The CSG to union against this CSG
  105517. */
  105518. unionInPlace(csg: CSG): void;
  105519. /**
  105520. * Subtracts this CSG with another CSG
  105521. * @param csg The CSG to subtract against this CSG
  105522. * @returns A new CSG
  105523. */
  105524. subtract(csg: CSG): CSG;
  105525. /**
  105526. * Subtracts this CSG with another CSG in place
  105527. * @param csg The CSG to subtact against this CSG
  105528. */
  105529. subtractInPlace(csg: CSG): void;
  105530. /**
  105531. * Intersect this CSG with another CSG
  105532. * @param csg The CSG to intersect against this CSG
  105533. * @returns A new CSG
  105534. */
  105535. intersect(csg: CSG): CSG;
  105536. /**
  105537. * Intersects this CSG with another CSG in place
  105538. * @param csg The CSG to intersect against this CSG
  105539. */
  105540. intersectInPlace(csg: CSG): void;
  105541. /**
  105542. * Return a new CSG solid with solid and empty space switched. This solid is
  105543. * not modified.
  105544. * @returns A new CSG solid with solid and empty space switched
  105545. */
  105546. inverse(): CSG;
  105547. /**
  105548. * Inverses the CSG in place
  105549. */
  105550. inverseInPlace(): void;
  105551. /**
  105552. * This is used to keep meshes transformations so they can be restored
  105553. * when we build back a Babylon Mesh
  105554. * NB : All CSG operations are performed in world coordinates
  105555. * @param csg The CSG to copy the transform attributes from
  105556. * @returns This CSG
  105557. */
  105558. copyTransformAttributes(csg: CSG): CSG;
  105559. /**
  105560. * Build Raw mesh from CSG
  105561. * Coordinates here are in world space
  105562. * @param name The name of the mesh geometry
  105563. * @param scene The Scene
  105564. * @param keepSubMeshes Specifies if the submeshes should be kept
  105565. * @returns A new Mesh
  105566. */
  105567. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  105568. /**
  105569. * Build Mesh from CSG taking material and transforms into account
  105570. * @param name The name of the Mesh
  105571. * @param material The material of the Mesh
  105572. * @param scene The Scene
  105573. * @param keepSubMeshes Specifies if submeshes should be kept
  105574. * @returns The new Mesh
  105575. */
  105576. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  105577. }
  105578. }
  105579. declare module BABYLON {
  105580. /**
  105581. * Class used to create a trail following a mesh
  105582. */
  105583. export class TrailMesh extends Mesh {
  105584. private _generator;
  105585. private _autoStart;
  105586. private _running;
  105587. private _diameter;
  105588. private _length;
  105589. private _sectionPolygonPointsCount;
  105590. private _sectionVectors;
  105591. private _sectionNormalVectors;
  105592. private _beforeRenderObserver;
  105593. /**
  105594. * @constructor
  105595. * @param name The value used by scene.getMeshByName() to do a lookup.
  105596. * @param generator The mesh to generate a trail.
  105597. * @param scene The scene to add this mesh to.
  105598. * @param diameter Diameter of trailing mesh. Default is 1.
  105599. * @param length Length of trailing mesh. Default is 60.
  105600. * @param autoStart Automatically start trailing mesh. Default true.
  105601. */
  105602. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  105603. /**
  105604. * "TrailMesh"
  105605. * @returns "TrailMesh"
  105606. */
  105607. getClassName(): string;
  105608. private _createMesh;
  105609. /**
  105610. * Start trailing mesh.
  105611. */
  105612. start(): void;
  105613. /**
  105614. * Stop trailing mesh.
  105615. */
  105616. stop(): void;
  105617. /**
  105618. * Update trailing mesh geometry.
  105619. */
  105620. update(): void;
  105621. /**
  105622. * Returns a new TrailMesh object.
  105623. * @param name is a string, the name given to the new mesh
  105624. * @param newGenerator use new generator object for cloned trail mesh
  105625. * @returns a new mesh
  105626. */
  105627. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  105628. /**
  105629. * Serializes this trail mesh
  105630. * @param serializationObject object to write serialization to
  105631. */
  105632. serialize(serializationObject: any): void;
  105633. /**
  105634. * Parses a serialized trail mesh
  105635. * @param parsedMesh the serialized mesh
  105636. * @param scene the scene to create the trail mesh in
  105637. * @returns the created trail mesh
  105638. */
  105639. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  105640. }
  105641. }
  105642. declare module BABYLON {
  105643. /**
  105644. * Class containing static functions to help procedurally build meshes
  105645. */
  105646. export class RibbonBuilder {
  105647. /**
  105648. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  105649. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  105650. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  105651. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  105652. * * 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
  105653. * * 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
  105654. * * 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
  105655. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105656. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105657. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105658. * * 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
  105659. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  105660. * * 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
  105661. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  105662. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105663. * @param name defines the name of the mesh
  105664. * @param options defines the options used to create the mesh
  105665. * @param scene defines the hosting scene
  105666. * @returns the ribbon mesh
  105667. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  105668. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105669. */
  105670. static CreateRibbon(name: string, options: {
  105671. pathArray: Vector3[][];
  105672. closeArray?: boolean;
  105673. closePath?: boolean;
  105674. offset?: number;
  105675. updatable?: boolean;
  105676. sideOrientation?: number;
  105677. frontUVs?: Vector4;
  105678. backUVs?: Vector4;
  105679. instance?: Mesh;
  105680. invertUV?: boolean;
  105681. uvs?: Vector2[];
  105682. colors?: Color4[];
  105683. }, scene?: Nullable<Scene>): Mesh;
  105684. }
  105685. }
  105686. declare module BABYLON {
  105687. /**
  105688. * Class containing static functions to help procedurally build meshes
  105689. */
  105690. export class TorusKnotBuilder {
  105691. /**
  105692. * Creates a torus knot mesh
  105693. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  105694. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  105695. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  105696. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  105697. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105698. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105699. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105700. * @param name defines the name of the mesh
  105701. * @param options defines the options used to create the mesh
  105702. * @param scene defines the hosting scene
  105703. * @returns the torus knot mesh
  105704. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  105705. */
  105706. static CreateTorusKnot(name: string, options: {
  105707. radius?: number;
  105708. tube?: number;
  105709. radialSegments?: number;
  105710. tubularSegments?: number;
  105711. p?: number;
  105712. q?: number;
  105713. updatable?: boolean;
  105714. sideOrientation?: number;
  105715. frontUVs?: Vector4;
  105716. backUVs?: Vector4;
  105717. }, scene: any): Mesh;
  105718. }
  105719. }
  105720. declare module BABYLON {
  105721. /**
  105722. * Polygon
  105723. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  105724. */
  105725. export class Polygon {
  105726. /**
  105727. * Creates a rectangle
  105728. * @param xmin bottom X coord
  105729. * @param ymin bottom Y coord
  105730. * @param xmax top X coord
  105731. * @param ymax top Y coord
  105732. * @returns points that make the resulting rectation
  105733. */
  105734. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  105735. /**
  105736. * Creates a circle
  105737. * @param radius radius of circle
  105738. * @param cx scale in x
  105739. * @param cy scale in y
  105740. * @param numberOfSides number of sides that make up the circle
  105741. * @returns points that make the resulting circle
  105742. */
  105743. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  105744. /**
  105745. * Creates a polygon from input string
  105746. * @param input Input polygon data
  105747. * @returns the parsed points
  105748. */
  105749. static Parse(input: string): Vector2[];
  105750. /**
  105751. * Starts building a polygon from x and y coordinates
  105752. * @param x x coordinate
  105753. * @param y y coordinate
  105754. * @returns the started path2
  105755. */
  105756. static StartingAt(x: number, y: number): Path2;
  105757. }
  105758. /**
  105759. * Builds a polygon
  105760. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  105761. */
  105762. export class PolygonMeshBuilder {
  105763. private _points;
  105764. private _outlinepoints;
  105765. private _holes;
  105766. private _name;
  105767. private _scene;
  105768. private _epoints;
  105769. private _eholes;
  105770. private _addToepoint;
  105771. /**
  105772. * Babylon reference to the earcut plugin.
  105773. */
  105774. bjsEarcut: any;
  105775. /**
  105776. * Creates a PolygonMeshBuilder
  105777. * @param name name of the builder
  105778. * @param contours Path of the polygon
  105779. * @param scene scene to add to
  105780. * @param earcutInjection can be used to inject your own earcut reference
  105781. */
  105782. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  105783. /**
  105784. * Adds a whole within the polygon
  105785. * @param hole Array of points defining the hole
  105786. * @returns this
  105787. */
  105788. addHole(hole: Vector2[]): PolygonMeshBuilder;
  105789. /**
  105790. * Creates the polygon
  105791. * @param updatable If the mesh should be updatable
  105792. * @param depth The depth of the mesh created
  105793. * @returns the created mesh
  105794. */
  105795. build(updatable?: boolean, depth?: number): Mesh;
  105796. /**
  105797. * Creates the polygon
  105798. * @param depth The depth of the mesh created
  105799. * @returns the created VertexData
  105800. */
  105801. buildVertexData(depth?: number): VertexData;
  105802. /**
  105803. * Adds a side to the polygon
  105804. * @param positions points that make the polygon
  105805. * @param normals normals of the polygon
  105806. * @param uvs uvs of the polygon
  105807. * @param indices indices of the polygon
  105808. * @param bounds bounds of the polygon
  105809. * @param points points of the polygon
  105810. * @param depth depth of the polygon
  105811. * @param flip flip of the polygon
  105812. */
  105813. private addSide;
  105814. }
  105815. }
  105816. declare module BABYLON {
  105817. /**
  105818. * Class containing static functions to help procedurally build meshes
  105819. */
  105820. export class PolygonBuilder {
  105821. /**
  105822. * Creates a polygon mesh
  105823. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  105824. * * 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
  105825. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105826. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  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)
  105828. * * Remember you can only change the shape positions, not their number when updating a polygon
  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. * @param earcutInjection can be used to inject your own earcut reference
  105833. * @returns the polygon mesh
  105834. */
  105835. static CreatePolygon(name: string, options: {
  105836. shape: Vector3[];
  105837. holes?: Vector3[][];
  105838. depth?: number;
  105839. faceUV?: Vector4[];
  105840. faceColors?: Color4[];
  105841. updatable?: boolean;
  105842. sideOrientation?: number;
  105843. frontUVs?: Vector4;
  105844. backUVs?: Vector4;
  105845. }, scene: Scene, earcutInjection?: any): Mesh;
  105846. /**
  105847. * Creates an extruded polygon mesh, with depth in the Y direction.
  105848. * * 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)
  105849. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  105850. * @param name defines the name of the mesh
  105851. * @param options defines the options used to create the mesh
  105852. * @param scene defines the hosting scene
  105853. * @param earcutInjection can be used to inject your own earcut reference
  105854. * @returns the polygon mesh
  105855. */
  105856. static ExtrudePolygon(name: string, options: {
  105857. shape: Vector3[];
  105858. holes?: Vector3[][];
  105859. depth?: number;
  105860. faceUV?: Vector4[];
  105861. faceColors?: Color4[];
  105862. updatable?: boolean;
  105863. sideOrientation?: number;
  105864. frontUVs?: Vector4;
  105865. backUVs?: Vector4;
  105866. }, scene: Scene, earcutInjection?: any): Mesh;
  105867. }
  105868. }
  105869. declare module BABYLON {
  105870. /**
  105871. * Class containing static functions to help procedurally build meshes
  105872. */
  105873. export class ShapeBuilder {
  105874. /**
  105875. * 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.
  105876. * * 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.
  105877. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  105878. * * 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.
  105879. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  105880. * * 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
  105881. * * 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
  105882. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  105883. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105884. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105885. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  105886. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105887. * @param name defines the name of the mesh
  105888. * @param options defines the options used to create the mesh
  105889. * @param scene defines the hosting scene
  105890. * @returns the extruded shape mesh
  105891. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105892. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105893. */
  105894. static ExtrudeShape(name: string, options: {
  105895. shape: Vector3[];
  105896. path: Vector3[];
  105897. scale?: number;
  105898. rotation?: number;
  105899. cap?: number;
  105900. updatable?: boolean;
  105901. sideOrientation?: number;
  105902. frontUVs?: Vector4;
  105903. backUVs?: Vector4;
  105904. instance?: Mesh;
  105905. invertUV?: boolean;
  105906. }, scene?: Nullable<Scene>): Mesh;
  105907. /**
  105908. * Creates an custom extruded shape mesh.
  105909. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  105910. * * 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.
  105911. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  105912. * * 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
  105913. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  105914. * * 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
  105915. * * It must returns a float value that will be the scale value applied to the shape on each path point
  105916. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  105917. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  105918. * * 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
  105919. * * 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
  105920. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  105921. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105922. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105923. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105924. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105925. * @param name defines the name of the mesh
  105926. * @param options defines the options used to create the mesh
  105927. * @param scene defines the hosting scene
  105928. * @returns the custom extruded shape mesh
  105929. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  105930. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105931. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105932. */
  105933. static ExtrudeShapeCustom(name: string, options: {
  105934. shape: Vector3[];
  105935. path: Vector3[];
  105936. scaleFunction?: any;
  105937. rotationFunction?: any;
  105938. ribbonCloseArray?: boolean;
  105939. ribbonClosePath?: boolean;
  105940. cap?: number;
  105941. updatable?: boolean;
  105942. sideOrientation?: number;
  105943. frontUVs?: Vector4;
  105944. backUVs?: Vector4;
  105945. instance?: Mesh;
  105946. invertUV?: boolean;
  105947. }, scene: Scene): Mesh;
  105948. private static _ExtrudeShapeGeneric;
  105949. }
  105950. }
  105951. declare module BABYLON {
  105952. /**
  105953. * Class containing static functions to help procedurally build meshes
  105954. */
  105955. export class LatheBuilder {
  105956. /**
  105957. * Creates lathe mesh.
  105958. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  105959. * * 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
  105960. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  105961. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  105962. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  105963. * * 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
  105964. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  105965. * * 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
  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 optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105969. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105970. * @param name defines the name of the mesh
  105971. * @param options defines the options used to create the mesh
  105972. * @param scene defines the hosting scene
  105973. * @returns the lathe mesh
  105974. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  105975. */
  105976. static CreateLathe(name: string, options: {
  105977. shape: Vector3[];
  105978. radius?: number;
  105979. tessellation?: number;
  105980. clip?: number;
  105981. arc?: number;
  105982. closed?: boolean;
  105983. updatable?: boolean;
  105984. sideOrientation?: number;
  105985. frontUVs?: Vector4;
  105986. backUVs?: Vector4;
  105987. cap?: number;
  105988. invertUV?: boolean;
  105989. }, scene: Scene): Mesh;
  105990. }
  105991. }
  105992. declare module BABYLON {
  105993. /**
  105994. * Class containing static functions to help procedurally build meshes
  105995. */
  105996. export class TubeBuilder {
  105997. /**
  105998. * Creates a tube mesh.
  105999. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  106000. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  106001. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  106002. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  106003. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  106004. * * 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)
  106005. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  106006. * * 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
  106007. * * 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
  106008. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106009. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106010. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106011. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106012. * @param name defines the name of the mesh
  106013. * @param options defines the options used to create the mesh
  106014. * @param scene defines the hosting scene
  106015. * @returns the tube mesh
  106016. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106017. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  106018. */
  106019. static CreateTube(name: string, options: {
  106020. path: Vector3[];
  106021. radius?: number;
  106022. tessellation?: number;
  106023. radiusFunction?: {
  106024. (i: number, distance: number): number;
  106025. };
  106026. cap?: number;
  106027. arc?: number;
  106028. updatable?: boolean;
  106029. sideOrientation?: number;
  106030. frontUVs?: Vector4;
  106031. backUVs?: Vector4;
  106032. instance?: Mesh;
  106033. invertUV?: boolean;
  106034. }, scene: Scene): Mesh;
  106035. }
  106036. }
  106037. declare module BABYLON {
  106038. /**
  106039. * Class containing static functions to help procedurally build meshes
  106040. */
  106041. export class IcoSphereBuilder {
  106042. /**
  106043. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  106044. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  106045. * * 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`)
  106046. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  106047. * * 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
  106048. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106049. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106050. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106051. * @param name defines the name of the mesh
  106052. * @param options defines the options used to create the mesh
  106053. * @param scene defines the hosting scene
  106054. * @returns the icosahedron mesh
  106055. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  106056. */
  106057. static CreateIcoSphere(name: string, options: {
  106058. radius?: number;
  106059. radiusX?: number;
  106060. radiusY?: number;
  106061. radiusZ?: number;
  106062. flat?: boolean;
  106063. subdivisions?: number;
  106064. sideOrientation?: number;
  106065. frontUVs?: Vector4;
  106066. backUVs?: Vector4;
  106067. updatable?: boolean;
  106068. }, scene: Scene): Mesh;
  106069. }
  106070. }
  106071. declare module BABYLON {
  106072. /**
  106073. * Class containing static functions to help procedurally build meshes
  106074. */
  106075. export class DecalBuilder {
  106076. /**
  106077. * Creates a decal mesh.
  106078. * 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
  106079. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  106080. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  106081. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  106082. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  106083. * @param name defines the name of the mesh
  106084. * @param sourceMesh defines the mesh where the decal must be applied
  106085. * @param options defines the options used to create the mesh
  106086. * @param scene defines the hosting scene
  106087. * @returns the decal mesh
  106088. * @see https://doc.babylonjs.com/how_to/decals
  106089. */
  106090. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  106091. position?: Vector3;
  106092. normal?: Vector3;
  106093. size?: Vector3;
  106094. angle?: number;
  106095. }): Mesh;
  106096. }
  106097. }
  106098. declare module BABYLON {
  106099. /**
  106100. * Class containing static functions to help procedurally build meshes
  106101. */
  106102. export class MeshBuilder {
  106103. /**
  106104. * Creates a box mesh
  106105. * * The parameter `size` sets the size (float) of each box side (default 1)
  106106. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  106107. * * 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)
  106108. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  106109. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106110. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106111. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106112. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  106113. * @param name defines the name of the mesh
  106114. * @param options defines the options used to create the mesh
  106115. * @param scene defines the hosting scene
  106116. * @returns the box mesh
  106117. */
  106118. static CreateBox(name: string, options: {
  106119. size?: number;
  106120. width?: number;
  106121. height?: number;
  106122. depth?: number;
  106123. faceUV?: Vector4[];
  106124. faceColors?: Color4[];
  106125. sideOrientation?: number;
  106126. frontUVs?: Vector4;
  106127. backUVs?: Vector4;
  106128. updatable?: boolean;
  106129. }, scene?: Nullable<Scene>): Mesh;
  106130. /**
  106131. * Creates a sphere mesh
  106132. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  106133. * * 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`)
  106134. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  106135. * * 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
  106136. * * 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)
  106137. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106138. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106139. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106140. * @param name defines the name of the mesh
  106141. * @param options defines the options used to create the mesh
  106142. * @param scene defines the hosting scene
  106143. * @returns the sphere mesh
  106144. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  106145. */
  106146. static CreateSphere(name: string, options: {
  106147. segments?: number;
  106148. diameter?: number;
  106149. diameterX?: number;
  106150. diameterY?: number;
  106151. diameterZ?: number;
  106152. arc?: number;
  106153. slice?: number;
  106154. sideOrientation?: number;
  106155. frontUVs?: Vector4;
  106156. backUVs?: Vector4;
  106157. updatable?: boolean;
  106158. }, scene: any): Mesh;
  106159. /**
  106160. * Creates a plane polygonal mesh. By default, this is a disc
  106161. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  106162. * * 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
  106163. * * 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
  106164. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106165. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106166. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106167. * @param name defines the name of the mesh
  106168. * @param options defines the options used to create the mesh
  106169. * @param scene defines the hosting scene
  106170. * @returns the plane polygonal mesh
  106171. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  106172. */
  106173. static CreateDisc(name: string, options: {
  106174. radius?: number;
  106175. tessellation?: number;
  106176. arc?: number;
  106177. updatable?: boolean;
  106178. sideOrientation?: number;
  106179. frontUVs?: Vector4;
  106180. backUVs?: Vector4;
  106181. }, scene?: Nullable<Scene>): Mesh;
  106182. /**
  106183. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  106184. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  106185. * * 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`)
  106186. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  106187. * * 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
  106188. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106189. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106191. * @param name defines the name of the mesh
  106192. * @param options defines the options used to create the mesh
  106193. * @param scene defines the hosting scene
  106194. * @returns the icosahedron mesh
  106195. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  106196. */
  106197. static CreateIcoSphere(name: string, options: {
  106198. radius?: number;
  106199. radiusX?: number;
  106200. radiusY?: number;
  106201. radiusZ?: number;
  106202. flat?: boolean;
  106203. subdivisions?: number;
  106204. sideOrientation?: number;
  106205. frontUVs?: Vector4;
  106206. backUVs?: Vector4;
  106207. updatable?: boolean;
  106208. }, scene: Scene): Mesh;
  106209. /**
  106210. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  106211. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  106212. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  106213. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  106214. * * 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
  106215. * * 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
  106216. * * 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
  106217. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106218. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106219. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106220. * * 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
  106221. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  106222. * * 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
  106223. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  106224. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106225. * @param name defines the name of the mesh
  106226. * @param options defines the options used to create the mesh
  106227. * @param scene defines the hosting scene
  106228. * @returns the ribbon mesh
  106229. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  106230. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106231. */
  106232. static CreateRibbon(name: string, options: {
  106233. pathArray: Vector3[][];
  106234. closeArray?: boolean;
  106235. closePath?: boolean;
  106236. offset?: number;
  106237. updatable?: boolean;
  106238. sideOrientation?: number;
  106239. frontUVs?: Vector4;
  106240. backUVs?: Vector4;
  106241. instance?: Mesh;
  106242. invertUV?: boolean;
  106243. uvs?: Vector2[];
  106244. colors?: Color4[];
  106245. }, scene?: Nullable<Scene>): Mesh;
  106246. /**
  106247. * Creates a cylinder or a cone mesh
  106248. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  106249. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  106250. * * 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.
  106251. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  106252. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  106253. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  106254. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  106255. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  106256. * * 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).
  106257. * * 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
  106258. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  106259. * * 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
  106260. * * 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.
  106261. * * If `enclose` is false, a ring surface is one element.
  106262. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  106263. * * 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
  106264. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106265. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106267. * @param name defines the name of the mesh
  106268. * @param options defines the options used to create the mesh
  106269. * @param scene defines the hosting scene
  106270. * @returns the cylinder mesh
  106271. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  106272. */
  106273. static CreateCylinder(name: string, options: {
  106274. height?: number;
  106275. diameterTop?: number;
  106276. diameterBottom?: number;
  106277. diameter?: number;
  106278. tessellation?: number;
  106279. subdivisions?: number;
  106280. arc?: number;
  106281. faceColors?: Color4[];
  106282. faceUV?: Vector4[];
  106283. updatable?: boolean;
  106284. hasRings?: boolean;
  106285. enclose?: boolean;
  106286. sideOrientation?: number;
  106287. frontUVs?: Vector4;
  106288. backUVs?: Vector4;
  106289. }, scene: any): Mesh;
  106290. /**
  106291. * Creates a torus mesh
  106292. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  106293. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  106294. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  106295. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106296. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106297. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106298. * @param name defines the name of the mesh
  106299. * @param options defines the options used to create the mesh
  106300. * @param scene defines the hosting scene
  106301. * @returns the torus mesh
  106302. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  106303. */
  106304. static CreateTorus(name: string, options: {
  106305. diameter?: number;
  106306. thickness?: number;
  106307. tessellation?: number;
  106308. updatable?: boolean;
  106309. sideOrientation?: number;
  106310. frontUVs?: Vector4;
  106311. backUVs?: Vector4;
  106312. }, scene: any): Mesh;
  106313. /**
  106314. * Creates a torus knot mesh
  106315. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  106316. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  106317. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  106318. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  106319. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106320. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106321. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106322. * @param name defines the name of the mesh
  106323. * @param options defines the options used to create the mesh
  106324. * @param scene defines the hosting scene
  106325. * @returns the torus knot mesh
  106326. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  106327. */
  106328. static CreateTorusKnot(name: string, options: {
  106329. radius?: number;
  106330. tube?: number;
  106331. radialSegments?: number;
  106332. tubularSegments?: number;
  106333. p?: number;
  106334. q?: number;
  106335. updatable?: boolean;
  106336. sideOrientation?: number;
  106337. frontUVs?: Vector4;
  106338. backUVs?: Vector4;
  106339. }, scene: any): Mesh;
  106340. /**
  106341. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  106342. * * 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
  106343. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  106344. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  106345. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  106346. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  106347. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  106348. * * 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
  106349. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  106350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106351. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  106352. * @param name defines the name of the new line system
  106353. * @param options defines the options used to create the line system
  106354. * @param scene defines the hosting scene
  106355. * @returns a new line system mesh
  106356. */
  106357. static CreateLineSystem(name: string, options: {
  106358. lines: Vector3[][];
  106359. updatable?: boolean;
  106360. instance?: Nullable<LinesMesh>;
  106361. colors?: Nullable<Color4[][]>;
  106362. useVertexAlpha?: boolean;
  106363. }, scene: Nullable<Scene>): LinesMesh;
  106364. /**
  106365. * Creates a line mesh
  106366. * 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
  106367. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  106368. * * The parameter `points` is an array successive Vector3
  106369. * * 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
  106370. * * The optional parameter `colors` is an array of successive Color4, one per line point
  106371. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  106372. * * When updating an instance, remember that only point positions can change, not the number of points
  106373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106374. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  106375. * @param name defines the name of the new line system
  106376. * @param options defines the options used to create the line system
  106377. * @param scene defines the hosting scene
  106378. * @returns a new line mesh
  106379. */
  106380. static CreateLines(name: string, options: {
  106381. points: Vector3[];
  106382. updatable?: boolean;
  106383. instance?: Nullable<LinesMesh>;
  106384. colors?: Color4[];
  106385. useVertexAlpha?: boolean;
  106386. }, scene?: Nullable<Scene>): LinesMesh;
  106387. /**
  106388. * Creates a dashed line mesh
  106389. * * 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
  106390. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  106391. * * The parameter `points` is an array successive Vector3
  106392. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  106393. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  106394. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  106395. * * 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
  106396. * * When updating an instance, remember that only point positions can change, not the number of points
  106397. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106398. * @param name defines the name of the mesh
  106399. * @param options defines the options used to create the mesh
  106400. * @param scene defines the hosting scene
  106401. * @returns the dashed line mesh
  106402. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  106403. */
  106404. static CreateDashedLines(name: string, options: {
  106405. points: Vector3[];
  106406. dashSize?: number;
  106407. gapSize?: number;
  106408. dashNb?: number;
  106409. updatable?: boolean;
  106410. instance?: LinesMesh;
  106411. }, scene?: Nullable<Scene>): LinesMesh;
  106412. /**
  106413. * 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.
  106414. * * 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.
  106415. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  106416. * * 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.
  106417. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  106418. * * 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
  106419. * * 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
  106420. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  106421. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106422. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106423. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  106424. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106425. * @param name defines the name of the mesh
  106426. * @param options defines the options used to create the mesh
  106427. * @param scene defines the hosting scene
  106428. * @returns the extruded shape mesh
  106429. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106430. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106431. */
  106432. static ExtrudeShape(name: string, options: {
  106433. shape: Vector3[];
  106434. path: Vector3[];
  106435. scale?: number;
  106436. rotation?: number;
  106437. cap?: number;
  106438. updatable?: boolean;
  106439. sideOrientation?: number;
  106440. frontUVs?: Vector4;
  106441. backUVs?: Vector4;
  106442. instance?: Mesh;
  106443. invertUV?: boolean;
  106444. }, scene?: Nullable<Scene>): Mesh;
  106445. /**
  106446. * Creates an custom extruded shape mesh.
  106447. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  106448. * * 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.
  106449. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  106450. * * 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
  106451. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  106452. * * 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
  106453. * * It must returns a float value that will be the scale value applied to the shape on each path point
  106454. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  106455. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  106456. * * 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
  106457. * * 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
  106458. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  106459. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106460. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106461. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106463. * @param name defines the name of the mesh
  106464. * @param options defines the options used to create the mesh
  106465. * @param scene defines the hosting scene
  106466. * @returns the custom extruded shape mesh
  106467. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  106468. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106469. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106470. */
  106471. static ExtrudeShapeCustom(name: string, options: {
  106472. shape: Vector3[];
  106473. path: Vector3[];
  106474. scaleFunction?: any;
  106475. rotationFunction?: any;
  106476. ribbonCloseArray?: boolean;
  106477. ribbonClosePath?: boolean;
  106478. cap?: number;
  106479. updatable?: boolean;
  106480. sideOrientation?: number;
  106481. frontUVs?: Vector4;
  106482. backUVs?: Vector4;
  106483. instance?: Mesh;
  106484. invertUV?: boolean;
  106485. }, scene: Scene): Mesh;
  106486. /**
  106487. * Creates lathe mesh.
  106488. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  106489. * * 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
  106490. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  106491. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  106492. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  106493. * * 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
  106494. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  106495. * * 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
  106496. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106497. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106498. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106500. * @param name defines the name of the mesh
  106501. * @param options defines the options used to create the mesh
  106502. * @param scene defines the hosting scene
  106503. * @returns the lathe mesh
  106504. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  106505. */
  106506. static CreateLathe(name: string, options: {
  106507. shape: Vector3[];
  106508. radius?: number;
  106509. tessellation?: number;
  106510. clip?: number;
  106511. arc?: number;
  106512. closed?: boolean;
  106513. updatable?: boolean;
  106514. sideOrientation?: number;
  106515. frontUVs?: Vector4;
  106516. backUVs?: Vector4;
  106517. cap?: number;
  106518. invertUV?: boolean;
  106519. }, scene: Scene): Mesh;
  106520. /**
  106521. * Creates a plane mesh
  106522. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  106523. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  106524. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  106525. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106526. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106527. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106528. * @param name defines the name of the mesh
  106529. * @param options defines the options used to create the mesh
  106530. * @param scene defines the hosting scene
  106531. * @returns the plane mesh
  106532. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  106533. */
  106534. static CreatePlane(name: string, options: {
  106535. size?: number;
  106536. width?: number;
  106537. height?: number;
  106538. sideOrientation?: number;
  106539. frontUVs?: Vector4;
  106540. backUVs?: Vector4;
  106541. updatable?: boolean;
  106542. sourcePlane?: Plane;
  106543. }, scene: Scene): Mesh;
  106544. /**
  106545. * Creates a ground mesh
  106546. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  106547. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  106548. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106549. * @param name defines the name of the mesh
  106550. * @param options defines the options used to create the mesh
  106551. * @param scene defines the hosting scene
  106552. * @returns the ground mesh
  106553. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  106554. */
  106555. static CreateGround(name: string, options: {
  106556. width?: number;
  106557. height?: number;
  106558. subdivisions?: number;
  106559. subdivisionsX?: number;
  106560. subdivisionsY?: number;
  106561. updatable?: boolean;
  106562. }, scene: any): Mesh;
  106563. /**
  106564. * Creates a tiled ground mesh
  106565. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  106566. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  106567. * * 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
  106568. * * 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
  106569. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106570. * @param name defines the name of the mesh
  106571. * @param options defines the options used to create the mesh
  106572. * @param scene defines the hosting scene
  106573. * @returns the tiled ground mesh
  106574. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  106575. */
  106576. static CreateTiledGround(name: string, options: {
  106577. xmin: number;
  106578. zmin: number;
  106579. xmax: number;
  106580. zmax: number;
  106581. subdivisions?: {
  106582. w: number;
  106583. h: number;
  106584. };
  106585. precision?: {
  106586. w: number;
  106587. h: number;
  106588. };
  106589. updatable?: boolean;
  106590. }, scene: Scene): Mesh;
  106591. /**
  106592. * Creates a ground mesh from a height map
  106593. * * The parameter `url` sets the URL of the height map image resource.
  106594. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  106595. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  106596. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  106597. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  106598. * * 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.
  106599. * * 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).
  106600. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  106601. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106602. * @param name defines the name of the mesh
  106603. * @param url defines the url to the height map
  106604. * @param options defines the options used to create the mesh
  106605. * @param scene defines the hosting scene
  106606. * @returns the ground mesh
  106607. * @see https://doc.babylonjs.com/babylon101/height_map
  106608. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  106609. */
  106610. static CreateGroundFromHeightMap(name: string, url: string, options: {
  106611. width?: number;
  106612. height?: number;
  106613. subdivisions?: number;
  106614. minHeight?: number;
  106615. maxHeight?: number;
  106616. colorFilter?: Color3;
  106617. alphaFilter?: number;
  106618. updatable?: boolean;
  106619. onReady?: (mesh: GroundMesh) => void;
  106620. }, scene: Scene): GroundMesh;
  106621. /**
  106622. * Creates a polygon mesh
  106623. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  106624. * * 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
  106625. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106627. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  106628. * * Remember you can only change the shape positions, not their number when updating a polygon
  106629. * @param name defines the name of the mesh
  106630. * @param options defines the options used to create the mesh
  106631. * @param scene defines the hosting scene
  106632. * @param earcutInjection can be used to inject your own earcut reference
  106633. * @returns the polygon mesh
  106634. */
  106635. static CreatePolygon(name: string, options: {
  106636. shape: Vector3[];
  106637. holes?: Vector3[][];
  106638. depth?: number;
  106639. faceUV?: Vector4[];
  106640. faceColors?: Color4[];
  106641. updatable?: boolean;
  106642. sideOrientation?: number;
  106643. frontUVs?: Vector4;
  106644. backUVs?: Vector4;
  106645. }, scene: Scene, earcutInjection?: any): Mesh;
  106646. /**
  106647. * Creates an extruded polygon mesh, with depth in the Y direction.
  106648. * * 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)
  106649. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  106650. * @param name defines the name of the mesh
  106651. * @param options defines the options used to create the mesh
  106652. * @param scene defines the hosting scene
  106653. * @param earcutInjection can be used to inject your own earcut reference
  106654. * @returns the polygon mesh
  106655. */
  106656. static ExtrudePolygon(name: string, options: {
  106657. shape: Vector3[];
  106658. holes?: Vector3[][];
  106659. depth?: number;
  106660. faceUV?: Vector4[];
  106661. faceColors?: Color4[];
  106662. updatable?: boolean;
  106663. sideOrientation?: number;
  106664. frontUVs?: Vector4;
  106665. backUVs?: Vector4;
  106666. }, scene: Scene, earcutInjection?: any): Mesh;
  106667. /**
  106668. * Creates a tube mesh.
  106669. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  106670. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  106671. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  106672. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  106673. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  106674. * * 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)
  106675. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  106676. * * 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
  106677. * * 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
  106678. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106679. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106680. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106682. * @param name defines the name of the mesh
  106683. * @param options defines the options used to create the mesh
  106684. * @param scene defines the hosting scene
  106685. * @returns the tube mesh
  106686. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106687. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  106688. */
  106689. static CreateTube(name: string, options: {
  106690. path: Vector3[];
  106691. radius?: number;
  106692. tessellation?: number;
  106693. radiusFunction?: {
  106694. (i: number, distance: number): number;
  106695. };
  106696. cap?: number;
  106697. arc?: number;
  106698. updatable?: boolean;
  106699. sideOrientation?: number;
  106700. frontUVs?: Vector4;
  106701. backUVs?: Vector4;
  106702. instance?: Mesh;
  106703. invertUV?: boolean;
  106704. }, scene: Scene): Mesh;
  106705. /**
  106706. * Creates a polyhedron mesh
  106707. * * 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
  106708. * * The parameter `size` (positive float, default 1) sets the polygon size
  106709. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  106710. * * 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`
  106711. * * 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
  106712. * * 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)`)
  106713. * * 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
  106714. * * 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
  106715. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106716. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106717. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106718. * @param name defines the name of the mesh
  106719. * @param options defines the options used to create the mesh
  106720. * @param scene defines the hosting scene
  106721. * @returns the polyhedron mesh
  106722. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  106723. */
  106724. static CreatePolyhedron(name: string, options: {
  106725. type?: number;
  106726. size?: number;
  106727. sizeX?: number;
  106728. sizeY?: number;
  106729. sizeZ?: number;
  106730. custom?: any;
  106731. faceUV?: Vector4[];
  106732. faceColors?: Color4[];
  106733. flat?: boolean;
  106734. updatable?: boolean;
  106735. sideOrientation?: number;
  106736. frontUVs?: Vector4;
  106737. backUVs?: Vector4;
  106738. }, scene: Scene): Mesh;
  106739. /**
  106740. * Creates a decal mesh.
  106741. * 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
  106742. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  106743. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  106744. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  106745. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  106746. * @param name defines the name of the mesh
  106747. * @param sourceMesh defines the mesh where the decal must be applied
  106748. * @param options defines the options used to create the mesh
  106749. * @param scene defines the hosting scene
  106750. * @returns the decal mesh
  106751. * @see https://doc.babylonjs.com/how_to/decals
  106752. */
  106753. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  106754. position?: Vector3;
  106755. normal?: Vector3;
  106756. size?: Vector3;
  106757. angle?: number;
  106758. }): Mesh;
  106759. }
  106760. }
  106761. declare module BABYLON {
  106762. /**
  106763. * A simplifier interface for future simplification implementations
  106764. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106765. */
  106766. export interface ISimplifier {
  106767. /**
  106768. * Simplification of a given mesh according to the given settings.
  106769. * Since this requires computation, it is assumed that the function runs async.
  106770. * @param settings The settings of the simplification, including quality and distance
  106771. * @param successCallback A callback that will be called after the mesh was simplified.
  106772. * @param errorCallback in case of an error, this callback will be called. optional.
  106773. */
  106774. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  106775. }
  106776. /**
  106777. * Expected simplification settings.
  106778. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  106779. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106780. */
  106781. export interface ISimplificationSettings {
  106782. /**
  106783. * Gets or sets the expected quality
  106784. */
  106785. quality: number;
  106786. /**
  106787. * Gets or sets the distance when this optimized version should be used
  106788. */
  106789. distance: number;
  106790. /**
  106791. * Gets an already optimized mesh
  106792. */
  106793. optimizeMesh?: boolean;
  106794. }
  106795. /**
  106796. * Class used to specify simplification options
  106797. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106798. */
  106799. export class SimplificationSettings implements ISimplificationSettings {
  106800. /** expected quality */
  106801. quality: number;
  106802. /** distance when this optimized version should be used */
  106803. distance: number;
  106804. /** already optimized mesh */
  106805. optimizeMesh?: boolean | undefined;
  106806. /**
  106807. * Creates a SimplificationSettings
  106808. * @param quality expected quality
  106809. * @param distance distance when this optimized version should be used
  106810. * @param optimizeMesh already optimized mesh
  106811. */
  106812. constructor(
  106813. /** expected quality */
  106814. quality: number,
  106815. /** distance when this optimized version should be used */
  106816. distance: number,
  106817. /** already optimized mesh */
  106818. optimizeMesh?: boolean | undefined);
  106819. }
  106820. /**
  106821. * Interface used to define a simplification task
  106822. */
  106823. export interface ISimplificationTask {
  106824. /**
  106825. * Array of settings
  106826. */
  106827. settings: Array<ISimplificationSettings>;
  106828. /**
  106829. * Simplification type
  106830. */
  106831. simplificationType: SimplificationType;
  106832. /**
  106833. * Mesh to simplify
  106834. */
  106835. mesh: Mesh;
  106836. /**
  106837. * Callback called on success
  106838. */
  106839. successCallback?: () => void;
  106840. /**
  106841. * Defines if parallel processing can be used
  106842. */
  106843. parallelProcessing: boolean;
  106844. }
  106845. /**
  106846. * Queue used to order the simplification tasks
  106847. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106848. */
  106849. export class SimplificationQueue {
  106850. private _simplificationArray;
  106851. /**
  106852. * Gets a boolean indicating that the process is still running
  106853. */
  106854. running: boolean;
  106855. /**
  106856. * Creates a new queue
  106857. */
  106858. constructor();
  106859. /**
  106860. * Adds a new simplification task
  106861. * @param task defines a task to add
  106862. */
  106863. addTask(task: ISimplificationTask): void;
  106864. /**
  106865. * Execute next task
  106866. */
  106867. executeNext(): void;
  106868. /**
  106869. * Execute a simplification task
  106870. * @param task defines the task to run
  106871. */
  106872. runSimplification(task: ISimplificationTask): void;
  106873. private getSimplifier;
  106874. }
  106875. /**
  106876. * The implemented types of simplification
  106877. * At the moment only Quadratic Error Decimation is implemented
  106878. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106879. */
  106880. export enum SimplificationType {
  106881. /** Quadratic error decimation */
  106882. QUADRATIC = 0
  106883. }
  106884. }
  106885. declare module BABYLON {
  106886. interface Scene {
  106887. /** @hidden (Backing field) */
  106888. _simplificationQueue: SimplificationQueue;
  106889. /**
  106890. * Gets or sets the simplification queue attached to the scene
  106891. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106892. */
  106893. simplificationQueue: SimplificationQueue;
  106894. }
  106895. interface Mesh {
  106896. /**
  106897. * Simplify the mesh according to the given array of settings.
  106898. * Function will return immediately and will simplify async
  106899. * @param settings a collection of simplification settings
  106900. * @param parallelProcessing should all levels calculate parallel or one after the other
  106901. * @param simplificationType the type of simplification to run
  106902. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  106903. * @returns the current mesh
  106904. */
  106905. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  106906. }
  106907. /**
  106908. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  106909. * created in a scene
  106910. */
  106911. export class SimplicationQueueSceneComponent implements ISceneComponent {
  106912. /**
  106913. * The component name helpfull to identify the component in the list of scene components.
  106914. */
  106915. readonly name: string;
  106916. /**
  106917. * The scene the component belongs to.
  106918. */
  106919. scene: Scene;
  106920. /**
  106921. * Creates a new instance of the component for the given scene
  106922. * @param scene Defines the scene to register the component in
  106923. */
  106924. constructor(scene: Scene);
  106925. /**
  106926. * Registers the component in a given scene
  106927. */
  106928. register(): void;
  106929. /**
  106930. * Rebuilds the elements related to this component in case of
  106931. * context lost for instance.
  106932. */
  106933. rebuild(): void;
  106934. /**
  106935. * Disposes the component and the associated ressources
  106936. */
  106937. dispose(): void;
  106938. private _beforeCameraUpdate;
  106939. }
  106940. }
  106941. declare module BABYLON {
  106942. /**
  106943. * Class used to enable access to IndexedDB
  106944. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  106945. */
  106946. export class Database implements IOfflineProvider {
  106947. private _callbackManifestChecked;
  106948. private _currentSceneUrl;
  106949. private _db;
  106950. private _enableSceneOffline;
  106951. private _enableTexturesOffline;
  106952. private _manifestVersionFound;
  106953. private _mustUpdateRessources;
  106954. private _hasReachedQuota;
  106955. private _isSupported;
  106956. private _idbFactory;
  106957. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  106958. private static IsUASupportingBlobStorage;
  106959. /**
  106960. * Gets a boolean indicating if Database storate is enabled (off by default)
  106961. */
  106962. static IDBStorageEnabled: boolean;
  106963. /**
  106964. * Gets a boolean indicating if scene must be saved in the database
  106965. */
  106966. readonly enableSceneOffline: boolean;
  106967. /**
  106968. * Gets a boolean indicating if textures must be saved in the database
  106969. */
  106970. readonly enableTexturesOffline: boolean;
  106971. /**
  106972. * Creates a new Database
  106973. * @param urlToScene defines the url to load the scene
  106974. * @param callbackManifestChecked defines the callback to use when manifest is checked
  106975. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  106976. */
  106977. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  106978. private static _ParseURL;
  106979. private static _ReturnFullUrlLocation;
  106980. private _checkManifestFile;
  106981. /**
  106982. * Open the database and make it available
  106983. * @param successCallback defines the callback to call on success
  106984. * @param errorCallback defines the callback to call on error
  106985. */
  106986. open(successCallback: () => void, errorCallback: () => void): void;
  106987. /**
  106988. * Loads an image from the database
  106989. * @param url defines the url to load from
  106990. * @param image defines the target DOM image
  106991. */
  106992. loadImage(url: string, image: HTMLImageElement): void;
  106993. private _loadImageFromDBAsync;
  106994. private _saveImageIntoDBAsync;
  106995. private _checkVersionFromDB;
  106996. private _loadVersionFromDBAsync;
  106997. private _saveVersionIntoDBAsync;
  106998. /**
  106999. * Loads a file from database
  107000. * @param url defines the URL to load from
  107001. * @param sceneLoaded defines a callback to call on success
  107002. * @param progressCallBack defines a callback to call when progress changed
  107003. * @param errorCallback defines a callback to call on error
  107004. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  107005. */
  107006. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  107007. private _loadFileAsync;
  107008. private _saveFileAsync;
  107009. /**
  107010. * Validates if xhr data is correct
  107011. * @param xhr defines the request to validate
  107012. * @param dataType defines the expected data type
  107013. * @returns true if data is correct
  107014. */
  107015. private static _ValidateXHRData;
  107016. }
  107017. }
  107018. declare module BABYLON {
  107019. /** @hidden */
  107020. export var gpuUpdateParticlesPixelShader: {
  107021. name: string;
  107022. shader: string;
  107023. };
  107024. }
  107025. declare module BABYLON {
  107026. /** @hidden */
  107027. export var gpuUpdateParticlesVertexShader: {
  107028. name: string;
  107029. shader: string;
  107030. };
  107031. }
  107032. declare module BABYLON {
  107033. /** @hidden */
  107034. export var clipPlaneFragmentDeclaration2: {
  107035. name: string;
  107036. shader: string;
  107037. };
  107038. }
  107039. declare module BABYLON {
  107040. /** @hidden */
  107041. export var gpuRenderParticlesPixelShader: {
  107042. name: string;
  107043. shader: string;
  107044. };
  107045. }
  107046. declare module BABYLON {
  107047. /** @hidden */
  107048. export var clipPlaneVertexDeclaration2: {
  107049. name: string;
  107050. shader: string;
  107051. };
  107052. }
  107053. declare module BABYLON {
  107054. /** @hidden */
  107055. export var gpuRenderParticlesVertexShader: {
  107056. name: string;
  107057. shader: string;
  107058. };
  107059. }
  107060. declare module BABYLON {
  107061. /**
  107062. * This represents a GPU particle system in Babylon
  107063. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  107064. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  107065. */
  107066. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  107067. /**
  107068. * The layer mask we are rendering the particles through.
  107069. */
  107070. layerMask: number;
  107071. private _capacity;
  107072. private _activeCount;
  107073. private _currentActiveCount;
  107074. private _accumulatedCount;
  107075. private _renderEffect;
  107076. private _updateEffect;
  107077. private _buffer0;
  107078. private _buffer1;
  107079. private _spriteBuffer;
  107080. private _updateVAO;
  107081. private _renderVAO;
  107082. private _targetIndex;
  107083. private _sourceBuffer;
  107084. private _targetBuffer;
  107085. private _engine;
  107086. private _currentRenderId;
  107087. private _started;
  107088. private _stopped;
  107089. private _timeDelta;
  107090. private _randomTexture;
  107091. private _randomTexture2;
  107092. private _attributesStrideSize;
  107093. private _updateEffectOptions;
  107094. private _randomTextureSize;
  107095. private _actualFrame;
  107096. private readonly _rawTextureWidth;
  107097. /**
  107098. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  107099. */
  107100. static readonly IsSupported: boolean;
  107101. /**
  107102. * An event triggered when the system is disposed.
  107103. */
  107104. onDisposeObservable: Observable<GPUParticleSystem>;
  107105. /**
  107106. * Gets the maximum number of particles active at the same time.
  107107. * @returns The max number of active particles.
  107108. */
  107109. getCapacity(): number;
  107110. /**
  107111. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  107112. * to override the particles.
  107113. */
  107114. forceDepthWrite: boolean;
  107115. /**
  107116. * Gets or set the number of active particles
  107117. */
  107118. activeParticleCount: number;
  107119. private _preWarmDone;
  107120. /**
  107121. * Is this system ready to be used/rendered
  107122. * @return true if the system is ready
  107123. */
  107124. isReady(): boolean;
  107125. /**
  107126. * Gets if the system has been started. (Note: this will still be true after stop is called)
  107127. * @returns True if it has been started, otherwise false.
  107128. */
  107129. isStarted(): boolean;
  107130. /**
  107131. * Starts the particle system and begins to emit
  107132. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  107133. */
  107134. start(delay?: number): void;
  107135. /**
  107136. * Stops the particle system.
  107137. */
  107138. stop(): void;
  107139. /**
  107140. * Remove all active particles
  107141. */
  107142. reset(): void;
  107143. /**
  107144. * Returns the string "GPUParticleSystem"
  107145. * @returns a string containing the class name
  107146. */
  107147. getClassName(): string;
  107148. private _colorGradientsTexture;
  107149. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  107150. /**
  107151. * Adds a new color gradient
  107152. * @param gradient defines the gradient to use (between 0 and 1)
  107153. * @param color1 defines the color to affect to the specified gradient
  107154. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  107155. * @returns the current particle system
  107156. */
  107157. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  107158. /**
  107159. * Remove a specific color gradient
  107160. * @param gradient defines the gradient to remove
  107161. * @returns the current particle system
  107162. */
  107163. removeColorGradient(gradient: number): GPUParticleSystem;
  107164. private _angularSpeedGradientsTexture;
  107165. private _sizeGradientsTexture;
  107166. private _velocityGradientsTexture;
  107167. private _limitVelocityGradientsTexture;
  107168. private _dragGradientsTexture;
  107169. private _addFactorGradient;
  107170. /**
  107171. * Adds a new size gradient
  107172. * @param gradient defines the gradient to use (between 0 and 1)
  107173. * @param factor defines the size factor to affect to the specified gradient
  107174. * @returns the current particle system
  107175. */
  107176. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  107177. /**
  107178. * Remove a specific size gradient
  107179. * @param gradient defines the gradient to remove
  107180. * @returns the current particle system
  107181. */
  107182. removeSizeGradient(gradient: number): GPUParticleSystem;
  107183. /**
  107184. * Adds a new angular speed gradient
  107185. * @param gradient defines the gradient to use (between 0 and 1)
  107186. * @param factor defines the angular speed to affect to the specified gradient
  107187. * @returns the current particle system
  107188. */
  107189. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  107190. /**
  107191. * Remove a specific angular speed gradient
  107192. * @param gradient defines the gradient to remove
  107193. * @returns the current particle system
  107194. */
  107195. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  107196. /**
  107197. * Adds a new velocity gradient
  107198. * @param gradient defines the gradient to use (between 0 and 1)
  107199. * @param factor defines the velocity to affect to the specified gradient
  107200. * @returns the current particle system
  107201. */
  107202. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  107203. /**
  107204. * Remove a specific velocity gradient
  107205. * @param gradient defines the gradient to remove
  107206. * @returns the current particle system
  107207. */
  107208. removeVelocityGradient(gradient: number): GPUParticleSystem;
  107209. /**
  107210. * Adds a new limit velocity gradient
  107211. * @param gradient defines the gradient to use (between 0 and 1)
  107212. * @param factor defines the limit velocity value to affect to the specified gradient
  107213. * @returns the current particle system
  107214. */
  107215. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  107216. /**
  107217. * Remove a specific limit velocity gradient
  107218. * @param gradient defines the gradient to remove
  107219. * @returns the current particle system
  107220. */
  107221. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  107222. /**
  107223. * Adds a new drag gradient
  107224. * @param gradient defines the gradient to use (between 0 and 1)
  107225. * @param factor defines the drag value to affect to the specified gradient
  107226. * @returns the current particle system
  107227. */
  107228. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  107229. /**
  107230. * Remove a specific drag gradient
  107231. * @param gradient defines the gradient to remove
  107232. * @returns the current particle system
  107233. */
  107234. removeDragGradient(gradient: number): GPUParticleSystem;
  107235. /**
  107236. * Not supported by GPUParticleSystem
  107237. * @param gradient defines the gradient to use (between 0 and 1)
  107238. * @param factor defines the emit rate value to affect to the specified gradient
  107239. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  107240. * @returns the current particle system
  107241. */
  107242. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  107243. /**
  107244. * Not supported by GPUParticleSystem
  107245. * @param gradient defines the gradient to remove
  107246. * @returns the current particle system
  107247. */
  107248. removeEmitRateGradient(gradient: number): IParticleSystem;
  107249. /**
  107250. * Not supported by GPUParticleSystem
  107251. * @param gradient defines the gradient to use (between 0 and 1)
  107252. * @param factor defines the start size value to affect to the specified gradient
  107253. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  107254. * @returns the current particle system
  107255. */
  107256. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  107257. /**
  107258. * Not supported by GPUParticleSystem
  107259. * @param gradient defines the gradient to remove
  107260. * @returns the current particle system
  107261. */
  107262. removeStartSizeGradient(gradient: number): IParticleSystem;
  107263. /**
  107264. * Not supported by GPUParticleSystem
  107265. * @param gradient defines the gradient to use (between 0 and 1)
  107266. * @param min defines the color remap minimal range
  107267. * @param max defines the color remap maximal range
  107268. * @returns the current particle system
  107269. */
  107270. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  107271. /**
  107272. * Not supported by GPUParticleSystem
  107273. * @param gradient defines the gradient to remove
  107274. * @returns the current particle system
  107275. */
  107276. removeColorRemapGradient(): IParticleSystem;
  107277. /**
  107278. * Not supported by GPUParticleSystem
  107279. * @param gradient defines the gradient to use (between 0 and 1)
  107280. * @param min defines the alpha remap minimal range
  107281. * @param max defines the alpha remap maximal range
  107282. * @returns the current particle system
  107283. */
  107284. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  107285. /**
  107286. * Not supported by GPUParticleSystem
  107287. * @param gradient defines the gradient to remove
  107288. * @returns the current particle system
  107289. */
  107290. removeAlphaRemapGradient(): IParticleSystem;
  107291. /**
  107292. * Not supported by GPUParticleSystem
  107293. * @param gradient defines the gradient to use (between 0 and 1)
  107294. * @param color defines the color to affect to the specified gradient
  107295. * @returns the current particle system
  107296. */
  107297. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  107298. /**
  107299. * Not supported by GPUParticleSystem
  107300. * @param gradient defines the gradient to remove
  107301. * @returns the current particle system
  107302. */
  107303. removeRampGradient(): IParticleSystem;
  107304. /**
  107305. * Not supported by GPUParticleSystem
  107306. * @returns the list of ramp gradients
  107307. */
  107308. getRampGradients(): Nullable<Array<Color3Gradient>>;
  107309. /**
  107310. * Not supported by GPUParticleSystem
  107311. * Gets or sets a boolean indicating that ramp gradients must be used
  107312. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  107313. */
  107314. useRampGradients: boolean;
  107315. /**
  107316. * Not supported by GPUParticleSystem
  107317. * @param gradient defines the gradient to use (between 0 and 1)
  107318. * @param factor defines the life time factor to affect to the specified gradient
  107319. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  107320. * @returns the current particle system
  107321. */
  107322. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  107323. /**
  107324. * Not supported by GPUParticleSystem
  107325. * @param gradient defines the gradient to remove
  107326. * @returns the current particle system
  107327. */
  107328. removeLifeTimeGradient(gradient: number): IParticleSystem;
  107329. /**
  107330. * Instantiates a GPU particle system.
  107331. * 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.
  107332. * @param name The name of the particle system
  107333. * @param options The options used to create the system
  107334. * @param scene The scene the particle system belongs to
  107335. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  107336. */
  107337. constructor(name: string, options: Partial<{
  107338. capacity: number;
  107339. randomTextureSize: number;
  107340. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  107341. protected _reset(): void;
  107342. private _createUpdateVAO;
  107343. private _createRenderVAO;
  107344. private _initialize;
  107345. /** @hidden */
  107346. _recreateUpdateEffect(): void;
  107347. /** @hidden */
  107348. _recreateRenderEffect(): void;
  107349. /**
  107350. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  107351. * @param preWarm defines if we are in the pre-warmimg phase
  107352. */
  107353. animate(preWarm?: boolean): void;
  107354. private _createFactorGradientTexture;
  107355. private _createSizeGradientTexture;
  107356. private _createAngularSpeedGradientTexture;
  107357. private _createVelocityGradientTexture;
  107358. private _createLimitVelocityGradientTexture;
  107359. private _createDragGradientTexture;
  107360. private _createColorGradientTexture;
  107361. /**
  107362. * Renders the particle system in its current state
  107363. * @param preWarm defines if the system should only update the particles but not render them
  107364. * @returns the current number of particles
  107365. */
  107366. render(preWarm?: boolean): number;
  107367. /**
  107368. * Rebuilds the particle system
  107369. */
  107370. rebuild(): void;
  107371. private _releaseBuffers;
  107372. private _releaseVAOs;
  107373. /**
  107374. * Disposes the particle system and free the associated resources
  107375. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  107376. */
  107377. dispose(disposeTexture?: boolean): void;
  107378. /**
  107379. * Clones the particle system.
  107380. * @param name The name of the cloned object
  107381. * @param newEmitter The new emitter to use
  107382. * @returns the cloned particle system
  107383. */
  107384. clone(name: string, newEmitter: any): GPUParticleSystem;
  107385. /**
  107386. * Serializes the particle system to a JSON object.
  107387. * @returns the JSON object
  107388. */
  107389. serialize(): any;
  107390. /**
  107391. * Parses a JSON object to create a GPU particle system.
  107392. * @param parsedParticleSystem The JSON object to parse
  107393. * @param scene The scene to create the particle system in
  107394. * @param rootUrl The root url to use to load external dependencies like texture
  107395. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  107396. * @returns the parsed GPU particle system
  107397. */
  107398. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  107399. }
  107400. }
  107401. declare module BABYLON {
  107402. /**
  107403. * Represents a set of particle systems working together to create a specific effect
  107404. */
  107405. export class ParticleSystemSet implements IDisposable {
  107406. private _emitterCreationOptions;
  107407. private _emitterNode;
  107408. /**
  107409. * Gets the particle system list
  107410. */
  107411. systems: IParticleSystem[];
  107412. /**
  107413. * Gets the emitter node used with this set
  107414. */
  107415. readonly emitterNode: Nullable<TransformNode>;
  107416. /**
  107417. * Creates a new emitter mesh as a sphere
  107418. * @param options defines the options used to create the sphere
  107419. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  107420. * @param scene defines the hosting scene
  107421. */
  107422. setEmitterAsSphere(options: {
  107423. diameter: number;
  107424. segments: number;
  107425. color: Color3;
  107426. }, renderingGroupId: number, scene: Scene): void;
  107427. /**
  107428. * Starts all particle systems of the set
  107429. * @param emitter defines an optional mesh to use as emitter for the particle systems
  107430. */
  107431. start(emitter?: AbstractMesh): void;
  107432. /**
  107433. * Release all associated resources
  107434. */
  107435. dispose(): void;
  107436. /**
  107437. * Serialize the set into a JSON compatible object
  107438. * @returns a JSON compatible representation of the set
  107439. */
  107440. serialize(): any;
  107441. /**
  107442. * Parse a new ParticleSystemSet from a serialized source
  107443. * @param data defines a JSON compatible representation of the set
  107444. * @param scene defines the hosting scene
  107445. * @param gpu defines if we want GPU particles or CPU particles
  107446. * @returns a new ParticleSystemSet
  107447. */
  107448. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  107449. }
  107450. }
  107451. declare module BABYLON {
  107452. /**
  107453. * This class is made for on one-liner static method to help creating particle system set.
  107454. */
  107455. export class ParticleHelper {
  107456. /**
  107457. * Gets or sets base Assets URL
  107458. */
  107459. static BaseAssetsUrl: string;
  107460. /**
  107461. * Create a default particle system that you can tweak
  107462. * @param emitter defines the emitter to use
  107463. * @param capacity defines the system capacity (default is 500 particles)
  107464. * @param scene defines the hosting scene
  107465. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  107466. * @returns the new Particle system
  107467. */
  107468. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  107469. /**
  107470. * This is the main static method (one-liner) of this helper to create different particle systems
  107471. * @param type This string represents the type to the particle system to create
  107472. * @param scene The scene where the particle system should live
  107473. * @param gpu If the system will use gpu
  107474. * @returns the ParticleSystemSet created
  107475. */
  107476. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  107477. /**
  107478. * Static function used to export a particle system to a ParticleSystemSet variable.
  107479. * Please note that the emitter shape is not exported
  107480. * @param systems defines the particle systems to export
  107481. * @returns the created particle system set
  107482. */
  107483. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  107484. }
  107485. }
  107486. declare module BABYLON {
  107487. interface Engine {
  107488. /**
  107489. * Create an effect to use with particle systems.
  107490. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  107491. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  107492. * @param uniformsNames defines a list of attribute names
  107493. * @param samplers defines an array of string used to represent textures
  107494. * @param defines defines the string containing the defines to use to compile the shaders
  107495. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  107496. * @param onCompiled defines a function to call when the effect creation is successful
  107497. * @param onError defines a function to call when the effect creation has failed
  107498. * @returns the new Effect
  107499. */
  107500. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  107501. }
  107502. interface Mesh {
  107503. /**
  107504. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  107505. * @returns an array of IParticleSystem
  107506. */
  107507. getEmittedParticleSystems(): IParticleSystem[];
  107508. /**
  107509. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  107510. * @returns an array of IParticleSystem
  107511. */
  107512. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  107513. }
  107514. /**
  107515. * @hidden
  107516. */
  107517. export var _IDoNeedToBeInTheBuild: number;
  107518. }
  107519. declare module BABYLON {
  107520. interface Scene {
  107521. /** @hidden (Backing field) */
  107522. _physicsEngine: Nullable<IPhysicsEngine>;
  107523. /**
  107524. * Gets the current physics engine
  107525. * @returns a IPhysicsEngine or null if none attached
  107526. */
  107527. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  107528. /**
  107529. * Enables physics to the current scene
  107530. * @param gravity defines the scene's gravity for the physics engine
  107531. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  107532. * @return a boolean indicating if the physics engine was initialized
  107533. */
  107534. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  107535. /**
  107536. * Disables and disposes the physics engine associated with the scene
  107537. */
  107538. disablePhysicsEngine(): void;
  107539. /**
  107540. * Gets a boolean indicating if there is an active physics engine
  107541. * @returns a boolean indicating if there is an active physics engine
  107542. */
  107543. isPhysicsEnabled(): boolean;
  107544. /**
  107545. * Deletes a physics compound impostor
  107546. * @param compound defines the compound to delete
  107547. */
  107548. deleteCompoundImpostor(compound: any): void;
  107549. /**
  107550. * An event triggered when physic simulation is about to be run
  107551. */
  107552. onBeforePhysicsObservable: Observable<Scene>;
  107553. /**
  107554. * An event triggered when physic simulation has been done
  107555. */
  107556. onAfterPhysicsObservable: Observable<Scene>;
  107557. }
  107558. interface AbstractMesh {
  107559. /** @hidden */
  107560. _physicsImpostor: Nullable<PhysicsImpostor>;
  107561. /**
  107562. * Gets or sets impostor used for physic simulation
  107563. * @see http://doc.babylonjs.com/features/physics_engine
  107564. */
  107565. physicsImpostor: Nullable<PhysicsImpostor>;
  107566. /**
  107567. * Gets the current physics impostor
  107568. * @see http://doc.babylonjs.com/features/physics_engine
  107569. * @returns a physics impostor or null
  107570. */
  107571. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  107572. /** Apply a physic impulse to the mesh
  107573. * @param force defines the force to apply
  107574. * @param contactPoint defines where to apply the force
  107575. * @returns the current mesh
  107576. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  107577. */
  107578. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  107579. /**
  107580. * Creates a physic joint between two meshes
  107581. * @param otherMesh defines the other mesh to use
  107582. * @param pivot1 defines the pivot to use on this mesh
  107583. * @param pivot2 defines the pivot to use on the other mesh
  107584. * @param options defines additional options (can be plugin dependent)
  107585. * @returns the current mesh
  107586. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  107587. */
  107588. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  107589. /** @hidden */
  107590. _disposePhysicsObserver: Nullable<Observer<Node>>;
  107591. }
  107592. /**
  107593. * Defines the physics engine scene component responsible to manage a physics engine
  107594. */
  107595. export class PhysicsEngineSceneComponent implements ISceneComponent {
  107596. /**
  107597. * The component name helpful to identify the component in the list of scene components.
  107598. */
  107599. readonly name: string;
  107600. /**
  107601. * The scene the component belongs to.
  107602. */
  107603. scene: Scene;
  107604. /**
  107605. * Creates a new instance of the component for the given scene
  107606. * @param scene Defines the scene to register the component in
  107607. */
  107608. constructor(scene: Scene);
  107609. /**
  107610. * Registers the component in a given scene
  107611. */
  107612. register(): void;
  107613. /**
  107614. * Rebuilds the elements related to this component in case of
  107615. * context lost for instance.
  107616. */
  107617. rebuild(): void;
  107618. /**
  107619. * Disposes the component and the associated ressources
  107620. */
  107621. dispose(): void;
  107622. }
  107623. }
  107624. declare module BABYLON {
  107625. /**
  107626. * A helper for physics simulations
  107627. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107628. */
  107629. export class PhysicsHelper {
  107630. private _scene;
  107631. private _physicsEngine;
  107632. /**
  107633. * Initializes the Physics helper
  107634. * @param scene Babylon.js scene
  107635. */
  107636. constructor(scene: Scene);
  107637. /**
  107638. * Applies a radial explosion impulse
  107639. * @param origin the origin of the explosion
  107640. * @param radius the explosion radius
  107641. * @param strength the explosion strength
  107642. * @param falloff possible options: Constant & Linear. Defaults to Constant
  107643. * @returns A physics radial explosion event, or null
  107644. */
  107645. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  107646. /**
  107647. * Applies a radial explosion force
  107648. * @param origin the origin of the explosion
  107649. * @param radius the explosion radius
  107650. * @param strength the explosion strength
  107651. * @param falloff possible options: Constant & Linear. Defaults to Constant
  107652. * @returns A physics radial explosion event, or null
  107653. */
  107654. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  107655. /**
  107656. * Creates a gravitational field
  107657. * @param origin the origin of the explosion
  107658. * @param radius the explosion radius
  107659. * @param strength the explosion strength
  107660. * @param falloff possible options: Constant & Linear. Defaults to Constant
  107661. * @returns A physics gravitational field event, or null
  107662. */
  107663. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  107664. /**
  107665. * Creates a physics updraft event
  107666. * @param origin the origin of the updraft
  107667. * @param radius the radius of the updraft
  107668. * @param strength the strength of the updraft
  107669. * @param height the height of the updraft
  107670. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  107671. * @returns A physics updraft event, or null
  107672. */
  107673. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  107674. /**
  107675. * Creates a physics vortex event
  107676. * @param origin the of the vortex
  107677. * @param radius the radius of the vortex
  107678. * @param strength the strength of the vortex
  107679. * @param height the height of the vortex
  107680. * @returns a Physics vortex event, or null
  107681. * A physics vortex event or null
  107682. */
  107683. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  107684. }
  107685. /**
  107686. * Represents a physics radial explosion event
  107687. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107688. */
  107689. export class PhysicsRadialExplosionEvent {
  107690. private _scene;
  107691. private _sphere;
  107692. private _sphereOptions;
  107693. private _rays;
  107694. private _dataFetched;
  107695. /**
  107696. * Initializes a radial explosioin event
  107697. * @param scene BabylonJS scene
  107698. */
  107699. constructor(scene: Scene);
  107700. /**
  107701. * Returns the data related to the radial explosion event (sphere & rays).
  107702. * @returns The radial explosion event data
  107703. */
  107704. getData(): PhysicsRadialExplosionEventData;
  107705. /**
  107706. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  107707. * @param impostor A physics imposter
  107708. * @param origin the origin of the explosion
  107709. * @param radius the explosion radius
  107710. * @param strength the explosion strength
  107711. * @param falloff possible options: Constant & Linear
  107712. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  107713. */
  107714. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  107715. /**
  107716. * Disposes the sphere.
  107717. * @param force Specifies if the sphere should be disposed by force
  107718. */
  107719. dispose(force?: boolean): void;
  107720. /*** Helpers ***/
  107721. private _prepareSphere;
  107722. private _intersectsWithSphere;
  107723. }
  107724. /**
  107725. * Represents a gravitational field event
  107726. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107727. */
  107728. export class PhysicsGravitationalFieldEvent {
  107729. private _physicsHelper;
  107730. private _scene;
  107731. private _origin;
  107732. private _radius;
  107733. private _strength;
  107734. private _falloff;
  107735. private _tickCallback;
  107736. private _sphere;
  107737. private _dataFetched;
  107738. /**
  107739. * Initializes the physics gravitational field event
  107740. * @param physicsHelper A physics helper
  107741. * @param scene BabylonJS scene
  107742. * @param origin The origin position of the gravitational field event
  107743. * @param radius The radius of the gravitational field event
  107744. * @param strength The strength of the gravitational field event
  107745. * @param falloff The falloff for the gravitational field event
  107746. */
  107747. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  107748. /**
  107749. * Returns the data related to the gravitational field event (sphere).
  107750. * @returns A gravitational field event
  107751. */
  107752. getData(): PhysicsGravitationalFieldEventData;
  107753. /**
  107754. * Enables the gravitational field.
  107755. */
  107756. enable(): void;
  107757. /**
  107758. * Disables the gravitational field.
  107759. */
  107760. disable(): void;
  107761. /**
  107762. * Disposes the sphere.
  107763. * @param force The force to dispose from the gravitational field event
  107764. */
  107765. dispose(force?: boolean): void;
  107766. private _tick;
  107767. }
  107768. /**
  107769. * Represents a physics updraft event
  107770. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107771. */
  107772. export class PhysicsUpdraftEvent {
  107773. private _scene;
  107774. private _origin;
  107775. private _radius;
  107776. private _strength;
  107777. private _height;
  107778. private _updraftMode;
  107779. private _physicsEngine;
  107780. private _originTop;
  107781. private _originDirection;
  107782. private _tickCallback;
  107783. private _cylinder;
  107784. private _cylinderPosition;
  107785. private _dataFetched;
  107786. /**
  107787. * Initializes the physics updraft event
  107788. * @param _scene BabylonJS scene
  107789. * @param _origin The origin position of the updraft
  107790. * @param _radius The radius of the updraft
  107791. * @param _strength The strength of the updraft
  107792. * @param _height The height of the updraft
  107793. * @param _updraftMode The mode of the updraft
  107794. */
  107795. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  107796. /**
  107797. * Returns the data related to the updraft event (cylinder).
  107798. * @returns A physics updraft event
  107799. */
  107800. getData(): PhysicsUpdraftEventData;
  107801. /**
  107802. * Enables the updraft.
  107803. */
  107804. enable(): void;
  107805. /**
  107806. * Disables the cortex.
  107807. */
  107808. disable(): void;
  107809. /**
  107810. * Disposes the sphere.
  107811. * @param force Specifies if the updraft should be disposed by force
  107812. */
  107813. dispose(force?: boolean): void;
  107814. private getImpostorForceAndContactPoint;
  107815. private _tick;
  107816. /*** Helpers ***/
  107817. private _prepareCylinder;
  107818. private _intersectsWithCylinder;
  107819. }
  107820. /**
  107821. * Represents a physics vortex event
  107822. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107823. */
  107824. export class PhysicsVortexEvent {
  107825. private _scene;
  107826. private _origin;
  107827. private _radius;
  107828. private _strength;
  107829. private _height;
  107830. private _physicsEngine;
  107831. private _originTop;
  107832. private _centripetalForceThreshold;
  107833. private _updraftMultiplier;
  107834. private _tickCallback;
  107835. private _cylinder;
  107836. private _cylinderPosition;
  107837. private _dataFetched;
  107838. /**
  107839. * Initializes the physics vortex event
  107840. * @param _scene The BabylonJS scene
  107841. * @param _origin The origin position of the vortex
  107842. * @param _radius The radius of the vortex
  107843. * @param _strength The strength of the vortex
  107844. * @param _height The height of the vortex
  107845. */
  107846. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  107847. /**
  107848. * Returns the data related to the vortex event (cylinder).
  107849. * @returns The physics vortex event data
  107850. */
  107851. getData(): PhysicsVortexEventData;
  107852. /**
  107853. * Enables the vortex.
  107854. */
  107855. enable(): void;
  107856. /**
  107857. * Disables the cortex.
  107858. */
  107859. disable(): void;
  107860. /**
  107861. * Disposes the sphere.
  107862. * @param force
  107863. */
  107864. dispose(force?: boolean): void;
  107865. private getImpostorForceAndContactPoint;
  107866. private _tick;
  107867. /*** Helpers ***/
  107868. private _prepareCylinder;
  107869. private _intersectsWithCylinder;
  107870. }
  107871. /**
  107872. * The strenght of the force in correspondence to the distance of the affected object
  107873. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107874. */
  107875. export enum PhysicsRadialImpulseFalloff {
  107876. /** Defines that impulse is constant in strength across it's whole radius */
  107877. Constant = 0,
  107878. /** DEfines that impulse gets weaker if it's further from the origin */
  107879. Linear = 1
  107880. }
  107881. /**
  107882. * The strength of the force in correspondence to the distance of the affected object
  107883. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107884. */
  107885. export enum PhysicsUpdraftMode {
  107886. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  107887. Center = 0,
  107888. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  107889. Perpendicular = 1
  107890. }
  107891. /**
  107892. * Interface for a physics force and contact point
  107893. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107894. */
  107895. export interface PhysicsForceAndContactPoint {
  107896. /**
  107897. * The force applied at the contact point
  107898. */
  107899. force: Vector3;
  107900. /**
  107901. * The contact point
  107902. */
  107903. contactPoint: Vector3;
  107904. }
  107905. /**
  107906. * Interface for radial explosion event data
  107907. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107908. */
  107909. export interface PhysicsRadialExplosionEventData {
  107910. /**
  107911. * A sphere used for the radial explosion event
  107912. */
  107913. sphere: Mesh;
  107914. /**
  107915. * An array of rays for the radial explosion event
  107916. */
  107917. rays: Array<Ray>;
  107918. }
  107919. /**
  107920. * Interface for gravitational field event data
  107921. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107922. */
  107923. export interface PhysicsGravitationalFieldEventData {
  107924. /**
  107925. * A sphere mesh used for the gravitational field event
  107926. */
  107927. sphere: Mesh;
  107928. }
  107929. /**
  107930. * Interface for updraft event data
  107931. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107932. */
  107933. export interface PhysicsUpdraftEventData {
  107934. /**
  107935. * A cylinder used for the updraft event
  107936. */
  107937. cylinder: Mesh;
  107938. }
  107939. /**
  107940. * Interface for vortex event data
  107941. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107942. */
  107943. export interface PhysicsVortexEventData {
  107944. /**
  107945. * A cylinder used for the vortex event
  107946. */
  107947. cylinder: Mesh;
  107948. }
  107949. }
  107950. declare module BABYLON {
  107951. /**
  107952. * AmmoJS Physics plugin
  107953. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107954. * @see https://github.com/kripken/ammo.js/
  107955. */
  107956. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  107957. private _useDeltaForWorldStep;
  107958. /**
  107959. * Reference to the Ammo library
  107960. */
  107961. bjsAMMO: any;
  107962. /**
  107963. * Created ammoJS world which physics bodies are added to
  107964. */
  107965. world: any;
  107966. /**
  107967. * Name of the plugin
  107968. */
  107969. name: string;
  107970. private _timeStep;
  107971. private _fixedTimeStep;
  107972. private _maxSteps;
  107973. private _tmpQuaternion;
  107974. private _tmpAmmoTransform;
  107975. private _tmpAmmoQuaternion;
  107976. private _tmpAmmoConcreteContactResultCallback;
  107977. private _collisionConfiguration;
  107978. private _dispatcher;
  107979. private _overlappingPairCache;
  107980. private _solver;
  107981. private _tmpAmmoVectorA;
  107982. private _tmpAmmoVectorB;
  107983. private _tmpAmmoVectorC;
  107984. private _tmpContactCallbackResult;
  107985. private static readonly DISABLE_COLLISION_FLAG;
  107986. private static readonly KINEMATIC_FLAG;
  107987. private static readonly DISABLE_DEACTIVATION_FLAG;
  107988. /**
  107989. * Initializes the ammoJS plugin
  107990. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  107991. * @param ammoInjection can be used to inject your own ammo reference
  107992. */
  107993. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  107994. /**
  107995. * Sets the gravity of the physics world (m/(s^2))
  107996. * @param gravity Gravity to set
  107997. */
  107998. setGravity(gravity: Vector3): void;
  107999. /**
  108000. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  108001. * @param timeStep timestep to use in seconds
  108002. */
  108003. setTimeStep(timeStep: number): void;
  108004. /**
  108005. * 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)
  108006. * @param fixedTimeStep fixedTimeStep to use in seconds
  108007. */
  108008. setFixedTimeStep(fixedTimeStep: number): void;
  108009. /**
  108010. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  108011. * @param maxSteps the maximum number of steps by the physics engine per frame
  108012. */
  108013. setMaxSteps(maxSteps: number): void;
  108014. /**
  108015. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  108016. * @returns the current timestep in seconds
  108017. */
  108018. getTimeStep(): number;
  108019. private _isImpostorInContact;
  108020. private _isImpostorPairInContact;
  108021. private _stepSimulation;
  108022. /**
  108023. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  108024. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  108025. * After the step the babylon meshes are set to the position of the physics imposters
  108026. * @param delta amount of time to step forward
  108027. * @param impostors array of imposters to update before/after the step
  108028. */
  108029. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  108030. private _tmpVector;
  108031. private _tmpMatrix;
  108032. /**
  108033. * Applies an implulse on the imposter
  108034. * @param impostor imposter to apply impulse
  108035. * @param force amount of force to be applied to the imposter
  108036. * @param contactPoint the location to apply the impulse on the imposter
  108037. */
  108038. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108039. /**
  108040. * Applies a force on the imposter
  108041. * @param impostor imposter to apply force
  108042. * @param force amount of force to be applied to the imposter
  108043. * @param contactPoint the location to apply the force on the imposter
  108044. */
  108045. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108046. /**
  108047. * Creates a physics body using the plugin
  108048. * @param impostor the imposter to create the physics body on
  108049. */
  108050. generatePhysicsBody(impostor: PhysicsImpostor): void;
  108051. /**
  108052. * Removes the physics body from the imposter and disposes of the body's memory
  108053. * @param impostor imposter to remove the physics body from
  108054. */
  108055. removePhysicsBody(impostor: PhysicsImpostor): void;
  108056. /**
  108057. * Generates a joint
  108058. * @param impostorJoint the imposter joint to create the joint with
  108059. */
  108060. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  108061. /**
  108062. * Removes a joint
  108063. * @param impostorJoint the imposter joint to remove the joint from
  108064. */
  108065. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  108066. private _addMeshVerts;
  108067. private _createShape;
  108068. /**
  108069. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  108070. * @param impostor imposter containing the physics body and babylon object
  108071. */
  108072. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  108073. /**
  108074. * Sets the babylon object's position/rotation from the physics body's position/rotation
  108075. * @param impostor imposter containing the physics body and babylon object
  108076. * @param newPosition new position
  108077. * @param newRotation new rotation
  108078. */
  108079. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  108080. /**
  108081. * If this plugin is supported
  108082. * @returns true if its supported
  108083. */
  108084. isSupported(): boolean;
  108085. /**
  108086. * Sets the linear velocity of the physics body
  108087. * @param impostor imposter to set the velocity on
  108088. * @param velocity velocity to set
  108089. */
  108090. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108091. /**
  108092. * Sets the angular velocity of the physics body
  108093. * @param impostor imposter to set the velocity on
  108094. * @param velocity velocity to set
  108095. */
  108096. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108097. /**
  108098. * gets the linear velocity
  108099. * @param impostor imposter to get linear velocity from
  108100. * @returns linear velocity
  108101. */
  108102. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108103. /**
  108104. * gets the angular velocity
  108105. * @param impostor imposter to get angular velocity from
  108106. * @returns angular velocity
  108107. */
  108108. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108109. /**
  108110. * Sets the mass of physics body
  108111. * @param impostor imposter to set the mass on
  108112. * @param mass mass to set
  108113. */
  108114. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  108115. /**
  108116. * Gets the mass of the physics body
  108117. * @param impostor imposter to get the mass from
  108118. * @returns mass
  108119. */
  108120. getBodyMass(impostor: PhysicsImpostor): number;
  108121. /**
  108122. * Gets friction of the impostor
  108123. * @param impostor impostor to get friction from
  108124. * @returns friction value
  108125. */
  108126. getBodyFriction(impostor: PhysicsImpostor): number;
  108127. /**
  108128. * Sets friction of the impostor
  108129. * @param impostor impostor to set friction on
  108130. * @param friction friction value
  108131. */
  108132. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  108133. /**
  108134. * Gets restitution of the impostor
  108135. * @param impostor impostor to get restitution from
  108136. * @returns restitution value
  108137. */
  108138. getBodyRestitution(impostor: PhysicsImpostor): number;
  108139. /**
  108140. * Sets resitution of the impostor
  108141. * @param impostor impostor to set resitution on
  108142. * @param restitution resitution value
  108143. */
  108144. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  108145. /**
  108146. * Sleeps the physics body and stops it from being active
  108147. * @param impostor impostor to sleep
  108148. */
  108149. sleepBody(impostor: PhysicsImpostor): void;
  108150. /**
  108151. * Activates the physics body
  108152. * @param impostor impostor to activate
  108153. */
  108154. wakeUpBody(impostor: PhysicsImpostor): void;
  108155. /**
  108156. * Updates the distance parameters of the joint
  108157. * @param joint joint to update
  108158. * @param maxDistance maximum distance of the joint
  108159. * @param minDistance minimum distance of the joint
  108160. */
  108161. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  108162. /**
  108163. * Sets a motor on the joint
  108164. * @param joint joint to set motor on
  108165. * @param speed speed of the motor
  108166. * @param maxForce maximum force of the motor
  108167. * @param motorIndex index of the motor
  108168. */
  108169. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  108170. /**
  108171. * Sets the motors limit
  108172. * @param joint joint to set limit on
  108173. * @param upperLimit upper limit
  108174. * @param lowerLimit lower limit
  108175. */
  108176. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  108177. /**
  108178. * Syncs the position and rotation of a mesh with the impostor
  108179. * @param mesh mesh to sync
  108180. * @param impostor impostor to update the mesh with
  108181. */
  108182. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  108183. /**
  108184. * Gets the radius of the impostor
  108185. * @param impostor impostor to get radius from
  108186. * @returns the radius
  108187. */
  108188. getRadius(impostor: PhysicsImpostor): number;
  108189. /**
  108190. * Gets the box size of the impostor
  108191. * @param impostor impostor to get box size from
  108192. * @param result the resulting box size
  108193. */
  108194. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  108195. /**
  108196. * Disposes of the impostor
  108197. */
  108198. dispose(): void;
  108199. }
  108200. }
  108201. declare module BABYLON {
  108202. /** @hidden */
  108203. export var blackAndWhitePixelShader: {
  108204. name: string;
  108205. shader: string;
  108206. };
  108207. }
  108208. declare module BABYLON {
  108209. /**
  108210. * Post process used to render in black and white
  108211. */
  108212. export class BlackAndWhitePostProcess extends PostProcess {
  108213. /**
  108214. * Linear about to convert he result to black and white (default: 1)
  108215. */
  108216. degree: number;
  108217. /**
  108218. * Creates a black and white post process
  108219. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  108220. * @param name The name of the effect.
  108221. * @param options The required width/height ratio to downsize to before computing the render pass.
  108222. * @param camera The camera to apply the render pass to.
  108223. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108224. * @param engine The engine which the post process will be applied. (default: current engine)
  108225. * @param reusable If the post process can be reused on the same frame. (default: false)
  108226. */
  108227. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108228. }
  108229. }
  108230. declare module BABYLON {
  108231. /**
  108232. * This represents a set of one or more post processes in Babylon.
  108233. * A post process can be used to apply a shader to a texture after it is rendered.
  108234. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  108235. */
  108236. export class PostProcessRenderEffect {
  108237. private _postProcesses;
  108238. private _getPostProcesses;
  108239. private _singleInstance;
  108240. private _cameras;
  108241. private _indicesForCamera;
  108242. /**
  108243. * Name of the effect
  108244. * @hidden
  108245. */
  108246. _name: string;
  108247. /**
  108248. * Instantiates a post process render effect.
  108249. * A post process can be used to apply a shader to a texture after it is rendered.
  108250. * @param engine The engine the effect is tied to
  108251. * @param name The name of the effect
  108252. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  108253. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  108254. */
  108255. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  108256. /**
  108257. * Checks if all the post processes in the effect are supported.
  108258. */
  108259. readonly isSupported: boolean;
  108260. /**
  108261. * Updates the current state of the effect
  108262. * @hidden
  108263. */
  108264. _update(): void;
  108265. /**
  108266. * Attaches the effect on cameras
  108267. * @param cameras The camera to attach to.
  108268. * @hidden
  108269. */
  108270. _attachCameras(cameras: Camera): void;
  108271. /**
  108272. * Attaches the effect on cameras
  108273. * @param cameras The camera to attach to.
  108274. * @hidden
  108275. */
  108276. _attachCameras(cameras: Camera[]): void;
  108277. /**
  108278. * Detatches the effect on cameras
  108279. * @param cameras The camera to detatch from.
  108280. * @hidden
  108281. */
  108282. _detachCameras(cameras: Camera): void;
  108283. /**
  108284. * Detatches the effect on cameras
  108285. * @param cameras The camera to detatch from.
  108286. * @hidden
  108287. */
  108288. _detachCameras(cameras: Camera[]): void;
  108289. /**
  108290. * Enables the effect on given cameras
  108291. * @param cameras The camera to enable.
  108292. * @hidden
  108293. */
  108294. _enable(cameras: Camera): void;
  108295. /**
  108296. * Enables the effect on given cameras
  108297. * @param cameras The camera to enable.
  108298. * @hidden
  108299. */
  108300. _enable(cameras: Nullable<Camera[]>): void;
  108301. /**
  108302. * Disables the effect on the given cameras
  108303. * @param cameras The camera to disable.
  108304. * @hidden
  108305. */
  108306. _disable(cameras: Camera): void;
  108307. /**
  108308. * Disables the effect on the given cameras
  108309. * @param cameras The camera to disable.
  108310. * @hidden
  108311. */
  108312. _disable(cameras: Nullable<Camera[]>): void;
  108313. /**
  108314. * Gets a list of the post processes contained in the effect.
  108315. * @param camera The camera to get the post processes on.
  108316. * @returns The list of the post processes in the effect.
  108317. */
  108318. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  108319. }
  108320. }
  108321. declare module BABYLON {
  108322. /** @hidden */
  108323. export var extractHighlightsPixelShader: {
  108324. name: string;
  108325. shader: string;
  108326. };
  108327. }
  108328. declare module BABYLON {
  108329. /**
  108330. * 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.
  108331. */
  108332. export class ExtractHighlightsPostProcess extends PostProcess {
  108333. /**
  108334. * The luminance threshold, pixels below this value will be set to black.
  108335. */
  108336. threshold: number;
  108337. /** @hidden */
  108338. _exposure: number;
  108339. /**
  108340. * Post process which has the input texture to be used when performing highlight extraction
  108341. * @hidden
  108342. */
  108343. _inputPostProcess: Nullable<PostProcess>;
  108344. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108345. }
  108346. }
  108347. declare module BABYLON {
  108348. /** @hidden */
  108349. export var bloomMergePixelShader: {
  108350. name: string;
  108351. shader: string;
  108352. };
  108353. }
  108354. declare module BABYLON {
  108355. /**
  108356. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  108357. */
  108358. export class BloomMergePostProcess extends PostProcess {
  108359. /** Weight of the bloom to be added to the original input. */
  108360. weight: number;
  108361. /**
  108362. * Creates a new instance of @see BloomMergePostProcess
  108363. * @param name The name of the effect.
  108364. * @param originalFromInput Post process which's input will be used for the merge.
  108365. * @param blurred Blurred highlights post process which's output will be used.
  108366. * @param weight Weight of the bloom to be added to the original input.
  108367. * @param options The required width/height ratio to downsize to before computing the render pass.
  108368. * @param camera The camera to apply the render pass to.
  108369. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108370. * @param engine The engine which the post process will be applied. (default: current engine)
  108371. * @param reusable If the post process can be reused on the same frame. (default: false)
  108372. * @param textureType Type of textures used when performing the post process. (default: 0)
  108373. * @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)
  108374. */
  108375. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  108376. /** Weight of the bloom to be added to the original input. */
  108377. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108378. }
  108379. }
  108380. declare module BABYLON {
  108381. /**
  108382. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  108383. */
  108384. export class BloomEffect extends PostProcessRenderEffect {
  108385. private bloomScale;
  108386. /**
  108387. * @hidden Internal
  108388. */
  108389. _effects: Array<PostProcess>;
  108390. /**
  108391. * @hidden Internal
  108392. */
  108393. _downscale: ExtractHighlightsPostProcess;
  108394. private _blurX;
  108395. private _blurY;
  108396. private _merge;
  108397. /**
  108398. * The luminance threshold to find bright areas of the image to bloom.
  108399. */
  108400. threshold: number;
  108401. /**
  108402. * The strength of the bloom.
  108403. */
  108404. weight: number;
  108405. /**
  108406. * Specifies the size of the bloom blur kernel, relative to the final output size
  108407. */
  108408. kernel: number;
  108409. /**
  108410. * Creates a new instance of @see BloomEffect
  108411. * @param scene The scene the effect belongs to.
  108412. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  108413. * @param bloomKernel The size of the kernel to be used when applying the blur.
  108414. * @param bloomWeight The the strength of bloom.
  108415. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  108416. * @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)
  108417. */
  108418. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  108419. /**
  108420. * Disposes each of the internal effects for a given camera.
  108421. * @param camera The camera to dispose the effect on.
  108422. */
  108423. disposeEffects(camera: Camera): void;
  108424. /**
  108425. * @hidden Internal
  108426. */
  108427. _updateEffects(): void;
  108428. /**
  108429. * Internal
  108430. * @returns if all the contained post processes are ready.
  108431. * @hidden
  108432. */
  108433. _isReady(): boolean;
  108434. }
  108435. }
  108436. declare module BABYLON {
  108437. /** @hidden */
  108438. export var chromaticAberrationPixelShader: {
  108439. name: string;
  108440. shader: string;
  108441. };
  108442. }
  108443. declare module BABYLON {
  108444. /**
  108445. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  108446. */
  108447. export class ChromaticAberrationPostProcess extends PostProcess {
  108448. /**
  108449. * The amount of seperation of rgb channels (default: 30)
  108450. */
  108451. aberrationAmount: number;
  108452. /**
  108453. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  108454. */
  108455. radialIntensity: number;
  108456. /**
  108457. * 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))
  108458. */
  108459. direction: Vector2;
  108460. /**
  108461. * 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))
  108462. */
  108463. centerPosition: Vector2;
  108464. /**
  108465. * Creates a new instance ChromaticAberrationPostProcess
  108466. * @param name The name of the effect.
  108467. * @param screenWidth The width of the screen to apply the effect on.
  108468. * @param screenHeight The height of the screen to apply the effect on.
  108469. * @param options The required width/height ratio to downsize to before computing the render pass.
  108470. * @param camera The camera to apply the render pass to.
  108471. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108472. * @param engine The engine which the post process will be applied. (default: current engine)
  108473. * @param reusable If the post process can be reused on the same frame. (default: false)
  108474. * @param textureType Type of textures used when performing the post process. (default: 0)
  108475. * @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)
  108476. */
  108477. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108478. }
  108479. }
  108480. declare module BABYLON {
  108481. /** @hidden */
  108482. export var circleOfConfusionPixelShader: {
  108483. name: string;
  108484. shader: string;
  108485. };
  108486. }
  108487. declare module BABYLON {
  108488. /**
  108489. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  108490. */
  108491. export class CircleOfConfusionPostProcess extends PostProcess {
  108492. /**
  108493. * 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.
  108494. */
  108495. lensSize: number;
  108496. /**
  108497. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  108498. */
  108499. fStop: number;
  108500. /**
  108501. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  108502. */
  108503. focusDistance: number;
  108504. /**
  108505. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  108506. */
  108507. focalLength: number;
  108508. private _depthTexture;
  108509. /**
  108510. * Creates a new instance CircleOfConfusionPostProcess
  108511. * @param name The name of the effect.
  108512. * @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.
  108513. * @param options The required width/height ratio to downsize to before computing the render pass.
  108514. * @param camera The camera to apply the render pass to.
  108515. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108516. * @param engine The engine which the post process will be applied. (default: current engine)
  108517. * @param reusable If the post process can be reused on the same frame. (default: false)
  108518. * @param textureType Type of textures used when performing the post process. (default: 0)
  108519. * @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)
  108520. */
  108521. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108522. /**
  108523. * 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.
  108524. */
  108525. depthTexture: RenderTargetTexture;
  108526. }
  108527. }
  108528. declare module BABYLON {
  108529. /** @hidden */
  108530. export var colorCorrectionPixelShader: {
  108531. name: string;
  108532. shader: string;
  108533. };
  108534. }
  108535. declare module BABYLON {
  108536. /**
  108537. *
  108538. * This post-process allows the modification of rendered colors by using
  108539. * a 'look-up table' (LUT). This effect is also called Color Grading.
  108540. *
  108541. * The object needs to be provided an url to a texture containing the color
  108542. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  108543. * Use an image editing software to tweak the LUT to match your needs.
  108544. *
  108545. * For an example of a color LUT, see here:
  108546. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  108547. * For explanations on color grading, see here:
  108548. * @see http://udn.epicgames.com/Three/ColorGrading.html
  108549. *
  108550. */
  108551. export class ColorCorrectionPostProcess extends PostProcess {
  108552. private _colorTableTexture;
  108553. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108554. }
  108555. }
  108556. declare module BABYLON {
  108557. /** @hidden */
  108558. export var convolutionPixelShader: {
  108559. name: string;
  108560. shader: string;
  108561. };
  108562. }
  108563. declare module BABYLON {
  108564. /**
  108565. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  108566. * input texture to perform effects such as edge detection or sharpening
  108567. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  108568. */
  108569. export class ConvolutionPostProcess extends PostProcess {
  108570. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  108571. kernel: number[];
  108572. /**
  108573. * Creates a new instance ConvolutionPostProcess
  108574. * @param name The name of the effect.
  108575. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  108576. * @param options The required width/height ratio to downsize to before computing the render pass.
  108577. * @param camera The camera to apply the render pass to.
  108578. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108579. * @param engine The engine which the post process will be applied. (default: current engine)
  108580. * @param reusable If the post process can be reused on the same frame. (default: false)
  108581. * @param textureType Type of textures used when performing the post process. (default: 0)
  108582. */
  108583. constructor(name: string,
  108584. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  108585. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  108586. /**
  108587. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108588. */
  108589. static EdgeDetect0Kernel: number[];
  108590. /**
  108591. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108592. */
  108593. static EdgeDetect1Kernel: number[];
  108594. /**
  108595. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108596. */
  108597. static EdgeDetect2Kernel: number[];
  108598. /**
  108599. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108600. */
  108601. static SharpenKernel: number[];
  108602. /**
  108603. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108604. */
  108605. static EmbossKernel: number[];
  108606. /**
  108607. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108608. */
  108609. static GaussianKernel: number[];
  108610. }
  108611. }
  108612. declare module BABYLON {
  108613. /**
  108614. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  108615. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  108616. * based on samples that have a large difference in distance than the center pixel.
  108617. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  108618. */
  108619. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  108620. direction: Vector2;
  108621. /**
  108622. * Creates a new instance CircleOfConfusionPostProcess
  108623. * @param name The name of the effect.
  108624. * @param scene The scene the effect belongs to.
  108625. * @param direction The direction the blur should be applied.
  108626. * @param kernel The size of the kernel used to blur.
  108627. * @param options The required width/height ratio to downsize to before computing the render pass.
  108628. * @param camera The camera to apply the render pass to.
  108629. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  108630. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  108631. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108632. * @param engine The engine which the post process will be applied. (default: current engine)
  108633. * @param reusable If the post process can be reused on the same frame. (default: false)
  108634. * @param textureType Type of textures used when performing the post process. (default: 0)
  108635. * @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)
  108636. */
  108637. 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);
  108638. }
  108639. }
  108640. declare module BABYLON {
  108641. /** @hidden */
  108642. export var depthOfFieldMergePixelShader: {
  108643. name: string;
  108644. shader: string;
  108645. };
  108646. }
  108647. declare module BABYLON {
  108648. /**
  108649. * Options to be set when merging outputs from the default pipeline.
  108650. */
  108651. export class DepthOfFieldMergePostProcessOptions {
  108652. /**
  108653. * The original image to merge on top of
  108654. */
  108655. originalFromInput: PostProcess;
  108656. /**
  108657. * Parameters to perform the merge of the depth of field effect
  108658. */
  108659. depthOfField?: {
  108660. circleOfConfusion: PostProcess;
  108661. blurSteps: Array<PostProcess>;
  108662. };
  108663. /**
  108664. * Parameters to perform the merge of bloom effect
  108665. */
  108666. bloom?: {
  108667. blurred: PostProcess;
  108668. weight: number;
  108669. };
  108670. }
  108671. /**
  108672. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  108673. */
  108674. export class DepthOfFieldMergePostProcess extends PostProcess {
  108675. private blurSteps;
  108676. /**
  108677. * Creates a new instance of DepthOfFieldMergePostProcess
  108678. * @param name The name of the effect.
  108679. * @param originalFromInput Post process which's input will be used for the merge.
  108680. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  108681. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  108682. * @param options The required width/height ratio to downsize to before computing the render pass.
  108683. * @param camera The camera to apply the render pass to.
  108684. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108685. * @param engine The engine which the post process will be applied. (default: current engine)
  108686. * @param reusable If the post process can be reused on the same frame. (default: false)
  108687. * @param textureType Type of textures used when performing the post process. (default: 0)
  108688. * @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)
  108689. */
  108690. 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);
  108691. /**
  108692. * Updates the effect with the current post process compile time values and recompiles the shader.
  108693. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  108694. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  108695. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  108696. * @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
  108697. * @param onCompiled Called when the shader has been compiled.
  108698. * @param onError Called if there is an error when compiling a shader.
  108699. */
  108700. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  108701. }
  108702. }
  108703. declare module BABYLON {
  108704. /**
  108705. * Specifies the level of max blur that should be applied when using the depth of field effect
  108706. */
  108707. export enum DepthOfFieldEffectBlurLevel {
  108708. /**
  108709. * Subtle blur
  108710. */
  108711. Low = 0,
  108712. /**
  108713. * Medium blur
  108714. */
  108715. Medium = 1,
  108716. /**
  108717. * Large blur
  108718. */
  108719. High = 2
  108720. }
  108721. /**
  108722. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  108723. */
  108724. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  108725. private _circleOfConfusion;
  108726. /**
  108727. * @hidden Internal, blurs from high to low
  108728. */
  108729. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  108730. private _depthOfFieldBlurY;
  108731. private _dofMerge;
  108732. /**
  108733. * @hidden Internal post processes in depth of field effect
  108734. */
  108735. _effects: Array<PostProcess>;
  108736. /**
  108737. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  108738. */
  108739. focalLength: number;
  108740. /**
  108741. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  108742. */
  108743. fStop: number;
  108744. /**
  108745. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  108746. */
  108747. focusDistance: number;
  108748. /**
  108749. * 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.
  108750. */
  108751. lensSize: number;
  108752. /**
  108753. * Creates a new instance DepthOfFieldEffect
  108754. * @param scene The scene the effect belongs to.
  108755. * @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.
  108756. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  108757. * @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)
  108758. */
  108759. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  108760. /**
  108761. * 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.
  108762. */
  108763. depthTexture: RenderTargetTexture;
  108764. /**
  108765. * Disposes each of the internal effects for a given camera.
  108766. * @param camera The camera to dispose the effect on.
  108767. */
  108768. disposeEffects(camera: Camera): void;
  108769. /**
  108770. * @hidden Internal
  108771. */
  108772. _updateEffects(): void;
  108773. /**
  108774. * Internal
  108775. * @returns if all the contained post processes are ready.
  108776. * @hidden
  108777. */
  108778. _isReady(): boolean;
  108779. }
  108780. }
  108781. declare module BABYLON {
  108782. /** @hidden */
  108783. export var displayPassPixelShader: {
  108784. name: string;
  108785. shader: string;
  108786. };
  108787. }
  108788. declare module BABYLON {
  108789. /**
  108790. * DisplayPassPostProcess which produces an output the same as it's input
  108791. */
  108792. export class DisplayPassPostProcess extends PostProcess {
  108793. /**
  108794. * Creates the DisplayPassPostProcess
  108795. * @param name The name of the effect.
  108796. * @param options The required width/height ratio to downsize to before computing the render pass.
  108797. * @param camera The camera to apply the render pass to.
  108798. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108799. * @param engine The engine which the post process will be applied. (default: current engine)
  108800. * @param reusable If the post process can be reused on the same frame. (default: false)
  108801. */
  108802. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108803. }
  108804. }
  108805. declare module BABYLON {
  108806. /** @hidden */
  108807. export var filterPixelShader: {
  108808. name: string;
  108809. shader: string;
  108810. };
  108811. }
  108812. declare module BABYLON {
  108813. /**
  108814. * Applies a kernel filter to the image
  108815. */
  108816. export class FilterPostProcess extends PostProcess {
  108817. /** The matrix to be applied to the image */
  108818. kernelMatrix: Matrix;
  108819. /**
  108820. *
  108821. * @param name The name of the effect.
  108822. * @param kernelMatrix The matrix to be applied to the image
  108823. * @param options The required width/height ratio to downsize to before computing the render pass.
  108824. * @param camera The camera to apply the render pass to.
  108825. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108826. * @param engine The engine which the post process will be applied. (default: current engine)
  108827. * @param reusable If the post process can be reused on the same frame. (default: false)
  108828. */
  108829. constructor(name: string,
  108830. /** The matrix to be applied to the image */
  108831. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108832. }
  108833. }
  108834. declare module BABYLON {
  108835. /** @hidden */
  108836. export var fxaaPixelShader: {
  108837. name: string;
  108838. shader: string;
  108839. };
  108840. }
  108841. declare module BABYLON {
  108842. /** @hidden */
  108843. export var fxaaVertexShader: {
  108844. name: string;
  108845. shader: string;
  108846. };
  108847. }
  108848. declare module BABYLON {
  108849. /**
  108850. * Fxaa post process
  108851. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  108852. */
  108853. export class FxaaPostProcess extends PostProcess {
  108854. /** @hidden */
  108855. texelWidth: number;
  108856. /** @hidden */
  108857. texelHeight: number;
  108858. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  108859. private _getDefines;
  108860. }
  108861. }
  108862. declare module BABYLON {
  108863. /** @hidden */
  108864. export var grainPixelShader: {
  108865. name: string;
  108866. shader: string;
  108867. };
  108868. }
  108869. declare module BABYLON {
  108870. /**
  108871. * The GrainPostProcess adds noise to the image at mid luminance levels
  108872. */
  108873. export class GrainPostProcess extends PostProcess {
  108874. /**
  108875. * The intensity of the grain added (default: 30)
  108876. */
  108877. intensity: number;
  108878. /**
  108879. * If the grain should be randomized on every frame
  108880. */
  108881. animated: boolean;
  108882. /**
  108883. * Creates a new instance of @see GrainPostProcess
  108884. * @param name The name of the effect.
  108885. * @param options The required width/height ratio to downsize to before computing the render pass.
  108886. * @param camera The camera to apply the render pass to.
  108887. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108888. * @param engine The engine which the post process will be applied. (default: current engine)
  108889. * @param reusable If the post process can be reused on the same frame. (default: false)
  108890. * @param textureType Type of textures used when performing the post process. (default: 0)
  108891. * @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)
  108892. */
  108893. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108894. }
  108895. }
  108896. declare module BABYLON {
  108897. /** @hidden */
  108898. export var highlightsPixelShader: {
  108899. name: string;
  108900. shader: string;
  108901. };
  108902. }
  108903. declare module BABYLON {
  108904. /**
  108905. * Extracts highlights from the image
  108906. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  108907. */
  108908. export class HighlightsPostProcess extends PostProcess {
  108909. /**
  108910. * Extracts highlights from the image
  108911. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  108912. * @param name The name of the effect.
  108913. * @param options The required width/height ratio to downsize to before computing the render pass.
  108914. * @param camera The camera to apply the render pass to.
  108915. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108916. * @param engine The engine which the post process will be applied. (default: current engine)
  108917. * @param reusable If the post process can be reused on the same frame. (default: false)
  108918. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  108919. */
  108920. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  108921. }
  108922. }
  108923. declare module BABYLON {
  108924. /** @hidden */
  108925. export var mrtFragmentDeclaration: {
  108926. name: string;
  108927. shader: string;
  108928. };
  108929. }
  108930. declare module BABYLON {
  108931. /** @hidden */
  108932. export var geometryPixelShader: {
  108933. name: string;
  108934. shader: string;
  108935. };
  108936. }
  108937. declare module BABYLON {
  108938. /** @hidden */
  108939. export var geometryVertexShader: {
  108940. name: string;
  108941. shader: string;
  108942. };
  108943. }
  108944. declare module BABYLON {
  108945. /**
  108946. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  108947. */
  108948. export class GeometryBufferRenderer {
  108949. /**
  108950. * Constant used to retrieve the position texture index in the G-Buffer textures array
  108951. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  108952. */
  108953. static readonly POSITION_TEXTURE_TYPE: number;
  108954. /**
  108955. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  108956. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  108957. */
  108958. static readonly VELOCITY_TEXTURE_TYPE: number;
  108959. /**
  108960. * Dictionary used to store the previous transformation matrices of each rendered mesh
  108961. * in order to compute objects velocities when enableVelocity is set to "true"
  108962. * @hidden
  108963. */
  108964. _previousTransformationMatrices: {
  108965. [index: number]: Matrix;
  108966. };
  108967. private _scene;
  108968. private _multiRenderTarget;
  108969. private _ratio;
  108970. private _enablePosition;
  108971. private _enableVelocity;
  108972. private _positionIndex;
  108973. private _velocityIndex;
  108974. protected _effect: Effect;
  108975. protected _cachedDefines: string;
  108976. /**
  108977. * Set the render list (meshes to be rendered) used in the G buffer.
  108978. */
  108979. renderList: Mesh[];
  108980. /**
  108981. * Gets wether or not G buffer are supported by the running hardware.
  108982. * This requires draw buffer supports
  108983. */
  108984. readonly isSupported: boolean;
  108985. /**
  108986. * Returns the index of the given texture type in the G-Buffer textures array
  108987. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  108988. * @returns the index of the given texture type in the G-Buffer textures array
  108989. */
  108990. getTextureIndex(textureType: number): number;
  108991. /**
  108992. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  108993. */
  108994. /**
  108995. * Sets whether or not objects positions are enabled for the G buffer.
  108996. */
  108997. enablePosition: boolean;
  108998. /**
  108999. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  109000. */
  109001. /**
  109002. * Sets wether or not objects velocities are enabled for the G buffer.
  109003. */
  109004. enableVelocity: boolean;
  109005. /**
  109006. * Gets the scene associated with the buffer.
  109007. */
  109008. readonly scene: Scene;
  109009. /**
  109010. * Gets the ratio used by the buffer during its creation.
  109011. * How big is the buffer related to the main canvas.
  109012. */
  109013. readonly ratio: number;
  109014. /** @hidden */
  109015. static _SceneComponentInitialization: (scene: Scene) => void;
  109016. /**
  109017. * Creates a new G Buffer for the scene
  109018. * @param scene The scene the buffer belongs to
  109019. * @param ratio How big is the buffer related to the main canvas.
  109020. */
  109021. constructor(scene: Scene, ratio?: number);
  109022. /**
  109023. * Checks wether everything is ready to render a submesh to the G buffer.
  109024. * @param subMesh the submesh to check readiness for
  109025. * @param useInstances is the mesh drawn using instance or not
  109026. * @returns true if ready otherwise false
  109027. */
  109028. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  109029. /**
  109030. * Gets the current underlying G Buffer.
  109031. * @returns the buffer
  109032. */
  109033. getGBuffer(): MultiRenderTarget;
  109034. /**
  109035. * Gets the number of samples used to render the buffer (anti aliasing).
  109036. */
  109037. /**
  109038. * Sets the number of samples used to render the buffer (anti aliasing).
  109039. */
  109040. samples: number;
  109041. /**
  109042. * Disposes the renderer and frees up associated resources.
  109043. */
  109044. dispose(): void;
  109045. protected _createRenderTargets(): void;
  109046. }
  109047. }
  109048. declare module BABYLON {
  109049. interface Scene {
  109050. /** @hidden (Backing field) */
  109051. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  109052. /**
  109053. * Gets or Sets the current geometry buffer associated to the scene.
  109054. */
  109055. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  109056. /**
  109057. * Enables a GeometryBufferRender and associates it with the scene
  109058. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  109059. * @returns the GeometryBufferRenderer
  109060. */
  109061. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  109062. /**
  109063. * Disables the GeometryBufferRender associated with the scene
  109064. */
  109065. disableGeometryBufferRenderer(): void;
  109066. }
  109067. /**
  109068. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  109069. * in several rendering techniques.
  109070. */
  109071. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  109072. /**
  109073. * The component name helpful to identify the component in the list of scene components.
  109074. */
  109075. readonly name: string;
  109076. /**
  109077. * The scene the component belongs to.
  109078. */
  109079. scene: Scene;
  109080. /**
  109081. * Creates a new instance of the component for the given scene
  109082. * @param scene Defines the scene to register the component in
  109083. */
  109084. constructor(scene: Scene);
  109085. /**
  109086. * Registers the component in a given scene
  109087. */
  109088. register(): void;
  109089. /**
  109090. * Rebuilds the elements related to this component in case of
  109091. * context lost for instance.
  109092. */
  109093. rebuild(): void;
  109094. /**
  109095. * Disposes the component and the associated ressources
  109096. */
  109097. dispose(): void;
  109098. private _gatherRenderTargets;
  109099. }
  109100. }
  109101. declare module BABYLON {
  109102. /** @hidden */
  109103. export var motionBlurPixelShader: {
  109104. name: string;
  109105. shader: string;
  109106. };
  109107. }
  109108. declare module BABYLON {
  109109. /**
  109110. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  109111. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  109112. * As an example, all you have to do is to create the post-process:
  109113. * var mb = new BABYLON.MotionBlurPostProcess(
  109114. * 'mb', // The name of the effect.
  109115. * scene, // The scene containing the objects to blur according to their velocity.
  109116. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  109117. * camera // The camera to apply the render pass to.
  109118. * );
  109119. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  109120. */
  109121. export class MotionBlurPostProcess extends PostProcess {
  109122. /**
  109123. * Defines how much the image is blurred by the movement. Default value is equal to 1
  109124. */
  109125. motionStrength: number;
  109126. /**
  109127. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  109128. */
  109129. /**
  109130. * Sets the number of iterations to be used for motion blur quality
  109131. */
  109132. motionBlurSamples: number;
  109133. private _motionBlurSamples;
  109134. private _geometryBufferRenderer;
  109135. /**
  109136. * Creates a new instance MotionBlurPostProcess
  109137. * @param name The name of the effect.
  109138. * @param scene The scene containing the objects to blur according to their velocity.
  109139. * @param options The required width/height ratio to downsize to before computing the render pass.
  109140. * @param camera The camera to apply the render pass to.
  109141. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109142. * @param engine The engine which the post process will be applied. (default: current engine)
  109143. * @param reusable If the post process can be reused on the same frame. (default: false)
  109144. * @param textureType Type of textures used when performing the post process. (default: 0)
  109145. * @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)
  109146. */
  109147. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109148. /**
  109149. * Disposes the post process.
  109150. * @param camera The camera to dispose the post process on.
  109151. */
  109152. dispose(camera?: Camera): void;
  109153. }
  109154. }
  109155. declare module BABYLON {
  109156. /** @hidden */
  109157. export var refractionPixelShader: {
  109158. name: string;
  109159. shader: string;
  109160. };
  109161. }
  109162. declare module BABYLON {
  109163. /**
  109164. * Post process which applies a refractin texture
  109165. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  109166. */
  109167. export class RefractionPostProcess extends PostProcess {
  109168. /** the base color of the refraction (used to taint the rendering) */
  109169. color: Color3;
  109170. /** simulated refraction depth */
  109171. depth: number;
  109172. /** the coefficient of the base color (0 to remove base color tainting) */
  109173. colorLevel: number;
  109174. private _refTexture;
  109175. private _ownRefractionTexture;
  109176. /**
  109177. * Gets or sets the refraction texture
  109178. * Please note that you are responsible for disposing the texture if you set it manually
  109179. */
  109180. refractionTexture: Texture;
  109181. /**
  109182. * Initializes the RefractionPostProcess
  109183. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  109184. * @param name The name of the effect.
  109185. * @param refractionTextureUrl Url of the refraction texture to use
  109186. * @param color the base color of the refraction (used to taint the rendering)
  109187. * @param depth simulated refraction depth
  109188. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  109189. * @param camera The camera to apply the render pass to.
  109190. * @param options The required width/height ratio to downsize to before computing the render pass.
  109191. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109192. * @param engine The engine which the post process will be applied. (default: current engine)
  109193. * @param reusable If the post process can be reused on the same frame. (default: false)
  109194. */
  109195. constructor(name: string, refractionTextureUrl: string,
  109196. /** the base color of the refraction (used to taint the rendering) */
  109197. color: Color3,
  109198. /** simulated refraction depth */
  109199. depth: number,
  109200. /** the coefficient of the base color (0 to remove base color tainting) */
  109201. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  109202. /**
  109203. * Disposes of the post process
  109204. * @param camera Camera to dispose post process on
  109205. */
  109206. dispose(camera: Camera): void;
  109207. }
  109208. }
  109209. declare module BABYLON {
  109210. /** @hidden */
  109211. export var sharpenPixelShader: {
  109212. name: string;
  109213. shader: string;
  109214. };
  109215. }
  109216. declare module BABYLON {
  109217. /**
  109218. * The SharpenPostProcess applies a sharpen kernel to every pixel
  109219. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  109220. */
  109221. export class SharpenPostProcess extends PostProcess {
  109222. /**
  109223. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  109224. */
  109225. colorAmount: number;
  109226. /**
  109227. * How much sharpness should be applied (default: 0.3)
  109228. */
  109229. edgeAmount: number;
  109230. /**
  109231. * Creates a new instance ConvolutionPostProcess
  109232. * @param name The name of the effect.
  109233. * @param options The required width/height ratio to downsize to before computing the render pass.
  109234. * @param camera The camera to apply the render pass to.
  109235. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109236. * @param engine The engine which the post process will be applied. (default: current engine)
  109237. * @param reusable If the post process can be reused on the same frame. (default: false)
  109238. * @param textureType Type of textures used when performing the post process. (default: 0)
  109239. * @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)
  109240. */
  109241. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109242. }
  109243. }
  109244. declare module BABYLON {
  109245. /**
  109246. * PostProcessRenderPipeline
  109247. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109248. */
  109249. export class PostProcessRenderPipeline {
  109250. private engine;
  109251. private _renderEffects;
  109252. private _renderEffectsForIsolatedPass;
  109253. /**
  109254. * @hidden
  109255. */
  109256. protected _cameras: Camera[];
  109257. /** @hidden */
  109258. _name: string;
  109259. /**
  109260. * Gets pipeline name
  109261. */
  109262. readonly name: string;
  109263. /**
  109264. * Initializes a PostProcessRenderPipeline
  109265. * @param engine engine to add the pipeline to
  109266. * @param name name of the pipeline
  109267. */
  109268. constructor(engine: Engine, name: string);
  109269. /**
  109270. * Gets the class name
  109271. * @returns "PostProcessRenderPipeline"
  109272. */
  109273. getClassName(): string;
  109274. /**
  109275. * If all the render effects in the pipeline are supported
  109276. */
  109277. readonly isSupported: boolean;
  109278. /**
  109279. * Adds an effect to the pipeline
  109280. * @param renderEffect the effect to add
  109281. */
  109282. addEffect(renderEffect: PostProcessRenderEffect): void;
  109283. /** @hidden */
  109284. _rebuild(): void;
  109285. /** @hidden */
  109286. _enableEffect(renderEffectName: string, cameras: Camera): void;
  109287. /** @hidden */
  109288. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  109289. /** @hidden */
  109290. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  109291. /** @hidden */
  109292. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  109293. /** @hidden */
  109294. _attachCameras(cameras: Camera, unique: boolean): void;
  109295. /** @hidden */
  109296. _attachCameras(cameras: Camera[], unique: boolean): void;
  109297. /** @hidden */
  109298. _detachCameras(cameras: Camera): void;
  109299. /** @hidden */
  109300. _detachCameras(cameras: Nullable<Camera[]>): void;
  109301. /** @hidden */
  109302. _update(): void;
  109303. /** @hidden */
  109304. _reset(): void;
  109305. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  109306. /**
  109307. * Disposes of the pipeline
  109308. */
  109309. dispose(): void;
  109310. }
  109311. }
  109312. declare module BABYLON {
  109313. /**
  109314. * PostProcessRenderPipelineManager class
  109315. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109316. */
  109317. export class PostProcessRenderPipelineManager {
  109318. private _renderPipelines;
  109319. /**
  109320. * Initializes a PostProcessRenderPipelineManager
  109321. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109322. */
  109323. constructor();
  109324. /**
  109325. * Gets the list of supported render pipelines
  109326. */
  109327. readonly supportedPipelines: PostProcessRenderPipeline[];
  109328. /**
  109329. * Adds a pipeline to the manager
  109330. * @param renderPipeline The pipeline to add
  109331. */
  109332. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  109333. /**
  109334. * Attaches a camera to the pipeline
  109335. * @param renderPipelineName The name of the pipeline to attach to
  109336. * @param cameras the camera to attach
  109337. * @param unique if the camera can be attached multiple times to the pipeline
  109338. */
  109339. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  109340. /**
  109341. * Detaches a camera from the pipeline
  109342. * @param renderPipelineName The name of the pipeline to detach from
  109343. * @param cameras the camera to detach
  109344. */
  109345. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  109346. /**
  109347. * Enables an effect by name on a pipeline
  109348. * @param renderPipelineName the name of the pipeline to enable the effect in
  109349. * @param renderEffectName the name of the effect to enable
  109350. * @param cameras the cameras that the effect should be enabled on
  109351. */
  109352. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  109353. /**
  109354. * Disables an effect by name on a pipeline
  109355. * @param renderPipelineName the name of the pipeline to disable the effect in
  109356. * @param renderEffectName the name of the effect to disable
  109357. * @param cameras the cameras that the effect should be disabled on
  109358. */
  109359. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  109360. /**
  109361. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  109362. */
  109363. update(): void;
  109364. /** @hidden */
  109365. _rebuild(): void;
  109366. /**
  109367. * Disposes of the manager and pipelines
  109368. */
  109369. dispose(): void;
  109370. }
  109371. }
  109372. declare module BABYLON {
  109373. interface Scene {
  109374. /** @hidden (Backing field) */
  109375. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  109376. /**
  109377. * Gets the postprocess render pipeline manager
  109378. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109379. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  109380. */
  109381. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  109382. }
  109383. /**
  109384. * Defines the Render Pipeline scene component responsible to rendering pipelines
  109385. */
  109386. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  109387. /**
  109388. * The component name helpfull to identify the component in the list of scene components.
  109389. */
  109390. readonly name: string;
  109391. /**
  109392. * The scene the component belongs to.
  109393. */
  109394. scene: Scene;
  109395. /**
  109396. * Creates a new instance of the component for the given scene
  109397. * @param scene Defines the scene to register the component in
  109398. */
  109399. constructor(scene: Scene);
  109400. /**
  109401. * Registers the component in a given scene
  109402. */
  109403. register(): void;
  109404. /**
  109405. * Rebuilds the elements related to this component in case of
  109406. * context lost for instance.
  109407. */
  109408. rebuild(): void;
  109409. /**
  109410. * Disposes the component and the associated ressources
  109411. */
  109412. dispose(): void;
  109413. private _gatherRenderTargets;
  109414. }
  109415. }
  109416. declare module BABYLON {
  109417. /**
  109418. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  109419. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  109420. */
  109421. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  109422. private _scene;
  109423. private _camerasToBeAttached;
  109424. /**
  109425. * ID of the sharpen post process,
  109426. */
  109427. private readonly SharpenPostProcessId;
  109428. /**
  109429. * @ignore
  109430. * ID of the image processing post process;
  109431. */
  109432. readonly ImageProcessingPostProcessId: string;
  109433. /**
  109434. * @ignore
  109435. * ID of the Fast Approximate Anti-Aliasing post process;
  109436. */
  109437. readonly FxaaPostProcessId: string;
  109438. /**
  109439. * ID of the chromatic aberration post process,
  109440. */
  109441. private readonly ChromaticAberrationPostProcessId;
  109442. /**
  109443. * ID of the grain post process
  109444. */
  109445. private readonly GrainPostProcessId;
  109446. /**
  109447. * Sharpen post process which will apply a sharpen convolution to enhance edges
  109448. */
  109449. sharpen: SharpenPostProcess;
  109450. private _sharpenEffect;
  109451. private bloom;
  109452. /**
  109453. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  109454. */
  109455. depthOfField: DepthOfFieldEffect;
  109456. /**
  109457. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  109458. */
  109459. fxaa: FxaaPostProcess;
  109460. /**
  109461. * Image post processing pass used to perform operations such as tone mapping or color grading.
  109462. */
  109463. imageProcessing: ImageProcessingPostProcess;
  109464. /**
  109465. * Chromatic aberration post process which will shift rgb colors in the image
  109466. */
  109467. chromaticAberration: ChromaticAberrationPostProcess;
  109468. private _chromaticAberrationEffect;
  109469. /**
  109470. * Grain post process which add noise to the image
  109471. */
  109472. grain: GrainPostProcess;
  109473. private _grainEffect;
  109474. /**
  109475. * Glow post process which adds a glow to emissive areas of the image
  109476. */
  109477. private _glowLayer;
  109478. /**
  109479. * Animations which can be used to tweak settings over a period of time
  109480. */
  109481. animations: Animation[];
  109482. private _imageProcessingConfigurationObserver;
  109483. private _sharpenEnabled;
  109484. private _bloomEnabled;
  109485. private _depthOfFieldEnabled;
  109486. private _depthOfFieldBlurLevel;
  109487. private _fxaaEnabled;
  109488. private _imageProcessingEnabled;
  109489. private _defaultPipelineTextureType;
  109490. private _bloomScale;
  109491. private _chromaticAberrationEnabled;
  109492. private _grainEnabled;
  109493. private _buildAllowed;
  109494. /**
  109495. * Gets active scene
  109496. */
  109497. readonly scene: Scene;
  109498. /**
  109499. * Enable or disable the sharpen process from the pipeline
  109500. */
  109501. sharpenEnabled: boolean;
  109502. private _resizeObserver;
  109503. private _hardwareScaleLevel;
  109504. private _bloomKernel;
  109505. /**
  109506. * Specifies the size of the bloom blur kernel, relative to the final output size
  109507. */
  109508. bloomKernel: number;
  109509. /**
  109510. * Specifies the weight of the bloom in the final rendering
  109511. */
  109512. private _bloomWeight;
  109513. /**
  109514. * Specifies the luma threshold for the area that will be blurred by the bloom
  109515. */
  109516. private _bloomThreshold;
  109517. private _hdr;
  109518. /**
  109519. * The strength of the bloom.
  109520. */
  109521. bloomWeight: number;
  109522. /**
  109523. * The strength of the bloom.
  109524. */
  109525. bloomThreshold: number;
  109526. /**
  109527. * The scale of the bloom, lower value will provide better performance.
  109528. */
  109529. bloomScale: number;
  109530. /**
  109531. * Enable or disable the bloom from the pipeline
  109532. */
  109533. bloomEnabled: boolean;
  109534. private _rebuildBloom;
  109535. /**
  109536. * If the depth of field is enabled.
  109537. */
  109538. depthOfFieldEnabled: boolean;
  109539. /**
  109540. * Blur level of the depth of field effect. (Higher blur will effect performance)
  109541. */
  109542. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  109543. /**
  109544. * If the anti aliasing is enabled.
  109545. */
  109546. fxaaEnabled: boolean;
  109547. private _samples;
  109548. /**
  109549. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  109550. */
  109551. samples: number;
  109552. /**
  109553. * If image processing is enabled.
  109554. */
  109555. imageProcessingEnabled: boolean;
  109556. /**
  109557. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  109558. */
  109559. glowLayerEnabled: boolean;
  109560. /**
  109561. * Enable or disable the chromaticAberration process from the pipeline
  109562. */
  109563. chromaticAberrationEnabled: boolean;
  109564. /**
  109565. * Enable or disable the grain process from the pipeline
  109566. */
  109567. grainEnabled: boolean;
  109568. /**
  109569. * @constructor
  109570. * @param name - The rendering pipeline name (default: "")
  109571. * @param hdr - If high dynamic range textures should be used (default: true)
  109572. * @param scene - The scene linked to this pipeline (default: the last created scene)
  109573. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  109574. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  109575. */
  109576. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  109577. /**
  109578. * Get the class name
  109579. * @returns "DefaultRenderingPipeline"
  109580. */
  109581. getClassName(): string;
  109582. /**
  109583. * Force the compilation of the entire pipeline.
  109584. */
  109585. prepare(): void;
  109586. private _hasCleared;
  109587. private _prevPostProcess;
  109588. private _prevPrevPostProcess;
  109589. private _setAutoClearAndTextureSharing;
  109590. private _depthOfFieldSceneObserver;
  109591. private _buildPipeline;
  109592. private _disposePostProcesses;
  109593. /**
  109594. * Adds a camera to the pipeline
  109595. * @param camera the camera to be added
  109596. */
  109597. addCamera(camera: Camera): void;
  109598. /**
  109599. * Removes a camera from the pipeline
  109600. * @param camera the camera to remove
  109601. */
  109602. removeCamera(camera: Camera): void;
  109603. /**
  109604. * Dispose of the pipeline and stop all post processes
  109605. */
  109606. dispose(): void;
  109607. /**
  109608. * Serialize the rendering pipeline (Used when exporting)
  109609. * @returns the serialized object
  109610. */
  109611. serialize(): any;
  109612. /**
  109613. * Parse the serialized pipeline
  109614. * @param source Source pipeline.
  109615. * @param scene The scene to load the pipeline to.
  109616. * @param rootUrl The URL of the serialized pipeline.
  109617. * @returns An instantiated pipeline from the serialized object.
  109618. */
  109619. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  109620. }
  109621. }
  109622. declare module BABYLON {
  109623. /** @hidden */
  109624. export var lensHighlightsPixelShader: {
  109625. name: string;
  109626. shader: string;
  109627. };
  109628. }
  109629. declare module BABYLON {
  109630. /** @hidden */
  109631. export var depthOfFieldPixelShader: {
  109632. name: string;
  109633. shader: string;
  109634. };
  109635. }
  109636. declare module BABYLON {
  109637. /**
  109638. * BABYLON.JS Chromatic Aberration GLSL Shader
  109639. * Author: Olivier Guyot
  109640. * Separates very slightly R, G and B colors on the edges of the screen
  109641. * Inspired by Francois Tarlier & Martins Upitis
  109642. */
  109643. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  109644. /**
  109645. * @ignore
  109646. * The chromatic aberration PostProcess id in the pipeline
  109647. */
  109648. LensChromaticAberrationEffect: string;
  109649. /**
  109650. * @ignore
  109651. * The highlights enhancing PostProcess id in the pipeline
  109652. */
  109653. HighlightsEnhancingEffect: string;
  109654. /**
  109655. * @ignore
  109656. * The depth-of-field PostProcess id in the pipeline
  109657. */
  109658. LensDepthOfFieldEffect: string;
  109659. private _scene;
  109660. private _depthTexture;
  109661. private _grainTexture;
  109662. private _chromaticAberrationPostProcess;
  109663. private _highlightsPostProcess;
  109664. private _depthOfFieldPostProcess;
  109665. private _edgeBlur;
  109666. private _grainAmount;
  109667. private _chromaticAberration;
  109668. private _distortion;
  109669. private _highlightsGain;
  109670. private _highlightsThreshold;
  109671. private _dofDistance;
  109672. private _dofAperture;
  109673. private _dofDarken;
  109674. private _dofPentagon;
  109675. private _blurNoise;
  109676. /**
  109677. * @constructor
  109678. *
  109679. * Effect parameters are as follow:
  109680. * {
  109681. * chromatic_aberration: number; // from 0 to x (1 for realism)
  109682. * edge_blur: number; // from 0 to x (1 for realism)
  109683. * distortion: number; // from 0 to x (1 for realism)
  109684. * grain_amount: number; // from 0 to 1
  109685. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  109686. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  109687. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  109688. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  109689. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  109690. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  109691. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  109692. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  109693. * }
  109694. * Note: if an effect parameter is unset, effect is disabled
  109695. *
  109696. * @param name The rendering pipeline name
  109697. * @param parameters - An object containing all parameters (see above)
  109698. * @param scene The scene linked to this pipeline
  109699. * @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)
  109700. * @param cameras The array of cameras that the rendering pipeline will be attached to
  109701. */
  109702. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  109703. /**
  109704. * Sets the amount of blur at the edges
  109705. * @param amount blur amount
  109706. */
  109707. setEdgeBlur(amount: number): void;
  109708. /**
  109709. * Sets edge blur to 0
  109710. */
  109711. disableEdgeBlur(): void;
  109712. /**
  109713. * Sets the amout of grain
  109714. * @param amount Amount of grain
  109715. */
  109716. setGrainAmount(amount: number): void;
  109717. /**
  109718. * Set grain amount to 0
  109719. */
  109720. disableGrain(): void;
  109721. /**
  109722. * Sets the chromatic aberration amount
  109723. * @param amount amount of chromatic aberration
  109724. */
  109725. setChromaticAberration(amount: number): void;
  109726. /**
  109727. * Sets chromatic aberration amount to 0
  109728. */
  109729. disableChromaticAberration(): void;
  109730. /**
  109731. * Sets the EdgeDistortion amount
  109732. * @param amount amount of EdgeDistortion
  109733. */
  109734. setEdgeDistortion(amount: number): void;
  109735. /**
  109736. * Sets edge distortion to 0
  109737. */
  109738. disableEdgeDistortion(): void;
  109739. /**
  109740. * Sets the FocusDistance amount
  109741. * @param amount amount of FocusDistance
  109742. */
  109743. setFocusDistance(amount: number): void;
  109744. /**
  109745. * Disables depth of field
  109746. */
  109747. disableDepthOfField(): void;
  109748. /**
  109749. * Sets the Aperture amount
  109750. * @param amount amount of Aperture
  109751. */
  109752. setAperture(amount: number): void;
  109753. /**
  109754. * Sets the DarkenOutOfFocus amount
  109755. * @param amount amount of DarkenOutOfFocus
  109756. */
  109757. setDarkenOutOfFocus(amount: number): void;
  109758. /**
  109759. * Creates a pentagon bokeh effect
  109760. */
  109761. enablePentagonBokeh(): void;
  109762. /**
  109763. * Disables the pentagon bokeh effect
  109764. */
  109765. disablePentagonBokeh(): void;
  109766. /**
  109767. * Enables noise blur
  109768. */
  109769. enableNoiseBlur(): void;
  109770. /**
  109771. * Disables noise blur
  109772. */
  109773. disableNoiseBlur(): void;
  109774. /**
  109775. * Sets the HighlightsGain amount
  109776. * @param amount amount of HighlightsGain
  109777. */
  109778. setHighlightsGain(amount: number): void;
  109779. /**
  109780. * Sets the HighlightsThreshold amount
  109781. * @param amount amount of HighlightsThreshold
  109782. */
  109783. setHighlightsThreshold(amount: number): void;
  109784. /**
  109785. * Disables highlights
  109786. */
  109787. disableHighlights(): void;
  109788. /**
  109789. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  109790. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  109791. */
  109792. dispose(disableDepthRender?: boolean): void;
  109793. private _createChromaticAberrationPostProcess;
  109794. private _createHighlightsPostProcess;
  109795. private _createDepthOfFieldPostProcess;
  109796. private _createGrainTexture;
  109797. }
  109798. }
  109799. declare module BABYLON {
  109800. /** @hidden */
  109801. export var ssao2PixelShader: {
  109802. name: string;
  109803. shader: string;
  109804. };
  109805. }
  109806. declare module BABYLON {
  109807. /** @hidden */
  109808. export var ssaoCombinePixelShader: {
  109809. name: string;
  109810. shader: string;
  109811. };
  109812. }
  109813. declare module BABYLON {
  109814. /**
  109815. * Render pipeline to produce ssao effect
  109816. */
  109817. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  109818. /**
  109819. * @ignore
  109820. * The PassPostProcess id in the pipeline that contains the original scene color
  109821. */
  109822. SSAOOriginalSceneColorEffect: string;
  109823. /**
  109824. * @ignore
  109825. * The SSAO PostProcess id in the pipeline
  109826. */
  109827. SSAORenderEffect: string;
  109828. /**
  109829. * @ignore
  109830. * The horizontal blur PostProcess id in the pipeline
  109831. */
  109832. SSAOBlurHRenderEffect: string;
  109833. /**
  109834. * @ignore
  109835. * The vertical blur PostProcess id in the pipeline
  109836. */
  109837. SSAOBlurVRenderEffect: string;
  109838. /**
  109839. * @ignore
  109840. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  109841. */
  109842. SSAOCombineRenderEffect: string;
  109843. /**
  109844. * The output strength of the SSAO post-process. Default value is 1.0.
  109845. */
  109846. totalStrength: number;
  109847. /**
  109848. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  109849. */
  109850. maxZ: number;
  109851. /**
  109852. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  109853. */
  109854. minZAspect: number;
  109855. private _samples;
  109856. /**
  109857. * Number of samples used for the SSAO calculations. Default value is 8
  109858. */
  109859. samples: number;
  109860. private _textureSamples;
  109861. /**
  109862. * Number of samples to use for antialiasing
  109863. */
  109864. textureSamples: number;
  109865. /**
  109866. * Ratio object used for SSAO ratio and blur ratio
  109867. */
  109868. private _ratio;
  109869. /**
  109870. * Dynamically generated sphere sampler.
  109871. */
  109872. private _sampleSphere;
  109873. /**
  109874. * Blur filter offsets
  109875. */
  109876. private _samplerOffsets;
  109877. private _expensiveBlur;
  109878. /**
  109879. * If bilateral blur should be used
  109880. */
  109881. expensiveBlur: boolean;
  109882. /**
  109883. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  109884. */
  109885. radius: number;
  109886. /**
  109887. * The base color of the SSAO post-process
  109888. * The final result is "base + ssao" between [0, 1]
  109889. */
  109890. base: number;
  109891. /**
  109892. * Support test.
  109893. */
  109894. static readonly IsSupported: boolean;
  109895. private _scene;
  109896. private _depthTexture;
  109897. private _normalTexture;
  109898. private _randomTexture;
  109899. private _originalColorPostProcess;
  109900. private _ssaoPostProcess;
  109901. private _blurHPostProcess;
  109902. private _blurVPostProcess;
  109903. private _ssaoCombinePostProcess;
  109904. private _firstUpdate;
  109905. /**
  109906. * Gets active scene
  109907. */
  109908. readonly scene: Scene;
  109909. /**
  109910. * @constructor
  109911. * @param name The rendering pipeline name
  109912. * @param scene The scene linked to this pipeline
  109913. * @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 }
  109914. * @param cameras The array of cameras that the rendering pipeline will be attached to
  109915. */
  109916. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  109917. /**
  109918. * Get the class name
  109919. * @returns "SSAO2RenderingPipeline"
  109920. */
  109921. getClassName(): string;
  109922. /**
  109923. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  109924. */
  109925. dispose(disableGeometryBufferRenderer?: boolean): void;
  109926. private _createBlurPostProcess;
  109927. /** @hidden */
  109928. _rebuild(): void;
  109929. private _bits;
  109930. private _radicalInverse_VdC;
  109931. private _hammersley;
  109932. private _hemisphereSample_uniform;
  109933. private _generateHemisphere;
  109934. private _createSSAOPostProcess;
  109935. private _createSSAOCombinePostProcess;
  109936. private _createRandomTexture;
  109937. /**
  109938. * Serialize the rendering pipeline (Used when exporting)
  109939. * @returns the serialized object
  109940. */
  109941. serialize(): any;
  109942. /**
  109943. * Parse the serialized pipeline
  109944. * @param source Source pipeline.
  109945. * @param scene The scene to load the pipeline to.
  109946. * @param rootUrl The URL of the serialized pipeline.
  109947. * @returns An instantiated pipeline from the serialized object.
  109948. */
  109949. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  109950. }
  109951. }
  109952. declare module BABYLON {
  109953. /** @hidden */
  109954. export var ssaoPixelShader: {
  109955. name: string;
  109956. shader: string;
  109957. };
  109958. }
  109959. declare module BABYLON {
  109960. /**
  109961. * Render pipeline to produce ssao effect
  109962. */
  109963. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  109964. /**
  109965. * @ignore
  109966. * The PassPostProcess id in the pipeline that contains the original scene color
  109967. */
  109968. SSAOOriginalSceneColorEffect: string;
  109969. /**
  109970. * @ignore
  109971. * The SSAO PostProcess id in the pipeline
  109972. */
  109973. SSAORenderEffect: string;
  109974. /**
  109975. * @ignore
  109976. * The horizontal blur PostProcess id in the pipeline
  109977. */
  109978. SSAOBlurHRenderEffect: string;
  109979. /**
  109980. * @ignore
  109981. * The vertical blur PostProcess id in the pipeline
  109982. */
  109983. SSAOBlurVRenderEffect: string;
  109984. /**
  109985. * @ignore
  109986. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  109987. */
  109988. SSAOCombineRenderEffect: string;
  109989. /**
  109990. * The output strength of the SSAO post-process. Default value is 1.0.
  109991. */
  109992. totalStrength: number;
  109993. /**
  109994. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  109995. */
  109996. radius: number;
  109997. /**
  109998. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  109999. * Must not be equal to fallOff and superior to fallOff.
  110000. * Default value is 0.0075
  110001. */
  110002. area: number;
  110003. /**
  110004. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  110005. * Must not be equal to area and inferior to area.
  110006. * Default value is 0.000001
  110007. */
  110008. fallOff: number;
  110009. /**
  110010. * The base color of the SSAO post-process
  110011. * The final result is "base + ssao" between [0, 1]
  110012. */
  110013. base: number;
  110014. private _scene;
  110015. private _depthTexture;
  110016. private _randomTexture;
  110017. private _originalColorPostProcess;
  110018. private _ssaoPostProcess;
  110019. private _blurHPostProcess;
  110020. private _blurVPostProcess;
  110021. private _ssaoCombinePostProcess;
  110022. private _firstUpdate;
  110023. /**
  110024. * Gets active scene
  110025. */
  110026. readonly scene: Scene;
  110027. /**
  110028. * @constructor
  110029. * @param name - The rendering pipeline name
  110030. * @param scene - The scene linked to this pipeline
  110031. * @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 }
  110032. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  110033. */
  110034. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  110035. /**
  110036. * Get the class name
  110037. * @returns "SSAORenderingPipeline"
  110038. */
  110039. getClassName(): string;
  110040. /**
  110041. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  110042. */
  110043. dispose(disableDepthRender?: boolean): void;
  110044. private _createBlurPostProcess;
  110045. /** @hidden */
  110046. _rebuild(): void;
  110047. private _createSSAOPostProcess;
  110048. private _createSSAOCombinePostProcess;
  110049. private _createRandomTexture;
  110050. }
  110051. }
  110052. declare module BABYLON {
  110053. /** @hidden */
  110054. export var standardPixelShader: {
  110055. name: string;
  110056. shader: string;
  110057. };
  110058. }
  110059. declare module BABYLON {
  110060. /**
  110061. * Standard rendering pipeline
  110062. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  110063. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  110064. */
  110065. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  110066. /**
  110067. * Public members
  110068. */
  110069. /**
  110070. * Post-process which contains the original scene color before the pipeline applies all the effects
  110071. */
  110072. originalPostProcess: Nullable<PostProcess>;
  110073. /**
  110074. * Post-process used to down scale an image x4
  110075. */
  110076. downSampleX4PostProcess: Nullable<PostProcess>;
  110077. /**
  110078. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  110079. */
  110080. brightPassPostProcess: Nullable<PostProcess>;
  110081. /**
  110082. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  110083. */
  110084. blurHPostProcesses: PostProcess[];
  110085. /**
  110086. * Post-process array storing all the vertical blur post-processes used by the pipeline
  110087. */
  110088. blurVPostProcesses: PostProcess[];
  110089. /**
  110090. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  110091. */
  110092. textureAdderPostProcess: Nullable<PostProcess>;
  110093. /**
  110094. * Post-process used to create volumetric lighting effect
  110095. */
  110096. volumetricLightPostProcess: Nullable<PostProcess>;
  110097. /**
  110098. * Post-process used to smooth the previous volumetric light post-process on the X axis
  110099. */
  110100. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  110101. /**
  110102. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  110103. */
  110104. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  110105. /**
  110106. * Post-process used to merge the volumetric light effect and the real scene color
  110107. */
  110108. volumetricLightMergePostProces: Nullable<PostProcess>;
  110109. /**
  110110. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  110111. */
  110112. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  110113. /**
  110114. * Base post-process used to calculate the average luminance of the final image for HDR
  110115. */
  110116. luminancePostProcess: Nullable<PostProcess>;
  110117. /**
  110118. * Post-processes used to create down sample post-processes in order to get
  110119. * the average luminance of the final image for HDR
  110120. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  110121. */
  110122. luminanceDownSamplePostProcesses: PostProcess[];
  110123. /**
  110124. * Post-process used to create a HDR effect (light adaptation)
  110125. */
  110126. hdrPostProcess: Nullable<PostProcess>;
  110127. /**
  110128. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  110129. */
  110130. textureAdderFinalPostProcess: Nullable<PostProcess>;
  110131. /**
  110132. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  110133. */
  110134. lensFlareFinalPostProcess: Nullable<PostProcess>;
  110135. /**
  110136. * Post-process used to merge the final HDR post-process and the real scene color
  110137. */
  110138. hdrFinalPostProcess: Nullable<PostProcess>;
  110139. /**
  110140. * Post-process used to create a lens flare effect
  110141. */
  110142. lensFlarePostProcess: Nullable<PostProcess>;
  110143. /**
  110144. * Post-process that merges the result of the lens flare post-process and the real scene color
  110145. */
  110146. lensFlareComposePostProcess: Nullable<PostProcess>;
  110147. /**
  110148. * Post-process used to create a motion blur effect
  110149. */
  110150. motionBlurPostProcess: Nullable<PostProcess>;
  110151. /**
  110152. * Post-process used to create a depth of field effect
  110153. */
  110154. depthOfFieldPostProcess: Nullable<PostProcess>;
  110155. /**
  110156. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  110157. */
  110158. fxaaPostProcess: Nullable<FxaaPostProcess>;
  110159. /**
  110160. * Represents the brightness threshold in order to configure the illuminated surfaces
  110161. */
  110162. brightThreshold: number;
  110163. /**
  110164. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  110165. */
  110166. blurWidth: number;
  110167. /**
  110168. * Sets if the blur for highlighted surfaces must be only horizontal
  110169. */
  110170. horizontalBlur: boolean;
  110171. /**
  110172. * Sets the overall exposure used by the pipeline
  110173. */
  110174. exposure: number;
  110175. /**
  110176. * Texture used typically to simulate "dirty" on camera lens
  110177. */
  110178. lensTexture: Nullable<Texture>;
  110179. /**
  110180. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  110181. */
  110182. volumetricLightCoefficient: number;
  110183. /**
  110184. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  110185. */
  110186. volumetricLightPower: number;
  110187. /**
  110188. * Used the set the blur intensity to smooth the volumetric lights
  110189. */
  110190. volumetricLightBlurScale: number;
  110191. /**
  110192. * Light (spot or directional) used to generate the volumetric lights rays
  110193. * The source light must have a shadow generate so the pipeline can get its
  110194. * depth map
  110195. */
  110196. sourceLight: Nullable<SpotLight | DirectionalLight>;
  110197. /**
  110198. * For eye adaptation, represents the minimum luminance the eye can see
  110199. */
  110200. hdrMinimumLuminance: number;
  110201. /**
  110202. * For eye adaptation, represents the decrease luminance speed
  110203. */
  110204. hdrDecreaseRate: number;
  110205. /**
  110206. * For eye adaptation, represents the increase luminance speed
  110207. */
  110208. hdrIncreaseRate: number;
  110209. /**
  110210. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  110211. */
  110212. lensColorTexture: Nullable<Texture>;
  110213. /**
  110214. * The overall strengh for the lens flare effect
  110215. */
  110216. lensFlareStrength: number;
  110217. /**
  110218. * Dispersion coefficient for lens flare ghosts
  110219. */
  110220. lensFlareGhostDispersal: number;
  110221. /**
  110222. * Main lens flare halo width
  110223. */
  110224. lensFlareHaloWidth: number;
  110225. /**
  110226. * Based on the lens distortion effect, defines how much the lens flare result
  110227. * is distorted
  110228. */
  110229. lensFlareDistortionStrength: number;
  110230. /**
  110231. * Lens star texture must be used to simulate rays on the flares and is available
  110232. * in the documentation
  110233. */
  110234. lensStarTexture: Nullable<Texture>;
  110235. /**
  110236. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  110237. * flare effect by taking account of the dirt texture
  110238. */
  110239. lensFlareDirtTexture: Nullable<Texture>;
  110240. /**
  110241. * Represents the focal length for the depth of field effect
  110242. */
  110243. depthOfFieldDistance: number;
  110244. /**
  110245. * Represents the blur intensity for the blurred part of the depth of field effect
  110246. */
  110247. depthOfFieldBlurWidth: number;
  110248. /**
  110249. * For motion blur, defines how much the image is blurred by the movement
  110250. */
  110251. motionStrength: number;
  110252. /**
  110253. * List of animations for the pipeline (IAnimatable implementation)
  110254. */
  110255. animations: Animation[];
  110256. /**
  110257. * Private members
  110258. */
  110259. private _scene;
  110260. private _currentDepthOfFieldSource;
  110261. private _basePostProcess;
  110262. private _hdrCurrentLuminance;
  110263. private _floatTextureType;
  110264. private _ratio;
  110265. private _bloomEnabled;
  110266. private _depthOfFieldEnabled;
  110267. private _vlsEnabled;
  110268. private _lensFlareEnabled;
  110269. private _hdrEnabled;
  110270. private _motionBlurEnabled;
  110271. private _fxaaEnabled;
  110272. private _motionBlurSamples;
  110273. private _volumetricLightStepsCount;
  110274. private _samples;
  110275. /**
  110276. * @ignore
  110277. * Specifies if the bloom pipeline is enabled
  110278. */
  110279. BloomEnabled: boolean;
  110280. /**
  110281. * @ignore
  110282. * Specifies if the depth of field pipeline is enabed
  110283. */
  110284. DepthOfFieldEnabled: boolean;
  110285. /**
  110286. * @ignore
  110287. * Specifies if the lens flare pipeline is enabed
  110288. */
  110289. LensFlareEnabled: boolean;
  110290. /**
  110291. * @ignore
  110292. * Specifies if the HDR pipeline is enabled
  110293. */
  110294. HDREnabled: boolean;
  110295. /**
  110296. * @ignore
  110297. * Specifies if the volumetric lights scattering effect is enabled
  110298. */
  110299. VLSEnabled: boolean;
  110300. /**
  110301. * @ignore
  110302. * Specifies if the motion blur effect is enabled
  110303. */
  110304. MotionBlurEnabled: boolean;
  110305. /**
  110306. * Specifies if anti-aliasing is enabled
  110307. */
  110308. fxaaEnabled: boolean;
  110309. /**
  110310. * Specifies the number of steps used to calculate the volumetric lights
  110311. * Typically in interval [50, 200]
  110312. */
  110313. volumetricLightStepsCount: number;
  110314. /**
  110315. * Specifies the number of samples used for the motion blur effect
  110316. * Typically in interval [16, 64]
  110317. */
  110318. motionBlurSamples: number;
  110319. /**
  110320. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  110321. */
  110322. samples: number;
  110323. /**
  110324. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  110325. * @constructor
  110326. * @param name The rendering pipeline name
  110327. * @param scene The scene linked to this pipeline
  110328. * @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)
  110329. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  110330. * @param cameras The array of cameras that the rendering pipeline will be attached to
  110331. */
  110332. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  110333. private _buildPipeline;
  110334. private _createDownSampleX4PostProcess;
  110335. private _createBrightPassPostProcess;
  110336. private _createBlurPostProcesses;
  110337. private _createTextureAdderPostProcess;
  110338. private _createVolumetricLightPostProcess;
  110339. private _createLuminancePostProcesses;
  110340. private _createHdrPostProcess;
  110341. private _createLensFlarePostProcess;
  110342. private _createDepthOfFieldPostProcess;
  110343. private _createMotionBlurPostProcess;
  110344. private _getDepthTexture;
  110345. private _disposePostProcesses;
  110346. /**
  110347. * Dispose of the pipeline and stop all post processes
  110348. */
  110349. dispose(): void;
  110350. /**
  110351. * Serialize the rendering pipeline (Used when exporting)
  110352. * @returns the serialized object
  110353. */
  110354. serialize(): any;
  110355. /**
  110356. * Parse the serialized pipeline
  110357. * @param source Source pipeline.
  110358. * @param scene The scene to load the pipeline to.
  110359. * @param rootUrl The URL of the serialized pipeline.
  110360. * @returns An instantiated pipeline from the serialized object.
  110361. */
  110362. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  110363. /**
  110364. * Luminance steps
  110365. */
  110366. static LuminanceSteps: number;
  110367. }
  110368. }
  110369. declare module BABYLON {
  110370. /** @hidden */
  110371. export var tonemapPixelShader: {
  110372. name: string;
  110373. shader: string;
  110374. };
  110375. }
  110376. declare module BABYLON {
  110377. /** Defines operator used for tonemapping */
  110378. export enum TonemappingOperator {
  110379. /** Hable */
  110380. Hable = 0,
  110381. /** Reinhard */
  110382. Reinhard = 1,
  110383. /** HejiDawson */
  110384. HejiDawson = 2,
  110385. /** Photographic */
  110386. Photographic = 3
  110387. }
  110388. /**
  110389. * Defines a post process to apply tone mapping
  110390. */
  110391. export class TonemapPostProcess extends PostProcess {
  110392. private _operator;
  110393. /** Defines the required exposure adjustement */
  110394. exposureAdjustment: number;
  110395. /**
  110396. * Creates a new TonemapPostProcess
  110397. * @param name defines the name of the postprocess
  110398. * @param _operator defines the operator to use
  110399. * @param exposureAdjustment defines the required exposure adjustement
  110400. * @param camera defines the camera to use (can be null)
  110401. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  110402. * @param engine defines the hosting engine (can be ignore if camera is set)
  110403. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  110404. */
  110405. constructor(name: string, _operator: TonemappingOperator,
  110406. /** Defines the required exposure adjustement */
  110407. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  110408. }
  110409. }
  110410. declare module BABYLON {
  110411. /** @hidden */
  110412. export var depthVertexShader: {
  110413. name: string;
  110414. shader: string;
  110415. };
  110416. }
  110417. declare module BABYLON {
  110418. /** @hidden */
  110419. export var volumetricLightScatteringPixelShader: {
  110420. name: string;
  110421. shader: string;
  110422. };
  110423. }
  110424. declare module BABYLON {
  110425. /** @hidden */
  110426. export var volumetricLightScatteringPassPixelShader: {
  110427. name: string;
  110428. shader: string;
  110429. };
  110430. }
  110431. declare module BABYLON {
  110432. /**
  110433. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  110434. */
  110435. export class VolumetricLightScatteringPostProcess extends PostProcess {
  110436. private _volumetricLightScatteringPass;
  110437. private _volumetricLightScatteringRTT;
  110438. private _viewPort;
  110439. private _screenCoordinates;
  110440. private _cachedDefines;
  110441. /**
  110442. * If not undefined, the mesh position is computed from the attached node position
  110443. */
  110444. attachedNode: {
  110445. position: Vector3;
  110446. };
  110447. /**
  110448. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  110449. */
  110450. customMeshPosition: Vector3;
  110451. /**
  110452. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  110453. */
  110454. useCustomMeshPosition: boolean;
  110455. /**
  110456. * If the post-process should inverse the light scattering direction
  110457. */
  110458. invert: boolean;
  110459. /**
  110460. * The internal mesh used by the post-process
  110461. */
  110462. mesh: Mesh;
  110463. /**
  110464. * @hidden
  110465. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  110466. */
  110467. useDiffuseColor: boolean;
  110468. /**
  110469. * Array containing the excluded meshes not rendered in the internal pass
  110470. */
  110471. excludedMeshes: AbstractMesh[];
  110472. /**
  110473. * Controls the overall intensity of the post-process
  110474. */
  110475. exposure: number;
  110476. /**
  110477. * Dissipates each sample's contribution in range [0, 1]
  110478. */
  110479. decay: number;
  110480. /**
  110481. * Controls the overall intensity of each sample
  110482. */
  110483. weight: number;
  110484. /**
  110485. * Controls the density of each sample
  110486. */
  110487. density: number;
  110488. /**
  110489. * @constructor
  110490. * @param name The post-process name
  110491. * @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)
  110492. * @param camera The camera that the post-process will be attached to
  110493. * @param mesh The mesh used to create the light scattering
  110494. * @param samples The post-process quality, default 100
  110495. * @param samplingModeThe post-process filtering mode
  110496. * @param engine The babylon engine
  110497. * @param reusable If the post-process is reusable
  110498. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  110499. */
  110500. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  110501. /**
  110502. * Returns the string "VolumetricLightScatteringPostProcess"
  110503. * @returns "VolumetricLightScatteringPostProcess"
  110504. */
  110505. getClassName(): string;
  110506. private _isReady;
  110507. /**
  110508. * Sets the new light position for light scattering effect
  110509. * @param position The new custom light position
  110510. */
  110511. setCustomMeshPosition(position: Vector3): void;
  110512. /**
  110513. * Returns the light position for light scattering effect
  110514. * @return Vector3 The custom light position
  110515. */
  110516. getCustomMeshPosition(): Vector3;
  110517. /**
  110518. * Disposes the internal assets and detaches the post-process from the camera
  110519. */
  110520. dispose(camera: Camera): void;
  110521. /**
  110522. * Returns the render target texture used by the post-process
  110523. * @return the render target texture used by the post-process
  110524. */
  110525. getPass(): RenderTargetTexture;
  110526. private _meshExcluded;
  110527. private _createPass;
  110528. private _updateMeshScreenCoordinates;
  110529. /**
  110530. * Creates a default mesh for the Volumeric Light Scattering post-process
  110531. * @param name The mesh name
  110532. * @param scene The scene where to create the mesh
  110533. * @return the default mesh
  110534. */
  110535. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  110536. }
  110537. }
  110538. declare module BABYLON {
  110539. interface Scene {
  110540. /** @hidden (Backing field) */
  110541. _boundingBoxRenderer: BoundingBoxRenderer;
  110542. /** @hidden (Backing field) */
  110543. _forceShowBoundingBoxes: boolean;
  110544. /**
  110545. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  110546. */
  110547. forceShowBoundingBoxes: boolean;
  110548. /**
  110549. * Gets the bounding box renderer associated with the scene
  110550. * @returns a BoundingBoxRenderer
  110551. */
  110552. getBoundingBoxRenderer(): BoundingBoxRenderer;
  110553. }
  110554. interface AbstractMesh {
  110555. /** @hidden (Backing field) */
  110556. _showBoundingBox: boolean;
  110557. /**
  110558. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  110559. */
  110560. showBoundingBox: boolean;
  110561. }
  110562. /**
  110563. * Component responsible of rendering the bounding box of the meshes in a scene.
  110564. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  110565. */
  110566. export class BoundingBoxRenderer implements ISceneComponent {
  110567. /**
  110568. * The component name helpfull to identify the component in the list of scene components.
  110569. */
  110570. readonly name: string;
  110571. /**
  110572. * The scene the component belongs to.
  110573. */
  110574. scene: Scene;
  110575. /**
  110576. * Color of the bounding box lines placed in front of an object
  110577. */
  110578. frontColor: Color3;
  110579. /**
  110580. * Color of the bounding box lines placed behind an object
  110581. */
  110582. backColor: Color3;
  110583. /**
  110584. * Defines if the renderer should show the back lines or not
  110585. */
  110586. showBackLines: boolean;
  110587. /**
  110588. * @hidden
  110589. */
  110590. renderList: SmartArray<BoundingBox>;
  110591. private _colorShader;
  110592. private _vertexBuffers;
  110593. private _indexBuffer;
  110594. /**
  110595. * Instantiates a new bounding box renderer in a scene.
  110596. * @param scene the scene the renderer renders in
  110597. */
  110598. constructor(scene: Scene);
  110599. /**
  110600. * Registers the component in a given scene
  110601. */
  110602. register(): void;
  110603. private _evaluateSubMesh;
  110604. private _activeMesh;
  110605. private _prepareRessources;
  110606. private _createIndexBuffer;
  110607. /**
  110608. * Rebuilds the elements related to this component in case of
  110609. * context lost for instance.
  110610. */
  110611. rebuild(): void;
  110612. /**
  110613. * @hidden
  110614. */
  110615. reset(): void;
  110616. /**
  110617. * Render the bounding boxes of a specific rendering group
  110618. * @param renderingGroupId defines the rendering group to render
  110619. */
  110620. render(renderingGroupId: number): void;
  110621. /**
  110622. * In case of occlusion queries, we can render the occlusion bounding box through this method
  110623. * @param mesh Define the mesh to render the occlusion bounding box for
  110624. */
  110625. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  110626. /**
  110627. * Dispose and release the resources attached to this renderer.
  110628. */
  110629. dispose(): void;
  110630. }
  110631. }
  110632. declare module BABYLON {
  110633. /** @hidden */
  110634. export var depthPixelShader: {
  110635. name: string;
  110636. shader: string;
  110637. };
  110638. }
  110639. declare module BABYLON {
  110640. /**
  110641. * This represents a depth renderer in Babylon.
  110642. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  110643. */
  110644. export class DepthRenderer {
  110645. private _scene;
  110646. private _depthMap;
  110647. private _effect;
  110648. private _cachedDefines;
  110649. private _camera;
  110650. /**
  110651. * Specifiess that the depth renderer will only be used within
  110652. * the camera it is created for.
  110653. * This can help forcing its rendering during the camera processing.
  110654. */
  110655. useOnlyInActiveCamera: boolean;
  110656. /** @hidden */
  110657. static _SceneComponentInitialization: (scene: Scene) => void;
  110658. /**
  110659. * Instantiates a depth renderer
  110660. * @param scene The scene the renderer belongs to
  110661. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  110662. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  110663. */
  110664. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  110665. /**
  110666. * Creates the depth rendering effect and checks if the effect is ready.
  110667. * @param subMesh The submesh to be used to render the depth map of
  110668. * @param useInstances If multiple world instances should be used
  110669. * @returns if the depth renderer is ready to render the depth map
  110670. */
  110671. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110672. /**
  110673. * Gets the texture which the depth map will be written to.
  110674. * @returns The depth map texture
  110675. */
  110676. getDepthMap(): RenderTargetTexture;
  110677. /**
  110678. * Disposes of the depth renderer.
  110679. */
  110680. dispose(): void;
  110681. }
  110682. }
  110683. declare module BABYLON {
  110684. interface Scene {
  110685. /** @hidden (Backing field) */
  110686. _depthRenderer: {
  110687. [id: string]: DepthRenderer;
  110688. };
  110689. /**
  110690. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  110691. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  110692. * @returns the created depth renderer
  110693. */
  110694. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  110695. /**
  110696. * Disables a depth renderer for a given camera
  110697. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  110698. */
  110699. disableDepthRenderer(camera?: Nullable<Camera>): void;
  110700. }
  110701. /**
  110702. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  110703. * in several rendering techniques.
  110704. */
  110705. export class DepthRendererSceneComponent implements ISceneComponent {
  110706. /**
  110707. * The component name helpfull to identify the component in the list of scene components.
  110708. */
  110709. readonly name: string;
  110710. /**
  110711. * The scene the component belongs to.
  110712. */
  110713. scene: Scene;
  110714. /**
  110715. * Creates a new instance of the component for the given scene
  110716. * @param scene Defines the scene to register the component in
  110717. */
  110718. constructor(scene: Scene);
  110719. /**
  110720. * Registers the component in a given scene
  110721. */
  110722. register(): void;
  110723. /**
  110724. * Rebuilds the elements related to this component in case of
  110725. * context lost for instance.
  110726. */
  110727. rebuild(): void;
  110728. /**
  110729. * Disposes the component and the associated ressources
  110730. */
  110731. dispose(): void;
  110732. private _gatherRenderTargets;
  110733. private _gatherActiveCameraRenderTargets;
  110734. }
  110735. }
  110736. declare module BABYLON {
  110737. /** @hidden */
  110738. export var outlinePixelShader: {
  110739. name: string;
  110740. shader: string;
  110741. };
  110742. }
  110743. declare module BABYLON {
  110744. /** @hidden */
  110745. export var outlineVertexShader: {
  110746. name: string;
  110747. shader: string;
  110748. };
  110749. }
  110750. declare module BABYLON {
  110751. interface Scene {
  110752. /** @hidden */
  110753. _outlineRenderer: OutlineRenderer;
  110754. /**
  110755. * Gets the outline renderer associated with the scene
  110756. * @returns a OutlineRenderer
  110757. */
  110758. getOutlineRenderer(): OutlineRenderer;
  110759. }
  110760. interface AbstractMesh {
  110761. /** @hidden (Backing field) */
  110762. _renderOutline: boolean;
  110763. /**
  110764. * Gets or sets a boolean indicating if the outline must be rendered as well
  110765. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  110766. */
  110767. renderOutline: boolean;
  110768. /** @hidden (Backing field) */
  110769. _renderOverlay: boolean;
  110770. /**
  110771. * Gets or sets a boolean indicating if the overlay must be rendered as well
  110772. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  110773. */
  110774. renderOverlay: boolean;
  110775. }
  110776. /**
  110777. * This class is responsible to draw bothe outline/overlay of meshes.
  110778. * It should not be used directly but through the available method on mesh.
  110779. */
  110780. export class OutlineRenderer implements ISceneComponent {
  110781. /**
  110782. * The name of the component. Each component must have a unique name.
  110783. */
  110784. name: string;
  110785. /**
  110786. * The scene the component belongs to.
  110787. */
  110788. scene: Scene;
  110789. /**
  110790. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  110791. */
  110792. zOffset: number;
  110793. private _engine;
  110794. private _effect;
  110795. private _cachedDefines;
  110796. private _savedDepthWrite;
  110797. /**
  110798. * Instantiates a new outline renderer. (There could be only one per scene).
  110799. * @param scene Defines the scene it belongs to
  110800. */
  110801. constructor(scene: Scene);
  110802. /**
  110803. * Register the component to one instance of a scene.
  110804. */
  110805. register(): void;
  110806. /**
  110807. * Rebuilds the elements related to this component in case of
  110808. * context lost for instance.
  110809. */
  110810. rebuild(): void;
  110811. /**
  110812. * Disposes the component and the associated ressources.
  110813. */
  110814. dispose(): void;
  110815. /**
  110816. * Renders the outline in the canvas.
  110817. * @param subMesh Defines the sumesh to render
  110818. * @param batch Defines the batch of meshes in case of instances
  110819. * @param useOverlay Defines if the rendering is for the overlay or the outline
  110820. */
  110821. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  110822. /**
  110823. * Returns whether or not the outline renderer is ready for a given submesh.
  110824. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  110825. * @param subMesh Defines the submesh to check readyness for
  110826. * @param useInstances Defines wheter wee are trying to render instances or not
  110827. * @returns true if ready otherwise false
  110828. */
  110829. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110830. private _beforeRenderingMesh;
  110831. private _afterRenderingMesh;
  110832. }
  110833. }
  110834. declare module BABYLON {
  110835. /**
  110836. * Defines the list of states available for a task inside a AssetsManager
  110837. */
  110838. export enum AssetTaskState {
  110839. /**
  110840. * Initialization
  110841. */
  110842. INIT = 0,
  110843. /**
  110844. * Running
  110845. */
  110846. RUNNING = 1,
  110847. /**
  110848. * Done
  110849. */
  110850. DONE = 2,
  110851. /**
  110852. * Error
  110853. */
  110854. ERROR = 3
  110855. }
  110856. /**
  110857. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  110858. */
  110859. export abstract class AbstractAssetTask {
  110860. /**
  110861. * Task name
  110862. */ name: string;
  110863. /**
  110864. * Callback called when the task is successful
  110865. */
  110866. onSuccess: (task: any) => void;
  110867. /**
  110868. * Callback called when the task is not successful
  110869. */
  110870. onError: (task: any, message?: string, exception?: any) => void;
  110871. /**
  110872. * Creates a new AssetsManager
  110873. * @param name defines the name of the task
  110874. */
  110875. constructor(
  110876. /**
  110877. * Task name
  110878. */ name: string);
  110879. private _isCompleted;
  110880. private _taskState;
  110881. private _errorObject;
  110882. /**
  110883. * Get if the task is completed
  110884. */
  110885. readonly isCompleted: boolean;
  110886. /**
  110887. * Gets the current state of the task
  110888. */
  110889. readonly taskState: AssetTaskState;
  110890. /**
  110891. * Gets the current error object (if task is in error)
  110892. */
  110893. readonly errorObject: {
  110894. message?: string;
  110895. exception?: any;
  110896. };
  110897. /**
  110898. * Internal only
  110899. * @hidden
  110900. */
  110901. _setErrorObject(message?: string, exception?: any): void;
  110902. /**
  110903. * Execute the current task
  110904. * @param scene defines the scene where you want your assets to be loaded
  110905. * @param onSuccess is a callback called when the task is successfully executed
  110906. * @param onError is a callback called if an error occurs
  110907. */
  110908. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110909. /**
  110910. * Execute the current task
  110911. * @param scene defines the scene where you want your assets to be loaded
  110912. * @param onSuccess is a callback called when the task is successfully executed
  110913. * @param onError is a callback called if an error occurs
  110914. */
  110915. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110916. /**
  110917. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  110918. * This can be used with failed tasks that have the reason for failure fixed.
  110919. */
  110920. reset(): void;
  110921. private onErrorCallback;
  110922. private onDoneCallback;
  110923. }
  110924. /**
  110925. * Define the interface used by progress events raised during assets loading
  110926. */
  110927. export interface IAssetsProgressEvent {
  110928. /**
  110929. * Defines the number of remaining tasks to process
  110930. */
  110931. remainingCount: number;
  110932. /**
  110933. * Defines the total number of tasks
  110934. */
  110935. totalCount: number;
  110936. /**
  110937. * Defines the task that was just processed
  110938. */
  110939. task: AbstractAssetTask;
  110940. }
  110941. /**
  110942. * Class used to share progress information about assets loading
  110943. */
  110944. export class AssetsProgressEvent implements IAssetsProgressEvent {
  110945. /**
  110946. * Defines the number of remaining tasks to process
  110947. */
  110948. remainingCount: number;
  110949. /**
  110950. * Defines the total number of tasks
  110951. */
  110952. totalCount: number;
  110953. /**
  110954. * Defines the task that was just processed
  110955. */
  110956. task: AbstractAssetTask;
  110957. /**
  110958. * Creates a AssetsProgressEvent
  110959. * @param remainingCount defines the number of remaining tasks to process
  110960. * @param totalCount defines the total number of tasks
  110961. * @param task defines the task that was just processed
  110962. */
  110963. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  110964. }
  110965. /**
  110966. * Define a task used by AssetsManager to load meshes
  110967. */
  110968. export class MeshAssetTask extends AbstractAssetTask {
  110969. /**
  110970. * Defines the name of the task
  110971. */
  110972. name: string;
  110973. /**
  110974. * Defines the list of mesh's names you want to load
  110975. */
  110976. meshesNames: any;
  110977. /**
  110978. * Defines the root url to use as a base to load your meshes and associated resources
  110979. */
  110980. rootUrl: string;
  110981. /**
  110982. * Defines the filename of the scene to load from
  110983. */
  110984. sceneFilename: string;
  110985. /**
  110986. * Gets the list of loaded meshes
  110987. */
  110988. loadedMeshes: Array<AbstractMesh>;
  110989. /**
  110990. * Gets the list of loaded particle systems
  110991. */
  110992. loadedParticleSystems: Array<IParticleSystem>;
  110993. /**
  110994. * Gets the list of loaded skeletons
  110995. */
  110996. loadedSkeletons: Array<Skeleton>;
  110997. /**
  110998. * Gets the list of loaded animation groups
  110999. */
  111000. loadedAnimationGroups: Array<AnimationGroup>;
  111001. /**
  111002. * Callback called when the task is successful
  111003. */
  111004. onSuccess: (task: MeshAssetTask) => void;
  111005. /**
  111006. * Callback called when the task is successful
  111007. */
  111008. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  111009. /**
  111010. * Creates a new MeshAssetTask
  111011. * @param name defines the name of the task
  111012. * @param meshesNames defines the list of mesh's names you want to load
  111013. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  111014. * @param sceneFilename defines the filename of the scene to load from
  111015. */
  111016. constructor(
  111017. /**
  111018. * Defines the name of the task
  111019. */
  111020. name: string,
  111021. /**
  111022. * Defines the list of mesh's names you want to load
  111023. */
  111024. meshesNames: any,
  111025. /**
  111026. * Defines the root url to use as a base to load your meshes and associated resources
  111027. */
  111028. rootUrl: string,
  111029. /**
  111030. * Defines the filename of the scene to load from
  111031. */
  111032. sceneFilename: string);
  111033. /**
  111034. * Execute the current task
  111035. * @param scene defines the scene where you want your assets to be loaded
  111036. * @param onSuccess is a callback called when the task is successfully executed
  111037. * @param onError is a callback called if an error occurs
  111038. */
  111039. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  111040. }
  111041. /**
  111042. * Define a task used by AssetsManager to load text content
  111043. */
  111044. export class TextFileAssetTask extends AbstractAssetTask {
  111045. /**
  111046. * Defines the name of the task
  111047. */
  111048. name: string;
  111049. /**
  111050. * Defines the location of the file to load
  111051. */
  111052. url: string;
  111053. /**
  111054. * Gets the loaded text string
  111055. */
  111056. text: string;
  111057. /**
  111058. * Callback called when the task is successful
  111059. */
  111060. onSuccess: (task: TextFileAssetTask) => void;
  111061. /**
  111062. * Callback called when the task is successful
  111063. */
  111064. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  111065. /**
  111066. * Creates a new TextFileAssetTask object
  111067. * @param name defines the name of the task
  111068. * @param url defines the location of the file to load
  111069. */
  111070. constructor(
  111071. /**
  111072. * Defines the name of the task
  111073. */
  111074. name: string,
  111075. /**
  111076. * Defines the location of the file to load
  111077. */
  111078. url: string);
  111079. /**
  111080. * Execute the current task
  111081. * @param scene defines the scene where you want your assets to be loaded
  111082. * @param onSuccess is a callback called when the task is successfully executed
  111083. * @param onError is a callback called if an error occurs
  111084. */
  111085. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  111086. }
  111087. /**
  111088. * Define a task used by AssetsManager to load binary data
  111089. */
  111090. export class BinaryFileAssetTask extends AbstractAssetTask {
  111091. /**
  111092. * Defines the name of the task
  111093. */
  111094. name: string;
  111095. /**
  111096. * Defines the location of the file to load
  111097. */
  111098. url: string;
  111099. /**
  111100. * Gets the lodaded data (as an array buffer)
  111101. */
  111102. data: ArrayBuffer;
  111103. /**
  111104. * Callback called when the task is successful
  111105. */
  111106. onSuccess: (task: BinaryFileAssetTask) => void;
  111107. /**
  111108. * Callback called when the task is successful
  111109. */
  111110. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  111111. /**
  111112. * Creates a new BinaryFileAssetTask object
  111113. * @param name defines the name of the new task
  111114. * @param url defines the location of the file to load
  111115. */
  111116. constructor(
  111117. /**
  111118. * Defines the name of the task
  111119. */
  111120. name: string,
  111121. /**
  111122. * Defines the location of the file to load
  111123. */
  111124. url: string);
  111125. /**
  111126. * Execute the current task
  111127. * @param scene defines the scene where you want your assets to be loaded
  111128. * @param onSuccess is a callback called when the task is successfully executed
  111129. * @param onError is a callback called if an error occurs
  111130. */
  111131. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  111132. }
  111133. /**
  111134. * Define a task used by AssetsManager to load images
  111135. */
  111136. export class ImageAssetTask extends AbstractAssetTask {
  111137. /**
  111138. * Defines the name of the task
  111139. */
  111140. name: string;
  111141. /**
  111142. * Defines the location of the image to load
  111143. */
  111144. url: string;
  111145. /**
  111146. * Gets the loaded images
  111147. */
  111148. image: HTMLImageElement;
  111149. /**
  111150. * Callback called when the task is successful
  111151. */
  111152. onSuccess: (task: ImageAssetTask) => void;
  111153. /**
  111154. * Callback called when the task is successful
  111155. */
  111156. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  111157. /**
  111158. * Creates a new ImageAssetTask
  111159. * @param name defines the name of the task
  111160. * @param url defines the location of the image to load
  111161. */
  111162. constructor(
  111163. /**
  111164. * Defines the name of the task
  111165. */
  111166. name: string,
  111167. /**
  111168. * Defines the location of the image to load
  111169. */
  111170. url: string);
  111171. /**
  111172. * Execute the current task
  111173. * @param scene defines the scene where you want your assets to be loaded
  111174. * @param onSuccess is a callback called when the task is successfully executed
  111175. * @param onError is a callback called if an error occurs
  111176. */
  111177. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  111178. }
  111179. /**
  111180. * Defines the interface used by texture loading tasks
  111181. */
  111182. export interface ITextureAssetTask<TEX extends BaseTexture> {
  111183. /**
  111184. * Gets the loaded texture
  111185. */
  111186. texture: TEX;
  111187. }
  111188. /**
  111189. * Define a task used by AssetsManager to load 2D textures
  111190. */
  111191. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  111192. /**
  111193. * Defines the name of the task
  111194. */
  111195. name: string;
  111196. /**
  111197. * Defines the location of the file to load
  111198. */
  111199. url: string;
  111200. /**
  111201. * Defines if mipmap should not be generated (default is false)
  111202. */
  111203. noMipmap?: boolean | undefined;
  111204. /**
  111205. * Defines if texture must be inverted on Y axis (default is false)
  111206. */
  111207. invertY?: boolean | undefined;
  111208. /**
  111209. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  111210. */
  111211. samplingMode: number;
  111212. /**
  111213. * Gets the loaded texture
  111214. */
  111215. texture: Texture;
  111216. /**
  111217. * Callback called when the task is successful
  111218. */
  111219. onSuccess: (task: TextureAssetTask) => void;
  111220. /**
  111221. * Callback called when the task is successful
  111222. */
  111223. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  111224. /**
  111225. * Creates a new TextureAssetTask object
  111226. * @param name defines the name of the task
  111227. * @param url defines the location of the file to load
  111228. * @param noMipmap defines if mipmap should not be generated (default is false)
  111229. * @param invertY defines if texture must be inverted on Y axis (default is false)
  111230. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  111231. */
  111232. constructor(
  111233. /**
  111234. * Defines the name of the task
  111235. */
  111236. name: string,
  111237. /**
  111238. * Defines the location of the file to load
  111239. */
  111240. url: string,
  111241. /**
  111242. * Defines if mipmap should not be generated (default is false)
  111243. */
  111244. noMipmap?: boolean | undefined,
  111245. /**
  111246. * Defines if texture must be inverted on Y axis (default is false)
  111247. */
  111248. invertY?: boolean | undefined,
  111249. /**
  111250. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  111251. */
  111252. samplingMode?: number);
  111253. /**
  111254. * Execute the current task
  111255. * @param scene defines the scene where you want your assets to be loaded
  111256. * @param onSuccess is a callback called when the task is successfully executed
  111257. * @param onError is a callback called if an error occurs
  111258. */
  111259. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  111260. }
  111261. /**
  111262. * Define a task used by AssetsManager to load cube textures
  111263. */
  111264. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  111265. /**
  111266. * Defines the name of the task
  111267. */
  111268. name: string;
  111269. /**
  111270. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  111271. */
  111272. url: string;
  111273. /**
  111274. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  111275. */
  111276. extensions?: string[] | undefined;
  111277. /**
  111278. * Defines if mipmaps should not be generated (default is false)
  111279. */
  111280. noMipmap?: boolean | undefined;
  111281. /**
  111282. * Defines the explicit list of files (undefined by default)
  111283. */
  111284. files?: string[] | undefined;
  111285. /**
  111286. * Gets the loaded texture
  111287. */
  111288. texture: CubeTexture;
  111289. /**
  111290. * Callback called when the task is successful
  111291. */
  111292. onSuccess: (task: CubeTextureAssetTask) => void;
  111293. /**
  111294. * Callback called when the task is successful
  111295. */
  111296. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  111297. /**
  111298. * Creates a new CubeTextureAssetTask
  111299. * @param name defines the name of the task
  111300. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  111301. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  111302. * @param noMipmap defines if mipmaps should not be generated (default is false)
  111303. * @param files defines the explicit list of files (undefined by default)
  111304. */
  111305. constructor(
  111306. /**
  111307. * Defines the name of the task
  111308. */
  111309. name: string,
  111310. /**
  111311. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  111312. */
  111313. url: string,
  111314. /**
  111315. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  111316. */
  111317. extensions?: string[] | undefined,
  111318. /**
  111319. * Defines if mipmaps should not be generated (default is false)
  111320. */
  111321. noMipmap?: boolean | undefined,
  111322. /**
  111323. * Defines the explicit list of files (undefined by default)
  111324. */
  111325. files?: string[] | undefined);
  111326. /**
  111327. * Execute the current task
  111328. * @param scene defines the scene where you want your assets to be loaded
  111329. * @param onSuccess is a callback called when the task is successfully executed
  111330. * @param onError is a callback called if an error occurs
  111331. */
  111332. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  111333. }
  111334. /**
  111335. * Define a task used by AssetsManager to load HDR cube textures
  111336. */
  111337. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  111338. /**
  111339. * Defines the name of the task
  111340. */
  111341. name: string;
  111342. /**
  111343. * Defines the location of the file to load
  111344. */
  111345. url: string;
  111346. /**
  111347. * Defines the desired size (the more it increases the longer the generation will be)
  111348. */
  111349. size: number;
  111350. /**
  111351. * Defines if mipmaps should not be generated (default is false)
  111352. */
  111353. noMipmap: boolean;
  111354. /**
  111355. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  111356. */
  111357. generateHarmonics: boolean;
  111358. /**
  111359. * 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)
  111360. */
  111361. gammaSpace: boolean;
  111362. /**
  111363. * Internal Use Only
  111364. */
  111365. reserved: boolean;
  111366. /**
  111367. * Gets the loaded texture
  111368. */
  111369. texture: HDRCubeTexture;
  111370. /**
  111371. * Callback called when the task is successful
  111372. */
  111373. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  111374. /**
  111375. * Callback called when the task is successful
  111376. */
  111377. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  111378. /**
  111379. * Creates a new HDRCubeTextureAssetTask object
  111380. * @param name defines the name of the task
  111381. * @param url defines the location of the file to load
  111382. * @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.
  111383. * @param noMipmap defines if mipmaps should not be generated (default is false)
  111384. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  111385. * @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)
  111386. * @param reserved Internal use only
  111387. */
  111388. constructor(
  111389. /**
  111390. * Defines the name of the task
  111391. */
  111392. name: string,
  111393. /**
  111394. * Defines the location of the file to load
  111395. */
  111396. url: string,
  111397. /**
  111398. * Defines the desired size (the more it increases the longer the generation will be)
  111399. */
  111400. size: number,
  111401. /**
  111402. * Defines if mipmaps should not be generated (default is false)
  111403. */
  111404. noMipmap?: boolean,
  111405. /**
  111406. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  111407. */
  111408. generateHarmonics?: boolean,
  111409. /**
  111410. * 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)
  111411. */
  111412. gammaSpace?: boolean,
  111413. /**
  111414. * Internal Use Only
  111415. */
  111416. reserved?: boolean);
  111417. /**
  111418. * Execute the current task
  111419. * @param scene defines the scene where you want your assets to be loaded
  111420. * @param onSuccess is a callback called when the task is successfully executed
  111421. * @param onError is a callback called if an error occurs
  111422. */
  111423. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  111424. }
  111425. /**
  111426. * This class can be used to easily import assets into a scene
  111427. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  111428. */
  111429. export class AssetsManager {
  111430. private _scene;
  111431. private _isLoading;
  111432. protected _tasks: AbstractAssetTask[];
  111433. protected _waitingTasksCount: number;
  111434. protected _totalTasksCount: number;
  111435. /**
  111436. * Callback called when all tasks are processed
  111437. */
  111438. onFinish: (tasks: AbstractAssetTask[]) => void;
  111439. /**
  111440. * Callback called when a task is successful
  111441. */
  111442. onTaskSuccess: (task: AbstractAssetTask) => void;
  111443. /**
  111444. * Callback called when a task had an error
  111445. */
  111446. onTaskError: (task: AbstractAssetTask) => void;
  111447. /**
  111448. * Callback called when a task is done (whatever the result is)
  111449. */
  111450. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  111451. /**
  111452. * Observable called when all tasks are processed
  111453. */
  111454. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  111455. /**
  111456. * Observable called when a task had an error
  111457. */
  111458. onTaskErrorObservable: Observable<AbstractAssetTask>;
  111459. /**
  111460. * Observable called when all tasks were executed
  111461. */
  111462. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  111463. /**
  111464. * Observable called when a task is done (whatever the result is)
  111465. */
  111466. onProgressObservable: Observable<IAssetsProgressEvent>;
  111467. /**
  111468. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  111469. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  111470. */
  111471. useDefaultLoadingScreen: boolean;
  111472. /**
  111473. * Creates a new AssetsManager
  111474. * @param scene defines the scene to work on
  111475. */
  111476. constructor(scene: Scene);
  111477. /**
  111478. * Add a MeshAssetTask to the list of active tasks
  111479. * @param taskName defines the name of the new task
  111480. * @param meshesNames defines the name of meshes to load
  111481. * @param rootUrl defines the root url to use to locate files
  111482. * @param sceneFilename defines the filename of the scene file
  111483. * @returns a new MeshAssetTask object
  111484. */
  111485. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  111486. /**
  111487. * Add a TextFileAssetTask to the list of active tasks
  111488. * @param taskName defines the name of the new task
  111489. * @param url defines the url of the file to load
  111490. * @returns a new TextFileAssetTask object
  111491. */
  111492. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  111493. /**
  111494. * Add a BinaryFileAssetTask to the list of active tasks
  111495. * @param taskName defines the name of the new task
  111496. * @param url defines the url of the file to load
  111497. * @returns a new BinaryFileAssetTask object
  111498. */
  111499. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  111500. /**
  111501. * Add a ImageAssetTask to the list of active tasks
  111502. * @param taskName defines the name of the new task
  111503. * @param url defines the url of the file to load
  111504. * @returns a new ImageAssetTask object
  111505. */
  111506. addImageTask(taskName: string, url: string): ImageAssetTask;
  111507. /**
  111508. * Add a TextureAssetTask to the list of active tasks
  111509. * @param taskName defines the name of the new task
  111510. * @param url defines the url of the file to load
  111511. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  111512. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  111513. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  111514. * @returns a new TextureAssetTask object
  111515. */
  111516. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  111517. /**
  111518. * Add a CubeTextureAssetTask to the list of active tasks
  111519. * @param taskName defines the name of the new task
  111520. * @param url defines the url of the file to load
  111521. * @param extensions defines the extension to use to load the cube map (can be null)
  111522. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  111523. * @param files defines the list of files to load (can be null)
  111524. * @returns a new CubeTextureAssetTask object
  111525. */
  111526. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  111527. /**
  111528. *
  111529. * Add a HDRCubeTextureAssetTask to the list of active tasks
  111530. * @param taskName defines the name of the new task
  111531. * @param url defines the url of the file to load
  111532. * @param size defines the size you want for the cubemap (can be null)
  111533. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  111534. * @param generateHarmonics defines if you want to automatically generate (true by default)
  111535. * @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)
  111536. * @param reserved Internal use only
  111537. * @returns a new HDRCubeTextureAssetTask object
  111538. */
  111539. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  111540. /**
  111541. * Remove a task from the assets manager.
  111542. * @param task the task to remove
  111543. */
  111544. removeTask(task: AbstractAssetTask): void;
  111545. private _decreaseWaitingTasksCount;
  111546. private _runTask;
  111547. /**
  111548. * Reset the AssetsManager and remove all tasks
  111549. * @return the current instance of the AssetsManager
  111550. */
  111551. reset(): AssetsManager;
  111552. /**
  111553. * Start the loading process
  111554. * @return the current instance of the AssetsManager
  111555. */
  111556. load(): AssetsManager;
  111557. /**
  111558. * Start the loading process as an async operation
  111559. * @return a promise returning the list of failed tasks
  111560. */
  111561. loadAsync(): Promise<void>;
  111562. }
  111563. }
  111564. declare module BABYLON {
  111565. /**
  111566. * Wrapper class for promise with external resolve and reject.
  111567. */
  111568. export class Deferred<T> {
  111569. /**
  111570. * The promise associated with this deferred object.
  111571. */
  111572. readonly promise: Promise<T>;
  111573. private _resolve;
  111574. private _reject;
  111575. /**
  111576. * The resolve method of the promise associated with this deferred object.
  111577. */
  111578. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  111579. /**
  111580. * The reject method of the promise associated with this deferred object.
  111581. */
  111582. readonly reject: (reason?: any) => void;
  111583. /**
  111584. * Constructor for this deferred object.
  111585. */
  111586. constructor();
  111587. }
  111588. }
  111589. declare module BABYLON {
  111590. /**
  111591. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  111592. */
  111593. export class MeshExploder {
  111594. private _centerMesh;
  111595. private _meshes;
  111596. private _meshesOrigins;
  111597. private _toCenterVectors;
  111598. private _scaledDirection;
  111599. private _newPosition;
  111600. private _centerPosition;
  111601. /**
  111602. * Explodes meshes from a center mesh.
  111603. * @param meshes The meshes to explode.
  111604. * @param centerMesh The mesh to be center of explosion.
  111605. */
  111606. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  111607. private _setCenterMesh;
  111608. /**
  111609. * Get class name
  111610. * @returns "MeshExploder"
  111611. */
  111612. getClassName(): string;
  111613. /**
  111614. * "Exploded meshes"
  111615. * @returns Array of meshes with the centerMesh at index 0.
  111616. */
  111617. getMeshes(): Array<Mesh>;
  111618. /**
  111619. * Explodes meshes giving a specific direction
  111620. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  111621. */
  111622. explode(direction?: number): void;
  111623. }
  111624. }
  111625. declare module BABYLON {
  111626. /**
  111627. * Class used to help managing file picking and drag'n'drop
  111628. */
  111629. export class FilesInput {
  111630. /**
  111631. * List of files ready to be loaded
  111632. */
  111633. static readonly FilesToLoad: {
  111634. [key: string]: File;
  111635. };
  111636. /**
  111637. * Callback called when a file is processed
  111638. */
  111639. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  111640. private _engine;
  111641. private _currentScene;
  111642. private _sceneLoadedCallback;
  111643. private _progressCallback;
  111644. private _additionalRenderLoopLogicCallback;
  111645. private _textureLoadingCallback;
  111646. private _startingProcessingFilesCallback;
  111647. private _onReloadCallback;
  111648. private _errorCallback;
  111649. private _elementToMonitor;
  111650. private _sceneFileToLoad;
  111651. private _filesToLoad;
  111652. /**
  111653. * Creates a new FilesInput
  111654. * @param engine defines the rendering engine
  111655. * @param scene defines the hosting scene
  111656. * @param sceneLoadedCallback callback called when scene is loaded
  111657. * @param progressCallback callback called to track progress
  111658. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  111659. * @param textureLoadingCallback callback called when a texture is loading
  111660. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  111661. * @param onReloadCallback callback called when a reload is requested
  111662. * @param errorCallback callback call if an error occurs
  111663. */
  111664. 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);
  111665. private _dragEnterHandler;
  111666. private _dragOverHandler;
  111667. private _dropHandler;
  111668. /**
  111669. * Calls this function to listen to drag'n'drop events on a specific DOM element
  111670. * @param elementToMonitor defines the DOM element to track
  111671. */
  111672. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  111673. /**
  111674. * Release all associated resources
  111675. */
  111676. dispose(): void;
  111677. private renderFunction;
  111678. private drag;
  111679. private drop;
  111680. private _traverseFolder;
  111681. private _processFiles;
  111682. /**
  111683. * Load files from a drop event
  111684. * @param event defines the drop event to use as source
  111685. */
  111686. loadFiles(event: any): void;
  111687. private _processReload;
  111688. /**
  111689. * Reload the current scene from the loaded files
  111690. */
  111691. reload(): void;
  111692. }
  111693. }
  111694. declare module BABYLON {
  111695. /**
  111696. * Defines the root class used to create scene optimization to use with SceneOptimizer
  111697. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111698. */
  111699. export class SceneOptimization {
  111700. /**
  111701. * Defines the priority of this optimization (0 by default which means first in the list)
  111702. */
  111703. priority: number;
  111704. /**
  111705. * Gets a string describing the action executed by the current optimization
  111706. * @returns description string
  111707. */
  111708. getDescription(): string;
  111709. /**
  111710. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111711. * @param scene defines the current scene where to apply this optimization
  111712. * @param optimizer defines the current optimizer
  111713. * @returns true if everything that can be done was applied
  111714. */
  111715. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111716. /**
  111717. * Creates the SceneOptimization object
  111718. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111719. * @param desc defines the description associated with the optimization
  111720. */
  111721. constructor(
  111722. /**
  111723. * Defines the priority of this optimization (0 by default which means first in the list)
  111724. */
  111725. priority?: number);
  111726. }
  111727. /**
  111728. * Defines an optimization used to reduce the size of render target textures
  111729. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111730. */
  111731. export class TextureOptimization extends SceneOptimization {
  111732. /**
  111733. * Defines the priority of this optimization (0 by default which means first in the list)
  111734. */
  111735. priority: number;
  111736. /**
  111737. * 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
  111738. */
  111739. maximumSize: number;
  111740. /**
  111741. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  111742. */
  111743. step: number;
  111744. /**
  111745. * Gets a string describing the action executed by the current optimization
  111746. * @returns description string
  111747. */
  111748. getDescription(): string;
  111749. /**
  111750. * Creates the TextureOptimization object
  111751. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111752. * @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
  111753. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  111754. */
  111755. constructor(
  111756. /**
  111757. * Defines the priority of this optimization (0 by default which means first in the list)
  111758. */
  111759. priority?: number,
  111760. /**
  111761. * 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
  111762. */
  111763. maximumSize?: number,
  111764. /**
  111765. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  111766. */
  111767. step?: number);
  111768. /**
  111769. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111770. * @param scene defines the current scene where to apply this optimization
  111771. * @param optimizer defines the current optimizer
  111772. * @returns true if everything that can be done was applied
  111773. */
  111774. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111775. }
  111776. /**
  111777. * Defines an optimization used to increase or decrease the rendering resolution
  111778. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111779. */
  111780. export class HardwareScalingOptimization extends SceneOptimization {
  111781. /**
  111782. * Defines the priority of this optimization (0 by default which means first in the list)
  111783. */
  111784. priority: number;
  111785. /**
  111786. * Defines the maximum scale to use (2 by default)
  111787. */
  111788. maximumScale: number;
  111789. /**
  111790. * Defines the step to use between two passes (0.5 by default)
  111791. */
  111792. step: number;
  111793. private _currentScale;
  111794. private _directionOffset;
  111795. /**
  111796. * Gets a string describing the action executed by the current optimization
  111797. * @return description string
  111798. */
  111799. getDescription(): string;
  111800. /**
  111801. * Creates the HardwareScalingOptimization object
  111802. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111803. * @param maximumScale defines the maximum scale to use (2 by default)
  111804. * @param step defines the step to use between two passes (0.5 by default)
  111805. */
  111806. constructor(
  111807. /**
  111808. * Defines the priority of this optimization (0 by default which means first in the list)
  111809. */
  111810. priority?: number,
  111811. /**
  111812. * Defines the maximum scale to use (2 by default)
  111813. */
  111814. maximumScale?: number,
  111815. /**
  111816. * Defines the step to use between two passes (0.5 by default)
  111817. */
  111818. step?: number);
  111819. /**
  111820. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111821. * @param scene defines the current scene where to apply this optimization
  111822. * @param optimizer defines the current optimizer
  111823. * @returns true if everything that can be done was applied
  111824. */
  111825. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111826. }
  111827. /**
  111828. * Defines an optimization used to remove shadows
  111829. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111830. */
  111831. export class ShadowsOptimization extends SceneOptimization {
  111832. /**
  111833. * Gets a string describing the action executed by the current optimization
  111834. * @return description string
  111835. */
  111836. getDescription(): string;
  111837. /**
  111838. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111839. * @param scene defines the current scene where to apply this optimization
  111840. * @param optimizer defines the current optimizer
  111841. * @returns true if everything that can be done was applied
  111842. */
  111843. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111844. }
  111845. /**
  111846. * Defines an optimization used to turn post-processes off
  111847. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111848. */
  111849. export class PostProcessesOptimization extends SceneOptimization {
  111850. /**
  111851. * Gets a string describing the action executed by the current optimization
  111852. * @return description string
  111853. */
  111854. getDescription(): string;
  111855. /**
  111856. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111857. * @param scene defines the current scene where to apply this optimization
  111858. * @param optimizer defines the current optimizer
  111859. * @returns true if everything that can be done was applied
  111860. */
  111861. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111862. }
  111863. /**
  111864. * Defines an optimization used to turn lens flares off
  111865. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111866. */
  111867. export class LensFlaresOptimization extends SceneOptimization {
  111868. /**
  111869. * Gets a string describing the action executed by the current optimization
  111870. * @return description string
  111871. */
  111872. getDescription(): string;
  111873. /**
  111874. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111875. * @param scene defines the current scene where to apply this optimization
  111876. * @param optimizer defines the current optimizer
  111877. * @returns true if everything that can be done was applied
  111878. */
  111879. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111880. }
  111881. /**
  111882. * Defines an optimization based on user defined callback.
  111883. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111884. */
  111885. export class CustomOptimization extends SceneOptimization {
  111886. /**
  111887. * Callback called to apply the custom optimization.
  111888. */
  111889. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  111890. /**
  111891. * Callback called to get custom description
  111892. */
  111893. onGetDescription: () => string;
  111894. /**
  111895. * Gets a string describing the action executed by the current optimization
  111896. * @returns description string
  111897. */
  111898. getDescription(): string;
  111899. /**
  111900. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111901. * @param scene defines the current scene where to apply this optimization
  111902. * @param optimizer defines the current optimizer
  111903. * @returns true if everything that can be done was applied
  111904. */
  111905. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111906. }
  111907. /**
  111908. * Defines an optimization used to turn particles off
  111909. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111910. */
  111911. export class ParticlesOptimization extends SceneOptimization {
  111912. /**
  111913. * Gets a string describing the action executed by the current optimization
  111914. * @return description string
  111915. */
  111916. getDescription(): string;
  111917. /**
  111918. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111919. * @param scene defines the current scene where to apply this optimization
  111920. * @param optimizer defines the current optimizer
  111921. * @returns true if everything that can be done was applied
  111922. */
  111923. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111924. }
  111925. /**
  111926. * Defines an optimization used to turn render targets off
  111927. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111928. */
  111929. export class RenderTargetsOptimization extends SceneOptimization {
  111930. /**
  111931. * Gets a string describing the action executed by the current optimization
  111932. * @return description string
  111933. */
  111934. getDescription(): string;
  111935. /**
  111936. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111937. * @param scene defines the current scene where to apply this optimization
  111938. * @param optimizer defines the current optimizer
  111939. * @returns true if everything that can be done was applied
  111940. */
  111941. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111942. }
  111943. /**
  111944. * Defines an optimization used to merge meshes with compatible materials
  111945. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111946. */
  111947. export class MergeMeshesOptimization extends SceneOptimization {
  111948. private static _UpdateSelectionTree;
  111949. /**
  111950. * Gets or sets a boolean which defines if optimization octree has to be updated
  111951. */
  111952. /**
  111953. * Gets or sets a boolean which defines if optimization octree has to be updated
  111954. */
  111955. static UpdateSelectionTree: boolean;
  111956. /**
  111957. * Gets a string describing the action executed by the current optimization
  111958. * @return description string
  111959. */
  111960. getDescription(): string;
  111961. private _canBeMerged;
  111962. /**
  111963. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111964. * @param scene defines the current scene where to apply this optimization
  111965. * @param optimizer defines the current optimizer
  111966. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  111967. * @returns true if everything that can be done was applied
  111968. */
  111969. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  111970. }
  111971. /**
  111972. * Defines a list of options used by SceneOptimizer
  111973. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111974. */
  111975. export class SceneOptimizerOptions {
  111976. /**
  111977. * Defines the target frame rate to reach (60 by default)
  111978. */
  111979. targetFrameRate: number;
  111980. /**
  111981. * Defines the interval between two checkes (2000ms by default)
  111982. */
  111983. trackerDuration: number;
  111984. /**
  111985. * Gets the list of optimizations to apply
  111986. */
  111987. optimizations: SceneOptimization[];
  111988. /**
  111989. * Creates a new list of options used by SceneOptimizer
  111990. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  111991. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  111992. */
  111993. constructor(
  111994. /**
  111995. * Defines the target frame rate to reach (60 by default)
  111996. */
  111997. targetFrameRate?: number,
  111998. /**
  111999. * Defines the interval between two checkes (2000ms by default)
  112000. */
  112001. trackerDuration?: number);
  112002. /**
  112003. * Add a new optimization
  112004. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  112005. * @returns the current SceneOptimizerOptions
  112006. */
  112007. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  112008. /**
  112009. * Add a new custom optimization
  112010. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  112011. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  112012. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  112013. * @returns the current SceneOptimizerOptions
  112014. */
  112015. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  112016. /**
  112017. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  112018. * @param targetFrameRate defines the target frame rate (60 by default)
  112019. * @returns a SceneOptimizerOptions object
  112020. */
  112021. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  112022. /**
  112023. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  112024. * @param targetFrameRate defines the target frame rate (60 by default)
  112025. * @returns a SceneOptimizerOptions object
  112026. */
  112027. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  112028. /**
  112029. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  112030. * @param targetFrameRate defines the target frame rate (60 by default)
  112031. * @returns a SceneOptimizerOptions object
  112032. */
  112033. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  112034. }
  112035. /**
  112036. * Class used to run optimizations in order to reach a target frame rate
  112037. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  112038. */
  112039. export class SceneOptimizer implements IDisposable {
  112040. private _isRunning;
  112041. private _options;
  112042. private _scene;
  112043. private _currentPriorityLevel;
  112044. private _targetFrameRate;
  112045. private _trackerDuration;
  112046. private _currentFrameRate;
  112047. private _sceneDisposeObserver;
  112048. private _improvementMode;
  112049. /**
  112050. * Defines an observable called when the optimizer reaches the target frame rate
  112051. */
  112052. onSuccessObservable: Observable<SceneOptimizer>;
  112053. /**
  112054. * Defines an observable called when the optimizer enables an optimization
  112055. */
  112056. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  112057. /**
  112058. * Defines an observable called when the optimizer is not able to reach the target frame rate
  112059. */
  112060. onFailureObservable: Observable<SceneOptimizer>;
  112061. /**
  112062. * Gets a boolean indicating if the optimizer is in improvement mode
  112063. */
  112064. readonly isInImprovementMode: boolean;
  112065. /**
  112066. * Gets the current priority level (0 at start)
  112067. */
  112068. readonly currentPriorityLevel: number;
  112069. /**
  112070. * Gets the current frame rate checked by the SceneOptimizer
  112071. */
  112072. readonly currentFrameRate: number;
  112073. /**
  112074. * Gets or sets the current target frame rate (60 by default)
  112075. */
  112076. /**
  112077. * Gets or sets the current target frame rate (60 by default)
  112078. */
  112079. targetFrameRate: number;
  112080. /**
  112081. * Gets or sets the current interval between two checks (every 2000ms by default)
  112082. */
  112083. /**
  112084. * Gets or sets the current interval between two checks (every 2000ms by default)
  112085. */
  112086. trackerDuration: number;
  112087. /**
  112088. * Gets the list of active optimizations
  112089. */
  112090. readonly optimizations: SceneOptimization[];
  112091. /**
  112092. * Creates a new SceneOptimizer
  112093. * @param scene defines the scene to work on
  112094. * @param options defines the options to use with the SceneOptimizer
  112095. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  112096. * @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)
  112097. */
  112098. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  112099. /**
  112100. * Stops the current optimizer
  112101. */
  112102. stop(): void;
  112103. /**
  112104. * Reset the optimizer to initial step (current priority level = 0)
  112105. */
  112106. reset(): void;
  112107. /**
  112108. * Start the optimizer. By default it will try to reach a specific framerate
  112109. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  112110. */
  112111. start(): void;
  112112. private _checkCurrentState;
  112113. /**
  112114. * Release all resources
  112115. */
  112116. dispose(): void;
  112117. /**
  112118. * Helper function to create a SceneOptimizer with one single line of code
  112119. * @param scene defines the scene to work on
  112120. * @param options defines the options to use with the SceneOptimizer
  112121. * @param onSuccess defines a callback to call on success
  112122. * @param onFailure defines a callback to call on failure
  112123. * @returns the new SceneOptimizer object
  112124. */
  112125. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  112126. }
  112127. }
  112128. declare module BABYLON {
  112129. /**
  112130. * Class used to serialize a scene into a string
  112131. */
  112132. export class SceneSerializer {
  112133. /**
  112134. * Clear cache used by a previous serialization
  112135. */
  112136. static ClearCache(): void;
  112137. /**
  112138. * Serialize a scene into a JSON compatible object
  112139. * @param scene defines the scene to serialize
  112140. * @returns a JSON compatible object
  112141. */
  112142. static Serialize(scene: Scene): any;
  112143. /**
  112144. * Serialize a mesh into a JSON compatible object
  112145. * @param toSerialize defines the mesh to serialize
  112146. * @param withParents defines if parents must be serialized as well
  112147. * @param withChildren defines if children must be serialized as well
  112148. * @returns a JSON compatible object
  112149. */
  112150. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  112151. }
  112152. }
  112153. declare module BABYLON {
  112154. /**
  112155. * This represents the different options avilable for the video capture.
  112156. */
  112157. export interface VideoRecorderOptions {
  112158. /** Defines the mime type of the video */
  112159. mimeType: string;
  112160. /** Defines the video the video should be recorded at */
  112161. fps: number;
  112162. /** Defines the chunk size for the recording data */
  112163. recordChunckSize: number;
  112164. /** The audio tracks to attach to the record */
  112165. audioTracks?: MediaStreamTrack[];
  112166. }
  112167. /**
  112168. * This can helps recording videos from BabylonJS.
  112169. * This is based on the available WebRTC functionalities of the browser.
  112170. *
  112171. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  112172. */
  112173. export class VideoRecorder {
  112174. private static readonly _defaultOptions;
  112175. /**
  112176. * Returns wehther or not the VideoRecorder is available in your browser.
  112177. * @param engine Defines the Babylon Engine to check the support for
  112178. * @returns true if supported otherwise false
  112179. */
  112180. static IsSupported(engine: Engine): boolean;
  112181. private readonly _options;
  112182. private _canvas;
  112183. private _mediaRecorder;
  112184. private _recordedChunks;
  112185. private _fileName;
  112186. private _resolve;
  112187. private _reject;
  112188. /**
  112189. * True wether a recording is already in progress.
  112190. */
  112191. readonly isRecording: boolean;
  112192. /**
  112193. * Create a new VideoCapture object which can help converting what you see in Babylon to
  112194. * a video file.
  112195. * @param engine Defines the BabylonJS Engine you wish to record
  112196. * @param options Defines options that can be used to customized the capture
  112197. */
  112198. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  112199. /**
  112200. * Stops the current recording before the default capture timeout passed in the startRecording
  112201. * functions.
  112202. */
  112203. stopRecording(): void;
  112204. /**
  112205. * Starts recording the canvas for a max duration specified in parameters.
  112206. * @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.
  112207. * @param maxDuration Defines the maximum recording time in seconds.
  112208. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  112209. * @return a promise callback at the end of the recording with the video data in Blob.
  112210. */
  112211. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  112212. /**
  112213. * Releases internal resources used during the recording.
  112214. */
  112215. dispose(): void;
  112216. private _handleDataAvailable;
  112217. private _handleError;
  112218. private _handleStop;
  112219. }
  112220. }
  112221. declare module BABYLON {
  112222. /**
  112223. * Helper class to push actions to a pool of workers.
  112224. */
  112225. export class WorkerPool implements IDisposable {
  112226. private _workerInfos;
  112227. private _pendingActions;
  112228. /**
  112229. * Constructor
  112230. * @param workers Array of workers to use for actions
  112231. */
  112232. constructor(workers: Array<Worker>);
  112233. /**
  112234. * Terminates all workers and clears any pending actions.
  112235. */
  112236. dispose(): void;
  112237. /**
  112238. * Pushes an action to the worker pool. If all the workers are active, the action will be
  112239. * pended until a worker has completed its action.
  112240. * @param action The action to perform. Call onComplete when the action is complete.
  112241. */
  112242. push(action: (worker: Worker, onComplete: () => void) => void): void;
  112243. private _execute;
  112244. }
  112245. }
  112246. declare module BABYLON {
  112247. /**
  112248. * Class containing a set of static utilities functions for screenshots
  112249. */
  112250. export class ScreenshotTools {
  112251. /**
  112252. * Captures a screenshot of the current rendering
  112253. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  112254. * @param engine defines the rendering engine
  112255. * @param camera defines the source camera
  112256. * @param size This parameter can be set to a single number or to an object with the
  112257. * following (optional) properties: precision, width, height. If a single number is passed,
  112258. * it will be used for both width and height. If an object is passed, the screenshot size
  112259. * will be derived from the parameters. The precision property is a multiplier allowing
  112260. * rendering at a higher or lower resolution
  112261. * @param successCallback defines the callback receives a single parameter which contains the
  112262. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  112263. * src parameter of an <img> to display it
  112264. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  112265. * Check your browser for supported MIME types
  112266. */
  112267. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  112268. /**
  112269. * Generates an image screenshot from the specified camera.
  112270. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  112271. * @param engine The engine to use for rendering
  112272. * @param camera The camera to use for rendering
  112273. * @param size This parameter can be set to a single number or to an object with the
  112274. * following (optional) properties: precision, width, height. If a single number is passed,
  112275. * it will be used for both width and height. If an object is passed, the screenshot size
  112276. * will be derived from the parameters. The precision property is a multiplier allowing
  112277. * rendering at a higher or lower resolution
  112278. * @param successCallback The callback receives a single parameter which contains the
  112279. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  112280. * src parameter of an <img> to display it
  112281. * @param mimeType The MIME type of the screenshot image (default: image/png).
  112282. * Check your browser for supported MIME types
  112283. * @param samples Texture samples (default: 1)
  112284. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  112285. * @param fileName A name for for the downloaded file.
  112286. */
  112287. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  112288. }
  112289. }
  112290. declare module BABYLON {
  112291. /**
  112292. * A cursor which tracks a point on a path
  112293. */
  112294. export class PathCursor {
  112295. private path;
  112296. /**
  112297. * Stores path cursor callbacks for when an onchange event is triggered
  112298. */
  112299. private _onchange;
  112300. /**
  112301. * The value of the path cursor
  112302. */
  112303. value: number;
  112304. /**
  112305. * The animation array of the path cursor
  112306. */
  112307. animations: Animation[];
  112308. /**
  112309. * Initializes the path cursor
  112310. * @param path The path to track
  112311. */
  112312. constructor(path: Path2);
  112313. /**
  112314. * Gets the cursor point on the path
  112315. * @returns A point on the path cursor at the cursor location
  112316. */
  112317. getPoint(): Vector3;
  112318. /**
  112319. * Moves the cursor ahead by the step amount
  112320. * @param step The amount to move the cursor forward
  112321. * @returns This path cursor
  112322. */
  112323. moveAhead(step?: number): PathCursor;
  112324. /**
  112325. * Moves the cursor behind by the step amount
  112326. * @param step The amount to move the cursor back
  112327. * @returns This path cursor
  112328. */
  112329. moveBack(step?: number): PathCursor;
  112330. /**
  112331. * Moves the cursor by the step amount
  112332. * If the step amount is greater than one, an exception is thrown
  112333. * @param step The amount to move the cursor
  112334. * @returns This path cursor
  112335. */
  112336. move(step: number): PathCursor;
  112337. /**
  112338. * Ensures that the value is limited between zero and one
  112339. * @returns This path cursor
  112340. */
  112341. private ensureLimits;
  112342. /**
  112343. * Runs onchange callbacks on change (used by the animation engine)
  112344. * @returns This path cursor
  112345. */
  112346. private raiseOnChange;
  112347. /**
  112348. * Executes a function on change
  112349. * @param f A path cursor onchange callback
  112350. * @returns This path cursor
  112351. */
  112352. onchange(f: (cursor: PathCursor) => void): PathCursor;
  112353. }
  112354. }
  112355. declare module BABYLON {
  112356. /** @hidden */
  112357. export var blurPixelShader: {
  112358. name: string;
  112359. shader: string;
  112360. };
  112361. }
  112362. declare module BABYLON {
  112363. /** @hidden */
  112364. export var bones300Declaration: {
  112365. name: string;
  112366. shader: string;
  112367. };
  112368. }
  112369. declare module BABYLON {
  112370. /** @hidden */
  112371. export var instances300Declaration: {
  112372. name: string;
  112373. shader: string;
  112374. };
  112375. }
  112376. declare module BABYLON {
  112377. /** @hidden */
  112378. export var pointCloudVertexDeclaration: {
  112379. name: string;
  112380. shader: string;
  112381. };
  112382. }
  112383. // Mixins
  112384. interface Window {
  112385. mozIndexedDB: IDBFactory;
  112386. webkitIndexedDB: IDBFactory;
  112387. msIndexedDB: IDBFactory;
  112388. webkitURL: typeof URL;
  112389. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  112390. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  112391. WebGLRenderingContext: WebGLRenderingContext;
  112392. MSGesture: MSGesture;
  112393. CANNON: any;
  112394. AudioContext: AudioContext;
  112395. webkitAudioContext: AudioContext;
  112396. PointerEvent: any;
  112397. Math: Math;
  112398. Uint8Array: Uint8ArrayConstructor;
  112399. Float32Array: Float32ArrayConstructor;
  112400. mozURL: typeof URL;
  112401. msURL: typeof URL;
  112402. VRFrameData: any; // WebVR, from specs 1.1
  112403. DracoDecoderModule: any;
  112404. setImmediate(handler: (...args: any[]) => void): number;
  112405. }
  112406. interface HTMLCanvasElement {
  112407. requestPointerLock(): void;
  112408. msRequestPointerLock?(): void;
  112409. mozRequestPointerLock?(): void;
  112410. webkitRequestPointerLock?(): void;
  112411. /** Track wether a record is in progress */
  112412. isRecording: boolean;
  112413. /** Capture Stream method defined by some browsers */
  112414. captureStream(fps?: number): MediaStream;
  112415. }
  112416. interface CanvasRenderingContext2D {
  112417. msImageSmoothingEnabled: boolean;
  112418. }
  112419. interface MouseEvent {
  112420. mozMovementX: number;
  112421. mozMovementY: number;
  112422. webkitMovementX: number;
  112423. webkitMovementY: number;
  112424. msMovementX: number;
  112425. msMovementY: number;
  112426. }
  112427. interface Navigator {
  112428. mozGetVRDevices: (any: any) => any;
  112429. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  112430. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  112431. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  112432. webkitGetGamepads(): Gamepad[];
  112433. msGetGamepads(): Gamepad[];
  112434. webkitGamepads(): Gamepad[];
  112435. }
  112436. interface HTMLVideoElement {
  112437. mozSrcObject: any;
  112438. }
  112439. interface Math {
  112440. fround(x: number): number;
  112441. imul(a: number, b: number): number;
  112442. }
  112443. interface WebGLProgram {
  112444. context?: WebGLRenderingContext;
  112445. vertexShader?: WebGLShader;
  112446. fragmentShader?: WebGLShader;
  112447. isParallelCompiled: boolean;
  112448. onCompiled?: () => void;
  112449. }
  112450. interface WebGLRenderingContext {
  112451. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  112452. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  112453. vertexAttribDivisor(index: number, divisor: number): void;
  112454. createVertexArray(): any;
  112455. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  112456. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  112457. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  112458. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  112459. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  112460. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  112461. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  112462. // Queries
  112463. createQuery(): WebGLQuery;
  112464. deleteQuery(query: WebGLQuery): void;
  112465. beginQuery(target: number, query: WebGLQuery): void;
  112466. endQuery(target: number): void;
  112467. getQueryParameter(query: WebGLQuery, pname: number): any;
  112468. getQuery(target: number, pname: number): any;
  112469. MAX_SAMPLES: number;
  112470. RGBA8: number;
  112471. READ_FRAMEBUFFER: number;
  112472. DRAW_FRAMEBUFFER: number;
  112473. UNIFORM_BUFFER: number;
  112474. HALF_FLOAT_OES: number;
  112475. RGBA16F: number;
  112476. RGBA32F: number;
  112477. R32F: number;
  112478. RG32F: number;
  112479. RGB32F: number;
  112480. R16F: number;
  112481. RG16F: number;
  112482. RGB16F: number;
  112483. RED: number;
  112484. RG: number;
  112485. R8: number;
  112486. RG8: number;
  112487. UNSIGNED_INT_24_8: number;
  112488. DEPTH24_STENCIL8: number;
  112489. /* Multiple Render Targets */
  112490. drawBuffers(buffers: number[]): void;
  112491. readBuffer(src: number): void;
  112492. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  112493. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  112494. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  112495. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  112496. // Occlusion Query
  112497. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  112498. ANY_SAMPLES_PASSED: number;
  112499. QUERY_RESULT_AVAILABLE: number;
  112500. QUERY_RESULT: number;
  112501. }
  112502. interface WebGLBuffer {
  112503. references: number;
  112504. capacity: number;
  112505. is32Bits: boolean;
  112506. }
  112507. interface WebGLProgram {
  112508. transformFeedback?: WebGLTransformFeedback | null;
  112509. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  112510. }
  112511. interface EXT_disjoint_timer_query {
  112512. QUERY_COUNTER_BITS_EXT: number;
  112513. TIME_ELAPSED_EXT: number;
  112514. TIMESTAMP_EXT: number;
  112515. GPU_DISJOINT_EXT: number;
  112516. QUERY_RESULT_EXT: number;
  112517. QUERY_RESULT_AVAILABLE_EXT: number;
  112518. queryCounterEXT(query: WebGLQuery, target: number): void;
  112519. createQueryEXT(): WebGLQuery;
  112520. beginQueryEXT(target: number, query: WebGLQuery): void;
  112521. endQueryEXT(target: number): void;
  112522. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  112523. deleteQueryEXT(query: WebGLQuery): void;
  112524. }
  112525. interface WebGLUniformLocation {
  112526. _currentState: any;
  112527. }
  112528. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  112529. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  112530. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  112531. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  112532. interface WebGLRenderingContext {
  112533. readonly RASTERIZER_DISCARD: number;
  112534. readonly DEPTH_COMPONENT24: number;
  112535. readonly TEXTURE_3D: number;
  112536. readonly TEXTURE_2D_ARRAY: number;
  112537. readonly TEXTURE_COMPARE_FUNC: number;
  112538. readonly TEXTURE_COMPARE_MODE: number;
  112539. readonly COMPARE_REF_TO_TEXTURE: number;
  112540. readonly TEXTURE_WRAP_R: number;
  112541. readonly HALF_FLOAT: number;
  112542. readonly RGB8: number;
  112543. readonly RED_INTEGER: number;
  112544. readonly RG_INTEGER: number;
  112545. readonly RGB_INTEGER: number;
  112546. readonly RGBA_INTEGER: number;
  112547. readonly R8_SNORM: number;
  112548. readonly RG8_SNORM: number;
  112549. readonly RGB8_SNORM: number;
  112550. readonly RGBA8_SNORM: number;
  112551. readonly R8I: number;
  112552. readonly RG8I: number;
  112553. readonly RGB8I: number;
  112554. readonly RGBA8I: number;
  112555. readonly R8UI: number;
  112556. readonly RG8UI: number;
  112557. readonly RGB8UI: number;
  112558. readonly RGBA8UI: number;
  112559. readonly R16I: number;
  112560. readonly RG16I: number;
  112561. readonly RGB16I: number;
  112562. readonly RGBA16I: number;
  112563. readonly R16UI: number;
  112564. readonly RG16UI: number;
  112565. readonly RGB16UI: number;
  112566. readonly RGBA16UI: number;
  112567. readonly R32I: number;
  112568. readonly RG32I: number;
  112569. readonly RGB32I: number;
  112570. readonly RGBA32I: number;
  112571. readonly R32UI: number;
  112572. readonly RG32UI: number;
  112573. readonly RGB32UI: number;
  112574. readonly RGBA32UI: number;
  112575. readonly RGB10_A2UI: number;
  112576. readonly R11F_G11F_B10F: number;
  112577. readonly RGB9_E5: number;
  112578. readonly RGB10_A2: number;
  112579. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  112580. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  112581. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  112582. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  112583. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  112584. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  112585. 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;
  112586. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  112587. readonly TRANSFORM_FEEDBACK: number;
  112588. readonly INTERLEAVED_ATTRIBS: number;
  112589. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  112590. createTransformFeedback(): WebGLTransformFeedback;
  112591. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  112592. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  112593. beginTransformFeedback(primitiveMode: number): void;
  112594. endTransformFeedback(): void;
  112595. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  112596. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  112597. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  112598. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  112599. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  112600. }
  112601. interface ImageBitmap {
  112602. readonly width: number;
  112603. readonly height: number;
  112604. close(): void;
  112605. }
  112606. interface WebGLQuery extends WebGLObject {
  112607. }
  112608. declare var WebGLQuery: {
  112609. prototype: WebGLQuery;
  112610. new(): WebGLQuery;
  112611. };
  112612. interface WebGLSampler extends WebGLObject {
  112613. }
  112614. declare var WebGLSampler: {
  112615. prototype: WebGLSampler;
  112616. new(): WebGLSampler;
  112617. };
  112618. interface WebGLSync extends WebGLObject {
  112619. }
  112620. declare var WebGLSync: {
  112621. prototype: WebGLSync;
  112622. new(): WebGLSync;
  112623. };
  112624. interface WebGLTransformFeedback extends WebGLObject {
  112625. }
  112626. declare var WebGLTransformFeedback: {
  112627. prototype: WebGLTransformFeedback;
  112628. new(): WebGLTransformFeedback;
  112629. };
  112630. interface WebGLVertexArrayObject extends WebGLObject {
  112631. }
  112632. declare var WebGLVertexArrayObject: {
  112633. prototype: WebGLVertexArrayObject;
  112634. new(): WebGLVertexArrayObject;
  112635. };
  112636. // Type definitions for WebVR API
  112637. // Project: https://w3c.github.io/webvr/
  112638. // Definitions by: six a <https://github.com/lostfictions>
  112639. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  112640. interface VRDisplay extends EventTarget {
  112641. /**
  112642. * Dictionary of capabilities describing the VRDisplay.
  112643. */
  112644. readonly capabilities: VRDisplayCapabilities;
  112645. /**
  112646. * z-depth defining the far plane of the eye view frustum
  112647. * enables mapping of values in the render target depth
  112648. * attachment to scene coordinates. Initially set to 10000.0.
  112649. */
  112650. depthFar: number;
  112651. /**
  112652. * z-depth defining the near plane of the eye view frustum
  112653. * enables mapping of values in the render target depth
  112654. * attachment to scene coordinates. Initially set to 0.01.
  112655. */
  112656. depthNear: number;
  112657. /**
  112658. * An identifier for this distinct VRDisplay. Used as an
  112659. * association point in the Gamepad API.
  112660. */
  112661. readonly displayId: number;
  112662. /**
  112663. * A display name, a user-readable name identifying it.
  112664. */
  112665. readonly displayName: string;
  112666. readonly isConnected: boolean;
  112667. readonly isPresenting: boolean;
  112668. /**
  112669. * If this VRDisplay supports room-scale experiences, the optional
  112670. * stage attribute contains details on the room-scale parameters.
  112671. */
  112672. readonly stageParameters: VRStageParameters | null;
  112673. /**
  112674. * Passing the value returned by `requestAnimationFrame` to
  112675. * `cancelAnimationFrame` will unregister the callback.
  112676. * @param handle Define the hanle of the request to cancel
  112677. */
  112678. cancelAnimationFrame(handle: number): void;
  112679. /**
  112680. * Stops presenting to the VRDisplay.
  112681. * @returns a promise to know when it stopped
  112682. */
  112683. exitPresent(): Promise<void>;
  112684. /**
  112685. * Return the current VREyeParameters for the given eye.
  112686. * @param whichEye Define the eye we want the parameter for
  112687. * @returns the eye parameters
  112688. */
  112689. getEyeParameters(whichEye: string): VREyeParameters;
  112690. /**
  112691. * Populates the passed VRFrameData with the information required to render
  112692. * the current frame.
  112693. * @param frameData Define the data structure to populate
  112694. * @returns true if ok otherwise false
  112695. */
  112696. getFrameData(frameData: VRFrameData): boolean;
  112697. /**
  112698. * Get the layers currently being presented.
  112699. * @returns the list of VR layers
  112700. */
  112701. getLayers(): VRLayer[];
  112702. /**
  112703. * Return a VRPose containing the future predicted pose of the VRDisplay
  112704. * when the current frame will be presented. The value returned will not
  112705. * change until JavaScript has returned control to the browser.
  112706. *
  112707. * The VRPose will contain the position, orientation, velocity,
  112708. * and acceleration of each of these properties.
  112709. * @returns the pose object
  112710. */
  112711. getPose(): VRPose;
  112712. /**
  112713. * Return the current instantaneous pose of the VRDisplay, with no
  112714. * prediction applied.
  112715. * @returns the current instantaneous pose
  112716. */
  112717. getImmediatePose(): VRPose;
  112718. /**
  112719. * The callback passed to `requestAnimationFrame` will be called
  112720. * any time a new frame should be rendered. When the VRDisplay is
  112721. * presenting the callback will be called at the native refresh
  112722. * rate of the HMD. When not presenting this function acts
  112723. * identically to how window.requestAnimationFrame acts. Content should
  112724. * make no assumptions of frame rate or vsync behavior as the HMD runs
  112725. * asynchronously from other displays and at differing refresh rates.
  112726. * @param callback Define the eaction to run next frame
  112727. * @returns the request handle it
  112728. */
  112729. requestAnimationFrame(callback: FrameRequestCallback): number;
  112730. /**
  112731. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  112732. * Repeat calls while already presenting will update the VRLayers being displayed.
  112733. * @param layers Define the list of layer to present
  112734. * @returns a promise to know when the request has been fulfilled
  112735. */
  112736. requestPresent(layers: VRLayer[]): Promise<void>;
  112737. /**
  112738. * Reset the pose for this display, treating its current position and
  112739. * orientation as the "origin/zero" values. VRPose.position,
  112740. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  112741. * updated when calling resetPose(). This should be called in only
  112742. * sitting-space experiences.
  112743. */
  112744. resetPose(): void;
  112745. /**
  112746. * The VRLayer provided to the VRDisplay will be captured and presented
  112747. * in the HMD. Calling this function has the same effect on the source
  112748. * canvas as any other operation that uses its source image, and canvases
  112749. * created without preserveDrawingBuffer set to true will be cleared.
  112750. * @param pose Define the pose to submit
  112751. */
  112752. submitFrame(pose?: VRPose): void;
  112753. }
  112754. declare var VRDisplay: {
  112755. prototype: VRDisplay;
  112756. new(): VRDisplay;
  112757. };
  112758. interface VRLayer {
  112759. leftBounds?: number[] | Float32Array | null;
  112760. rightBounds?: number[] | Float32Array | null;
  112761. source?: HTMLCanvasElement | null;
  112762. }
  112763. interface VRDisplayCapabilities {
  112764. readonly canPresent: boolean;
  112765. readonly hasExternalDisplay: boolean;
  112766. readonly hasOrientation: boolean;
  112767. readonly hasPosition: boolean;
  112768. readonly maxLayers: number;
  112769. }
  112770. interface VREyeParameters {
  112771. /** @deprecated */
  112772. readonly fieldOfView: VRFieldOfView;
  112773. readonly offset: Float32Array;
  112774. readonly renderHeight: number;
  112775. readonly renderWidth: number;
  112776. }
  112777. interface VRFieldOfView {
  112778. readonly downDegrees: number;
  112779. readonly leftDegrees: number;
  112780. readonly rightDegrees: number;
  112781. readonly upDegrees: number;
  112782. }
  112783. interface VRFrameData {
  112784. readonly leftProjectionMatrix: Float32Array;
  112785. readonly leftViewMatrix: Float32Array;
  112786. readonly pose: VRPose;
  112787. readonly rightProjectionMatrix: Float32Array;
  112788. readonly rightViewMatrix: Float32Array;
  112789. readonly timestamp: number;
  112790. }
  112791. interface VRPose {
  112792. readonly angularAcceleration: Float32Array | null;
  112793. readonly angularVelocity: Float32Array | null;
  112794. readonly linearAcceleration: Float32Array | null;
  112795. readonly linearVelocity: Float32Array | null;
  112796. readonly orientation: Float32Array | null;
  112797. readonly position: Float32Array | null;
  112798. readonly timestamp: number;
  112799. }
  112800. interface VRStageParameters {
  112801. sittingToStandingTransform?: Float32Array;
  112802. sizeX?: number;
  112803. sizeY?: number;
  112804. }
  112805. interface Navigator {
  112806. getVRDisplays(): Promise<VRDisplay[]>;
  112807. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  112808. }
  112809. interface Window {
  112810. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  112811. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  112812. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  112813. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  112814. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  112815. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  112816. }
  112817. interface Gamepad {
  112818. readonly displayId: number;
  112819. }
  112820. interface XRDevice {
  112821. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  112822. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  112823. }
  112824. interface XRSession {
  112825. getInputSources(): Array<any>;
  112826. baseLayer: XRWebGLLayer;
  112827. requestFrameOfReference(type: string): Promise<void>;
  112828. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  112829. end(): Promise<void>;
  112830. requestAnimationFrame: Function;
  112831. addEventListener: Function;
  112832. }
  112833. interface XRSessionCreationOptions {
  112834. outputContext?: WebGLRenderingContext | null;
  112835. immersive?: boolean;
  112836. environmentIntegration?: boolean;
  112837. }
  112838. interface XRLayer {
  112839. getViewport: Function;
  112840. framebufferWidth: number;
  112841. framebufferHeight: number;
  112842. }
  112843. interface XRView {
  112844. projectionMatrix: Float32Array;
  112845. }
  112846. interface XRFrame {
  112847. getDevicePose: Function;
  112848. getInputPose: Function;
  112849. views: Array<XRView>;
  112850. baseLayer: XRLayer;
  112851. }
  112852. interface XRFrameOfReference {
  112853. }
  112854. interface XRWebGLLayer extends XRLayer {
  112855. framebuffer: WebGLFramebuffer;
  112856. }
  112857. declare var XRWebGLLayer: {
  112858. prototype: XRWebGLLayer;
  112859. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  112860. };